From c88be61b1ffb3945316a817be7967eef94f34a4e Mon Sep 17 00:00:00 2001 From: Zachary Scheuren Date: Mon, 6 Apr 2020 09:46:20 -0700 Subject: [PATCH] In otf2ttf conversion update LSB in hmtx to match xMin --- Snippets/otf2ttf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Snippets/otf2ttf.py b/Snippets/otf2ttf.py index 7a6bfe845..b925b33c4 100755 --- a/Snippets/otf2ttf.py +++ b/Snippets/otf2ttf.py @@ -38,6 +38,13 @@ def glyphs_to_quadratic( 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): assert ttFont.sfntVersion == "OTTO" 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) del ttFont["CFF "] glyf.compile(ttFont) + update_hmtx(ttFont, glyf) ttFont["maxp"] = maxp = newTable("maxp") maxp.tableVersion = 0x00010000