True Type Font format: Pen Position, Advance Width and Kerning

后端 未结 1 1056
失恋的感觉
失恋的感觉 2021-01-27 07:52

I am doing some work with font and use the TTF (True Type Font) file format for now. I understand the glyph has a pen point position and an advance width parameter

相关标签:
1条回答
  • 2021-01-27 08:09

    Hope this can help people in the future.What I found:

    • hhea contains information for the whole font
    • though this info is not really applicable. You need to read the data from the html table that contains data for each glyph in the font (left side bearing and advance width). Generally this table contains as many entries that the font contains glyph. Each entry specifies the glyph left side bearing and advance width.

    I didn't find any info about the pen position but I assume the xmin value of the glyph is with respect to the origin of the EM square. So to find the pen position (in x) you need to do something like:

    pos_pos_x = glyph->leftSideBearing - glyph->min.x
    

    Once the glyph is drawn you then need to move by glyph->advanceWidth and repeat that process for drawn glyph. I don't know if this 100% accurate, but at least this is what i have reversed-engineered so far.

    0 讨论(0)
提交回复
热议问题