Merge pull request #1873 from fonttools/otf2ttf-fix

In otf2ttf conversion update LSB in hmtx to match xMin
This commit is contained in:
Zachary Quinn Scheuren 2020-04-06 15:50:58 -07:00 committed by GitHub
commit 6578b7c8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,13 @@ def glyphs_to_quadratic(
return quadGlyphs return quadGlyphs
def update_hmtx(ttFont, glyf):
hmtx = ttFont["hmtx"]
for glyphName, glyph in glyf.glyphs.items():
if hasattr(glyph, 'xMin'):
hmtx[glyphName] = (hmtx[glyphName][0], glyph.xMin)
def otf_to_ttf(ttFont, post_format=POST_FORMAT, **kwargs): def otf_to_ttf(ttFont, post_format=POST_FORMAT, **kwargs):
assert ttFont.sfntVersion == "OTTO" assert ttFont.sfntVersion == "OTTO"
assert "CFF " in ttFont assert "CFF " in ttFont
@ -50,6 +57,7 @@ def otf_to_ttf(ttFont, post_format=POST_FORMAT, **kwargs):
glyf.glyphs = glyphs_to_quadratic(ttFont.getGlyphSet(), **kwargs) glyf.glyphs = glyphs_to_quadratic(ttFont.getGlyphSet(), **kwargs)
del ttFont["CFF "] del ttFont["CFF "]
glyf.compile(ttFont) glyf.compile(ttFont)
update_hmtx(ttFont, glyf)
ttFont["maxp"] = maxp = newTable("maxp") ttFont["maxp"] = maxp = newTable("maxp")
maxp.tableVersion = 0x00010000 maxp.tableVersion = 0x00010000