# Is there a way to turn off filter of fonts?

**URL:** <https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122>\
**Category:** Questions\
**Tags:** gui\
**Created:** [March 17, 2023, 7:46am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122 "2023-03-17T07:46:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 17, 2023, 7:46am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/1 "2023-03-17T07:46:54Z")

</div>

I’m using this font:

> **[Retro Gaming Font | dafont.com](https://www.dafont.com/retro-gaming.font)**
>
> Retro Gaming Font | dafont.com

And I noticed it’s being smoothed. I’d like to display all the blocky pixels in their glory. How can I do that? Thanks!

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 17, 2023, 12:03pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/2 "2023-03-17T12:03:58Z")

</div>

Hello! How are you drawing the font? Are you using a texture? A Playground example would be helpful here 🙂

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 18, 2023, 6:29am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/3 "2023-03-18T06:29:02Z")

</div>

I’m using a TextBlock and loading through html css. How can I do that in a playground?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 20, 2023, 1:23pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/4 "2023-03-20T13:23:46Z")

</div>

You can manually create and attach the css containing the font, like in this example: [Custom font | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#HN1I8Z#1). In any case, one thing you can already try is changing the GUI texture sampling mode to nearest, as that’s the usual ideal for pixel perfection.

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 22, 2023, 8:05am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/6 "2023-03-22T08:05:49Z")

</div>

I’m having trouble due to CORS. Where can I host the font?

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [March 22, 2023, 8:20am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/7 "2023-03-22T08:20:55Z")

</div>

Sorry, I removed by accident the example

[Text to customMesh in any TrueType font | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#IVGSG0#76)

**chatGPT:**  
If you are experiencing CORS (Cross-Origin Resource Sharing) issues with fonts, it is likely because the font file is hosted on a different domain than the website using it. To solve this issue, you can host the font on the same domain as your website.

Here are some options for hosting your font:

1. Host the font on your own server: You can upload the font files to your own server and serve them from there. This is a good option if you have control over your own server and have the necessary knowledge to set it up.
2. Use a content delivery network (CDN): A CDN is a network of servers that distribute content across the internet. There are many CDN services available that can host your font files, such as Google Fonts, Adobe Fonts, and Typekit. These services often have their own cross-domain policies in place, which can help to mitigate CORS issues.
3. Use a font hosting service: There are several font hosting services available that specialize in hosting fonts for websites. Some popular options include [Fonts.com](http://Fonts.com), Fontspring, and MyFonts. These services often offer additional features such as font management and licensing.

Regardless of which option you choose, be sure to test your website thoroughly to ensure that the font is loading correctly and that there are no CORS issues.

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 22, 2023, 8:43am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/9 "2023-03-22T08:43:01Z")

</div>

Yeah my server doesn’t have CORS enabled, I don’t have a CDN atm, and all of those sites listed are for hosting fonts bought through the site… thanks chatgpt…

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 22, 2023, 8:44am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/10 "2023-03-22T08:44:04Z")

</div>

I’m guessing the font I’m linking is missing some data in the ttf file for spacing/alignment.  
I’m getting more issues with this font:

> **[kroeger 05\_57 Font - FontZone.net](https://fontzone.net/font-details/kroeger-05-57)**
>
> Download kroeger 05\_57 font free! - FontZone.net offering 1000's of FREE fonts to download to help the millions of designers across the globe expressing their creativity with much more diversity

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [March 22, 2023, 9:14am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/11 "2023-03-22T09:14:41Z")

</div>

Since your demand on font quality is not very high, what do you think about the idea of defining your own font in the form of a matrix?

I have found an interesting approach to generate an ASCII type from the 2D context of a canvas element:

```auto
    <script>
        var canvas = document.createElement('canvas');
        canvas.width = 500;
        canvas.height = 500;
        document.body.appendChild(canvas);

        let c = canvas.getContext("2d");
        c.fillText("H e l l o !", 0, 7);
        d = c.getImageData(0, 0, 56, 7).data;
        s = "";
        for (i = 3; i < d.length; i += 4) {
            s += d[i] ? "#" : " ";
            s += (i + 1) % 224 ? " " : "\n";
        }

        console.log(s);
    </script>

```

Output on the console:

```auto
# # # # # # # # # # # #                                  
# # # # # # # # # # # #                                  
# # # # # # # # # # # # # # # # # # # # #                                  
# # # # # # # # # # # # # # # # # # # # # # # # #                                  
# # # # # # # # # # # # # # # # # # # # # #                                  
# # # # # # # # # # # # # # # # #                                            
# # # # # # # # # # # # # # # # # # # # # #

```

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 22, 2023, 5:45pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/12 "2023-03-22T17:45:50Z")

