计算字体truetype hhea值(上升,下降) [英] Computing font truetype hhea values (ascender, descender)
问题描述
我试图解析truetype字体为建立和存储上升,为每个字体大小的下行,我使用 http://nodebox.github.io/opentype.js/ 做了一个了不起的工作,但我不明白如何计算返回的值。
示例字体Blackoak(adobe)
我有[Ascender,Descender] = 1900和-500
我认为这些数字表示与em空间的基线的距离,但是我需要其他元信息来计算这些值吗?
提前Thx
如果要计算ascender /以字体为单位的下拉字体,然后你需要为 为了将这些数字转换为特定字体大小的像素,还需要提取字体中每个em 的单位数。您可以通过从 I'm trying to parse truetype font for building and store the ascender,descender for each fontsize, i'm using http://nodebox.github.io/opentype.js/ that did an amazing work, but i don't understand how to compute the returned values. Exemple font Blackoak (adobe)
i've got [Ascender, Descender] = 1900 and -5OO I presume that these numbers indicates the distance from the basline in em space, but did i need other meta information for computing these values? Thx in advance If you want to compute ascender/descender in pixels for specific font size, then you need to lookup In order to convert these numbers to pixels for specific font size you also need to extract how many units per em are in your font. You can do that by reading For example, lets take a look at the opentype.js Font Inspector and assume 16px font size. Value
这篇关于计算字体truetype hhea值(上升,下降)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! sTypoAscender
和<$ c $查找 OS / 2
c> sTypoDescender 值(按 W3C )。 hhea
表中的上升和
下降
字体设计师的意图 必然对应于实际的计算值。关于价值类型,你是正确的,上行和下行是在UPM单位,负面意味着低于基准。
头
表中读取 unitsPerEm
值来实现。通常,对于OTF,其1000个UPM,对于TTF-1024或2048个UPM。 sTypoAscender
和 sTypoDescender
的绝对值应该合计为 unitsPerEm
值。然后它只是一个比例的问题。例如,让我们来看看opentype.js nofollow>字体检查器并假设16px的字体大小。值 unitsPerEm
是2048 UPM, sTypoAscender
和 sTypoDescender
是1536 (1536 + 512 = 2048):
Ascender = 16 * 1536/2048 = 12px(高于基线)
Descender = 16 * -512/2048 = -4px(低于基线)
OS/2
table for sTypoAscender
and sTypoDescender
values (as instructed by W3C). The ascender
and descender
values of hhea
table are marking only font designer's intention which not necessarily corresponds to real computed values. Concerning value type, you're right, ascender and descender are in UPM units and negative means below the baseline. unitsPerEm
value from the head
table. Usually, for OTF its 1000 UPM, for TTF - 1024 or 2048 UPM. Absolute values of sTypoAscender
and sTypoDescender
should add up to unitsPerEm
value. And then its just a matter of ratio. unitsPerEm
is 2048 UPM, sTypoAscender
and sTypoDescender
are 1536 and -512 correspondingly (1536 + 512 = 2048): Ascender = 16 * 1536/2048 = 12px (above baseline)
Descender = 16 * -512/2048 = -4px (below baseline)