Forum > LazUtils

[LazFreeType] how get charcode by glyph index?

(1/2) > >>

zamtmn:
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?

circular:
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

zamtmn:
Thanks, I thought so. While did just brute force attack, but it is slow. Have to do the inverse functions.

circular:
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)

zamtmn:
Ок. I will try to do when I decide other issues with the TTF in my app

Navigation

[0] Message Index

[#] Next page

Go to full version