</div>

No, I just need these fonts to work. Auto resize doesn’t work either.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 22, 2023, 7:00pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/13 "2023-03-22T19:00:03Z")

</div>

Can you host it on github? I find it the easiest way: [Using External Assets In the Playground | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/toolsAndResources/thePlayground/externalPGAssets)

You could set up a webpage through github and share your project too

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 23, 2023, 1:46am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/14 "2023-03-23T01:46:10Z")

</div>

@carolhmj That worked! Thank you!

Unfortunately I can’t repro it in playgrounds… blarg

> **[Babylon.js Playground](https://playground.babylonjs.com/#HN1I8Z%2317)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

That works fine…

![Screenshot 2023-03-22 at 6.44.48 PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/1/61fe99d3c8607caaf5a8c3b2e04a640b317e4302.png)  
That’s what it looks like locally. hm

EDIT: oh wait I just reloaded the playground and now it does it.

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 23, 2023, 1:48am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/15 "2023-03-23T01:48:39Z")

</div>

Ok I’m on to something so. I click on:

> **[Babylon.js Playground](https://playground.babylonjs.com/#HN1I8Z%2317)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Then it looks like the font doesn’t load and I click the play button and it loads and shows the clipping problem!

 ![Screenshot 2023-03-22 at 6.48.25 PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/6/361f8b64a9376bec3a358c6847a223abd7de1ab4.png)  
 ![Screenshot 2023-03-22 at 6.48.16 PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/b/4beb6cd7448f8e0de4a3b69aa6acc768497d237c.png)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [March 23, 2023, 12:47pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/16 "2023-03-23T12:47:17Z")

</div>

Oh yeah, the Playground has this weird quirk where the fonts don’t seem to load the first time. Quick question: does this happen with only this font? Have you tried switching this font in your game to another pixel style font to see if the same thing happens? Knowing this would help us narrow down if the problem is specific to a font or something general 🤔

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [March 23, 2023, 2:10pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/17 "2023-03-23T14:10:16Z")

</div>

In fact, I’m also having problems loading google fonts through the head of the document and @import.  
Eventually, it loads. Eventually it doesn’t. The only reliable loading of custom font I found is with typekit.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [March 23, 2023, 2:35pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/18 "2023-03-23T14:35:37Z")

</div>

> **[Web Font preloading for HTML5 games – Mozilla Hacks - the Web developer blog](https://hacks.mozilla.org/2016/06/webfont-preloading-for-html5-games/)**
>
> In game development there are two methods of rendering text: via bitmap fonts and vector fonts. Bitmap fonts are essentially a sprite sheet image that contains all the characters of ...

A common browser behavior is that the font will not even load until the user interacts with the page and needs to be considered.

There are work arounds for it, one of which is make a landing screen with baked out text that the user sees when they come to the page. That require them then to interact with a “Play” button or something which then will allow the fonts to propagate.

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [March 23, 2023, 5:37pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/19 "2023-03-23T17:37:55Z")

</div>

You can hook to an event when the font is loaded:  
[create-react-app-typescript-babylonjs/App.tsx at master · brianzinn/create-react-app-typescript-babylonjs · GitHub](https://github.com/brianzinn/create-react-app-typescript-babylonjs/blob/master/src/App.tsx#L28)

Then call `markAsDirty()` on the ADT. That will update the fallback font to the correct font, or you can hold off showing the GUI until the font is loaded.

edit: I think I had brought up once if we could add a font list to the constructor of ADT and then it would automatically mark as dirty. To get the correct font name you can loop through the `document.fonts`.

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 24, 2023, 4:37am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/20 "2023-03-24T04:37:02Z")

</div>

Typekit? How does that work?

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 24, 2023, 4:38am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/21 "2023-03-24T04:38:47Z")

</div>

Looks like I can make it happen with most other fonts and it happens mostly with the second @fontface so it looks like this is a loading issue.

---

<div class="post-metadata">

**Author:** ![Pixelodo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pixelodo/32/29875_2.png) [@Pixelodo](https://forum.babylonjs.com/u/Pixelodo)\
**Post date:** [March 24, 2023, 4:39am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122/22 "2023-03-24T04:39:50Z")

</div>

So I guess I’m looking for the most reliable way to load fonts into Babylon.

[Next page](https://forum.babylonjs.com/t/is-there-a-way-to-turn-off-filter-of-fonts/39122.md?page=2)
