In otf2ttf conversion update LSB in hmtx to match xMin

This commit is contained in:
Zachary Scheuren 2020-04-06 09:46:20 -07:00
parent efd54dca61
commit c88be61b1f

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