Fix broken line height under Macintosh (#704).

This commit is contained in:
be5invis 2020-10-24 21:44:33 -07:00
parent d144dee113
commit 191d094692
4 changed files with 30 additions and 16 deletions

1
changes/3.7.1.md Normal file
View file

@ -0,0 +1 @@
* Fix broken line height under Macintosh (#704).

View file

@ -42,7 +42,18 @@ module.exports = function () {
},
OS_2: {
achVendID: "BE5N",
panose: [2, 0, 5, 9, 0, 0, 0, 0, 0, 0],
panose: {
bFamilyType: 2,
bSerifStyle: 0,
bWeight: 5,
bProportion: 9,
bContrast: 3,
bStrokeVariation: 0,
bArmStyle: 0,
bLetterform: 0,
bMidline: 0,
bXHeight: 4
},
fsSelection: 192,
fsType: 0,
sCapHeight: 0,

View file

@ -205,28 +205,30 @@ export : define [calculateMetrics para] : begin
export : define [setFontMetrics para metrics fm] : begin
define [object CAP Descender XH Width] metrics
# Metric metadata
# Note: we use 1000upm in design, and (1000 * upmsacle)upm in production, to avoid rounding error.
define asc : para.leading * CAP / (CAP - Descender)
define desc : para.leading * Descender / (CAP - Descender)
define descenderPad : fallback para.descenderPad 0
define leading : Math.round para.leading
define asc : Math.round : leading * CAP / (CAP - Descender)
define desc : Math.round : leading * Descender / (CAP - Descender)
define descenderPad : Math.round : fallback para.descenderPad 0
define winMetricAscenderPad : Math.round : fallback para.winMetricAscenderPad 0
define winMetricDescenderPad : Math.round : fallback para.winMetricDescenderPad 0
set fm.OS_2.xAvgCharWidth Width
set fm.head.unitsPerEm 1000
set fm.hhea.ascender asc
set fm.OS_2.usWinAscent (asc + [fallback para.winMetricAscenderPad 0])
set fm.OS_2.usWinAscent (asc + winMetricAscenderPad)
set fm.OS_2.sTypoAscender asc
set fm.hhea.descender (Descender - descenderPad)
set fm.OS_2.usWinDescent ([Math.abs desc] + descenderPad + [fallback para.winMetricDescenderPad 0])
set fm.OS_2.usWinDescent ([Math.abs desc] + descenderPad + winMetricDescenderPad)
set fm.OS_2.sTypoDescender (desc - descenderPad)
set fm.hhea.lineGap (para.leading - asc + Descender)
set fm.OS_2.sTypoLineGap (para.leading - asc + desc)
set fm.hhea.lineGap (leading - asc + Descender)
set fm.OS_2.sTypoLineGap (leading - asc + desc)
set fm.OS_2.sxHeight XH
set fm.OS_2.sCapHeight CAP
set fm.post.italicAngle (0 - para.slopeAngle)
set fm.post.italicAngle [Math.round (0 - para.slopeAngle)]
export : define [compositeBaseAnchors] : begin

View file

@ -171,7 +171,7 @@ export : define [assignFontNames para metrics font] : begin
# Weight, width and slope
set font.OS_2.usWeightClass para.naming.weight
set font.OS_2.usWidthClass para.naming.width
set font.OS_2.panose.2 : 1 + para.naming.weight / 100
set font.OS_2.panose.bWeight : 1 + para.naming.weight / 100
set font.OS_2.fsSelection : object
oblique : not : not isOblique
bold : not : not isBold
@ -193,8 +193,8 @@ export : define [assignFontNames para metrics font] : begin
set font.head.fontRevision : majorVersion + (minorVersion * 10 + patchVersion) / 1000
if (para.diversityM == 1 && para.diversityF == 1 && para.diversityI == 1 && para.diversityII == 1) : begin
set font.OS_2.panose.3 9 # Monospaced
set font.post.isFixedPitch true
set font.OS_2.panose.bProportion 9 # Monospaced
set font.post.isFixedPitch true
: else : begin
set font.OS_2.panose.3 0
set font.post.isFixedPitch false
set font.OS_2.panose.bProportion 0
set font.post.isFixedPitch false