The 2024 Wheel Reinvention Jam is in 16 days. September 23-29, 2024. More info

Problems with loading fonts need help

I haven't checked but I suppose monospaced font should not have kerning information. For example "Lucida Console" or fonts with "Mono" in the name.
Yay!

Thanks all of you for your help, so far so good.

My font rendering with stb is close to be completed, but am really stuck trying to display some unicode characters (小耳木兎).
Regardless the font type (liberation mono, arial or times new roman), all I get are those invalid glyphs.

Is there anything in particular I need to be aware or configure when using a unicode in the range of Chinese o Japanese glyphs?




Unicode

P.S. is it only me or the img tag seems broken, it only displays an icon but I see no image

Edited by itzjac on
Most fonts support only a subset of codepoints. You need to use a font that support the codepoint range you want to display. So you will probably need to use several fonts.

For the image tag you need to put the url to the file itself, not the html page. On imgur, right click on the image and select "view image" and use that url ( https://i.imgur.com/ONqSs2q.png instead of https://imgur.com/ONqSs2q ).

Edited by Simon Anciaux on
Not a 100% accurate check (but works most of the time) is to check filesize of font. If it is around 1MB or less - it won't have asian language glyphs. Only fonts with 10MB+ size usually have those.

Edited by Mārtiņš Možeiko on

Not a 100% accurate check (but works most of the time) is to check filesize of font. If it is around 1MB or less - it won't have asian language glyphs. Only fonts with 10MB+ size usually have those.


Oh, that might be right, but really, am using the same ttf file that's in the Windows/font path. Notepad displays those codepoints fine.
Am gonna try downloading another font that looks above 1M.

mrmixer
For the image tag you need to put the url to the file itself, not the html page

thanks that will do!

Edited by itzjac on
@mmozeiko this is a good font (unifoundry) for testing purposes, and yes this one works!




So, how come the same arial font works in Notepad and not in my app?

Where is windows accessing the arial font with chinese characters then?



Edited by itzjac on
It's using a different font based on the codepoint range. https://en.wikipedia.org/wiki/Unicode#Architecture_and_terminology

Edited by Simon Anciaux on Reason: fixed link
More precise: https://en.wikipedia.org/wiki/Font_substitution

Edited by Mārtiņš Možeiko on
Ok, with Font Substitution that makes sense for the office Apps, maybe for Notepad too.


But! When I watched the episode of glyph extraction and unicode, I remember that Mr. Muratori tested the win32 API with the arial font ("C:\\Windows\\Fonts\\arial.ttf") and the chinese glyphs displayed nicely. Was it really arial or which one then?

Is it possible that in the arial used while streaming was different than the one in my win OS (win10 Pro)?

Edited by itzjac on
If I remember correctly he is using Windows API to get font data. Windows API does font substitution automatically. That's why it works everywhere - Word, Notepad, your custom app - everywhere.

If you use something like stb_truetype or freetype library then it is up to you to figure out if ttf file contains needed glyph, and if not then how to manually get it from different ttf file (that's where libraries like fontconfig come into play).

Edited by Mārtiņš Možeiko on
Am glad I found this problem while using the stb_truetype, this is a very important feature to aware of.

I also imagined that the explanation was some "behind the scenes" for the Win32 API.

For the record, thanks all for you input.