Lazarus
Programming => Packages and Libraries => LazUtils => Topic started by: zamtmn on February 18, 2013, 10:22:37 am
-
I need to implement a render TTF fonts. I want to use TFreeTypeFont. How can I get the character code by glyph number? Reverse procedure provided TFreeTypeFont.CharIndex [charcode]. If I only known glyph index, the character code I can not find out?
-
Nope, there is no function for that yet.
The char index is obtained using TT_Char_Index function which uses CharMap_Index of TTCMap. So one glyph is not associated with one char code, it depends on the map used.
However it would be possible to do a reverse function similar to CharMap_Index.
By the way, I think that there are still some errors in those functions, because with some fonts like Courier New some glyphs are not found.
Here is some spec for cmap table:
https://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html
-
Thanks, I thought so. While did just brute force attack, but it is slow. Have to do the inverse functions.
-
If you do so, it is possible to add them to LazFreeType.
Note that :
- the relative offsets can be relative to the position after the value of the offset.
- The map is not necessary already loaded (see beginning of CharMap_Index function)
-
Ок. I will try to do when I decide other issues with the TTF in my app
-
Ok.
-
I think a quick search on the glyph index in these data structures is not possible. Requires a different data structure for binary search, it is better to organize outside EasyLazFreeType
-
I think that you need to create a sorted tree, like AVGLVLTree.
This class could be put in the TTCMap unit, that's not a problem, just a matter of time until the patch is applied. But of course you can make it as an independant class, so that it's the same, included or not.