Lazarus

Programming => Packages and Libraries => LazUtils => Topic started by: zamtmn on February 18, 2013, 10:22:37 am

Title: [LazFreeType] how get charcode by glyph index?
Post 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?
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: circular on February 18, 2013, 11:48:26 am
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
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: zamtmn on February 19, 2013, 08:27:08 am
Thanks, I thought so. While did just brute force attack, but it is slow. Have to do the inverse functions.
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: circular on February 19, 2013, 09:41:04 am
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)
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: zamtmn on February 19, 2013, 10:12:16 am
Ок. I will try to do when I decide other issues with the TTF in my app
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: circular on February 19, 2013, 10:21:00 am
Ok.
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: zamtmn on February 28, 2013, 10:55:28 am
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
Title: Re: [LazFreeType] how get charcode by glyph index?
Post by: circular on March 01, 2013, 07:05:19 pm
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.
TinyPortal © 2005-2018