glyf: support setting vmtx advance/tsb from phantom points
This commit is contained in:
parent
2b50b94ed7
commit
91089b7a1b
@ -362,9 +362,9 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
||||
"coord" is an array of GlyphCoordinates which must include the four
|
||||
"phantom points".
|
||||
|
||||
Only the horizontal advance and sidebearings in "hmtx" table are updated
|
||||
from the first two phantom points. The last two phantom points for
|
||||
vertical typesetting are currently ignored.
|
||||
Both the horizontal/vertical advances and left/top sidebearings in "hmtx"
|
||||
and "vmtx" tables (if any) are updated from four phantom points and
|
||||
the glyph's bounding boxes.
|
||||
"""
|
||||
# TODO: Create new glyph if not already present
|
||||
assert glyphName in self.glyphs
|
||||
@ -400,9 +400,15 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
||||
# https://github.com/fonttools/fonttools/pull/1198
|
||||
horizontalAdvanceWidth = 0
|
||||
leftSideBearing = otRound(glyph.xMin - leftSideX)
|
||||
# TODO Handle vertical metrics?
|
||||
ttFont["hmtx"].metrics[glyphName] = horizontalAdvanceWidth, leftSideBearing
|
||||
|
||||
if "vmtx" in ttFont:
|
||||
verticalAdvanceWidth = otRound(topSideY - bottomSideY)
|
||||
if verticalAdvanceWidth < 0: # unlikely but do the same as horizontal
|
||||
verticalAdvanceWidth = 0
|
||||
topSideBearing = otRound(topSideY - glyph.yMax)
|
||||
ttFont["vmtx"].metrics[glyphName] = verticalAdvanceWidth, topSideBearing
|
||||
|
||||
|
||||
_GlyphControls = namedtuple(
|
||||
"_GlyphControls", "numberOfContours endPts flags components"
|
||||
|
Loading…
x
Reference in New Issue
Block a user