Quantcast
Viewing all articles
Browse latest Browse all 5381

C/C++ • Re: Help with Freetype2 and Font Awesome fonts

...
Now, for fonts such as FreeMono.ttf and many others, this works well
However, for the Font Awesome 6 OTF, or the Font Awesome 5 TTF files, it doesn't. If I ask for characters outside the normal ASCII range, it gives me an invalid glyph.
I know that the characters are 32 bit, such as 0xf003, so outside the normal ASCII range, and in the live code, chr is typed as uint32_t.
I also have some code that I use for a similar reason to draw directly to a framebuffer and I am using FreeType2 to render text.

https://github.com/AndrewFromMelbourne/raspifb16
https://github.com/AndrewFromMelbourne/ ... eeType.cxx

The code I have only expects ASCII characters. I did a quick modification, that I might push later and I am able to print the extended characters in both Font Awesome 5 and 6. The value 0xF003 prints an envelope for "Font Awesome 6 Free-Regular-400.otf"

Side note: The value 0xF003 is 16 bit, but yes FT_Get_Char_Index takes a unsigned 32 bit integer for the "charcode".

Question: Can you print extended characters from FreeMono.ttf? For example 0x2B20 prints the outline of a pentagon.
Can anyone give me any clues as to how to start working out what is wrong? I know the font files contain a single face, and multiple charmaps, and I can successfully enumerate the available characters and identify that the characters I want are actually there, but I wonder whether I need to do something different when loading the glyphs?
I don't think there is anything wrong with the way you are loading the glyphs. That code looks similar to mine. I don't use the FT_LOAD_TARGET_MONO flag, as I use the returned value as a greyscale.
Another thing that puzzles me is that if I use the font from within a python3/tkinter app, when I display text using the font, it works, including both lowercase and uppercase letters, but the character to glyph mapping seems to suggest that character 'A' and character 'a' both map to glyph#24. This confirms what I see within the ASCII range. How come python can display normal text?
I can see the same issue with the alphabet being in capitals for both upper and lower case characters. This is only true for Font Awesome 6. I have installed the Font Manager package on my Raspberry Pi 5. The Font Manager and Font Viewer show the same capital letters for Font Awesome 6.

Sorry that this isn't much help. For what it is worth, you can be assured the FreeType2 can render the extended character values in Font Awesome.

Statistics: Posted by AndyD — Sat Jul 13, 2024 2:13 pm



Viewing all articles
Browse latest Browse all 5381

Trending Articles