如何計算字體高度?
如上圖中是「華文中宋」的字體屬性,UPM是1000,怎麼計算字體高度?中文字體與西文字體的計算有什麼區別?補充:我想問的「字體高度」指的是字元排版時的「行高」。如下圖所示,當清除所有段落布局時,行高應該正好等於字體高度。另外:字體屬性中的那些數值分別表示什麼意思?
Typo Ascender、Typo Descender、Typo Line Gap、Win Asecnt、Win Descent、Ascender、Descender、Line Gap。補充:由於我這個問題問的不是太清楚,@梁海 已經問了一個更清楚的問題:Office Word 是如何根據字體的 OS/2 表等信息計算「單倍行距」的?
@梁海 詳細已經回答了第一個問題,恕不贅述。關於後面提到的幾個參數:題主用的是FontCreator 7.5吧。題主提到的那些參數,FontCreator的用戶手冊裡面有詳細的解釋。用戶手冊位於菜單里的Help—User Manual中,是一個pdf文件。引用如下:
Typo Ascender
The typographic ascender for this font. Remember that this is not the same as the Ascender value in the Metrics tab, which Apple defines in a far different manner.The suggested usage for TypoAscender is that it be used in conjunction with unitsPerEm to compute a typographically correct default line spacing. The goal is to free applications from Macintosh or Windows-specific metrics which are constrained by backward compatibility requirements. These new metrics, when combined with the character design widths, will allow applications to lay out documents in a typographically correct and portable fashion.For CJK (Chinese, Japanese, and Korean) fonts that are intended to be used for vertical writing (in addition to horizontal writing), the required value for TypoAscender is that which describes the top of the design space (aka, em-square). For example, if the design space of the font extends from coordinates 0,-120 to 1000,880 (that is, a 1000x1000 box set 120 design units below the Latin baseline), then the value of TypoAscender must be set to 880. Failing to adhere to these requirements will result in incorrect vertical layout.Typo Descender
The typographic descender for this font. Remember that this is not the same as the Descender value in the Metrics tab, which Apple defines in a far different manner.The suggested usage for Typo Descender is that it be used in conjunction with unitsPerEm to compute a typographically correct default line spacing. The goal is to free applications from Macintosh or Windows-specific metrics, which are constrained by backward compatibility requirements. These new metrics, when combined with the character design widths, will allow applications to lay out documents in a typographically correct and portable fashion.For CJK (Chinese, Japanese, and Korean) fonts that are intended to be used for vertical writing (in addition to horizontal writing), the required value for Typo Descender is that which describes the bottom of the design space (aka, em-square). For example, if the design space of the font extends from coordinates 0,-120 to 1000,880 (that is, a 1000x1000 box set 120 design units below the Latin baseline), then the value of Typo Descender must be set to - 120. Failing to adhere to these requirements will result in incorrect vertical layout.Typo Line GapThe typographic line gap for this font. Remember that this is not the same as the Line Gap value, which Apple defines in a far different manner.The suggested usage for Typo Line Gap is that it be used in conjunction with Units per em to compute a typographically correct default line spacing. Typical values average 7-10% of units per em.Win AscentThe ascender metric for Windows. This, too, is distinct from Apples Ascender value and from the Typo Ascender value. Win Ascent is computed as the yMax for all characters in the Windows ANSI character set. Win Ascent is used to compute the Windows font height and default line spacing. For Symbol fonts, it is the same as yMax.Win DescentThe descender metric for Windows. This, too, is distinct from Apples Descender value and from the Typo Descender value. Win Descent is computed as the -yMin for all characters in the Windows ANSI character set. Win Descent is used to compute the Windows font height and default line spacing. For Symbol fonts, it is the same as -yMin.
Ascender (Macintosh-specific)Typographic ascentDescender (Macintosh-specific)Typographic descentLine Gap (Macintosh-specific)
Typographic line gap. Negative Line Gap values are treated as zero.
行高通常指任意相鄰兩行基線之間的距離。
你魯莽地把自己的疑問抽象成現在這個樣子,別人沒法確認你到底想問什麼。說清楚你具體想用自己所說的「字體高度」這個數值來做什麼,否則只能建議你自己去看 OpenType 文檔了(而且你既然想知道那些數值的意義也本來就得去讀文檔):
- The Horizontal Header Table
- The OS/2 Windows Metrics Table
lineHeight1 = ( hhea.ascent + hhea.descent + hhea.lineGap ) / head.unitsPerEm
這個行高數值乘以當前字型大小(比如 10 pt)就是你要的具體尺度數值了。另外注意它在排版環境中會取整,比如在 Pages 里應該是四捨五入的。比如華文中宋的行高計算出來是
lineHeight1 = 1.325 = ( 1007 + 318 + 0 ) / 1000
於是在 Pages 里,10 pt 的文本行高取整至 13 pt,而 100 pt 的文本行高取整至 133 pt。
但是 Windows 里的情況比較複雜,按理說應當是符合 OpenType 規範的lineHeight2 = ( OS/2.sTypoAscender + OS/2.sTypoDescender + OS/2.sTypoLineGap )
/ head.unitsPerEm
或其實更常見但不符合規範的
lineHeight3 = ( OS/2.usWinAscent + OS/2.usWinDescent ) / head.unitsPerEm
這二者之一。但是,按照以上兩種方法算出來分別是 1.144 和 1.137。而華文中宋的行高在 Word 2013 里(已關閉「如果定義了文檔網格,則對齊到網格」)是個似乎介於 1.47 與 1.48 之間的數值。
不知與加上 sTypoLineGap 的 144 之後的行高數值lineHeight4 = 1.469 = ( lineHeight1 + OS/2.sTypoLineGap) / head.unitsPerEm
是否有關。
推薦閱讀:
※如何看待與評價方正悠黑三維可變、文鼎晶熙黑(可變字體)?
※雙語標準字:思路與實踐
※推薦兩款中西文字體搭配
※初學設計師,字體設計怎麼練?
※為什麼感覺 iOS 設備上的中文字體效果比 Android 設備漂亮?