aboutsummaryrefslogtreecommitdiff
path: root/Snippets/otf2ttf.py
diff options
context:
space:
mode:
Diffstat (limited to 'Snippets/otf2ttf.py')
-rwxr-xr-xSnippets/otf2ttf.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Snippets/otf2ttf.py b/Snippets/otf2ttf.py
index 62b4f735..b925b33c 100755
--- a/Snippets/otf2ttf.py
+++ b/Snippets/otf2ttf.py
@@ -1,12 +1,11 @@
-#!/usr/bin/env python
-from __future__ import print_function, division, absolute_import
+#!/usr/bin/env python3
import argparse
import logging
import os
import sys
-from cu2qu.pens import Cu2QuPen
+from fontTools.pens.cu2quPen import Cu2QuPen
from fontTools import configLogger
from fontTools.misc.cliTools import makeOutputFileName
from fontTools.pens.ttGlyphPen import TTGlyphPen
@@ -39,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
@@ -51,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