Recent

Author Topic: [LazFreeType] how get charcode by glyph index?  (Read 14018 times)

zamtmn

  • Hero Member
  • *****
  • Posts: 594
[LazFreeType] how get charcode by glyph index?
« 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?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType] how get charcode by glyph index?
« Reply #1 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
« Last Edit: February 18, 2013, 11:50:59 am by circular »
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType] how get charcode by glyph index?
« Reply #2 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.

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType] how get charcode by glyph index?
« Reply #3 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)
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType] how get charcode by glyph index?
« Reply #4 on: February 19, 2013, 10:12:16 am »
Ок. I will try to do when I decide other issues with the TTF in my app

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType] how get charcode by glyph index?
« Reply #5 on: February 19, 2013, 10:21:00 am »
Ok.
Conscience is the debugger of the mind

zamtmn

  • Hero Member
  • *****
  • Posts: 594
Re: [LazFreeType] how get charcode by glyph index?
« Reply #6 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

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: [LazFreeType] how get charcode by glyph index?
« Reply #7 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.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018