True Type字体格式:笔位置,提前宽度和字距 [英] True Type Font format: Pen Position, Advance Width and Kerning

查看:300
本文介绍了True Type字体格式:笔位置,提前宽度和字距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一些字体的工作,现在使用TTF(True Type Font)文件格式。我知道glyph有一个笔尖位置和一个 advance width 参数,它指定我们应该向右移动的距离(假设从左到右的字体在这里和水平之间)绘制下一个字形。我的问题:


  • 在哪里可以找到FFT文件中高级宽度的数据。是在 hhea 表?是 advanceWidthMax

  • 我无法找到文件中定义的笔位置在哪里?你能指出我将这个表存储在哪里吗? (或者我应该从字形xmin,ymin,基线和左轴承数据计算出来,然后使用字距进行额外的小调整?)

  • 是高级宽度的全局字体?


  • 每个字形都有一个笔位置吗?我明白为了调整字形之间的位置,你应该使用字间距数据来指定字形与高级宽度之间的偏移量。那是正确的吗?

    $ b $ h1>编辑

    我找到了部分回答我的问题:
    $ b $ ul
    $ h $包括整个字体的信息 li>

  • 尽管这个信息并不适用。您需要从 htmx 表格中读取包含字体中每个字形数据(左侧方向和前进宽度)的数据。


我仍然对笔的位置感兴趣)以及如何正确使用字距数据。

解决方案

希望这可以帮助未来的人。我发现:

虽然这个信息并不真正适用,但是它包含整个字体的信息。您需要从 html 表格中读取包含字体中每个字形(左侧方位和前进宽度)数据的数据。通常这个表格包含的字体包含字形的条目数量。每个条目都指定了字形左侧的方位和前进宽度。


我没有找到关于笔位置的任何信息,但我假设字形的xmin值是相对于EM平方的原点。所以要找到笔的位置(在x中),您需要执行以下操作:

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

一旦字形被绘制,您就需要移动 glyph-> advanceWidth ,然后为绘制的字形重复该过程。我不知道这100%是否准确,但至少这是我迄今为止所反向设计的。


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 that specifies the distance by which we should move to the right (assume left to right font here and horizontal) before drawing the next glyph. My questions:

  • where do I find the data for the advanced width in the FFT file. Is that in the hhea table? Is that advanceWidthMax?
  • I can't find where would the pen position defined in the file? Could you please indicate me the table where this would be stored? (or should I compute that from the glyph xmin, ymin, baseline and left bearing data? and then potentially use kerning for additional small adjustments?)

  • is the advanced width global for the font?

  • is there a pen position for each glyph?

  • I understand in order to adjust position between glyph you should be using the kerning data that specifies an offset between glyph with respect to the advanced width. Is that correct?

EDIT

I found a partial answer to my questions:

  • hhea contains information for the whole font
  • though this info is not really applicable. You need to read the data from the htmx table that contains data for each glyph in the font (left side bearing and advance width).

I am still interested in pen position) and how to properly use kerning data.

解决方案

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.

这篇关于True Type字体格式:笔位置,提前宽度和字距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