Skip to content

Commit

Permalink
Version 1.5.6 update
Browse files Browse the repository at this point in the history
Converter.changeUPM(): fix the bug to avoid composite glyphs being
scaled multiple times.
  • Loading branch information
Pal3love committed Sep 28, 2017
1 parent 1c96d6b commit ca28bfd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
23 changes: 18 additions & 5 deletions Package/otRebuilder/Lib/Converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ def changeUPM(self, targetUPM):
# Calculate scaling factor between old and new UPM
upmOld = self.font["head"].unitsPerEm
upmNew = int(targetUPM)
isCubic = self.font.has_key("CFF ")
if upmOld == upmNew:
return
elif upmNew < 16 or upmNew > 16384:
print("WARNING: Invalid UPM value. --UPM is now ignored.", file = sys.stderr)
return
elif self.font.has_key("CFF "):
elif isCubic:
print("WARNING: CFF-based font detected. Unfortunately it is currently not supported.", file = sys.stderr)
return
elif upmNew > 5000:
Expand All @@ -123,11 +124,23 @@ def changeUPM(self, targetUPM):
glyphSet = self.font.getGlyphSet()
for glyphName in glyphSet.keys():
glyph = glyphSet[glyphName]
ttPen = TTGlyphPen(glyphSet)
scalePen = TransformPen(ttPen, Scale(scaleFactor, scaleFactor))
glyph.draw(scalePen)
if isCubic: # TODO: `CFF `
# basePen = OTGlyphPen(glyphSet)
pass
else: # `glyf`
basePen = TTGlyphPen(glyphSet)
scalePen = TransformPen(basePen, Scale(scaleFactor, scaleFactor))
# Deal with quad composites (all cubics are not affected)
if not isCubic and glyph._glyph.isComposite(): # Scale each component's xy offset
glyph.draw(basePen)
for i in range(len(basePen.components)):
componentName, oldTrans = basePen.components[i]
newTrans = (oldTrans[0], oldTrans[1], oldTrans[2], oldTrans[3], oldTrans[4] * scaleFactor, oldTrans[5] * scaleFactor)
basePen.components[i] = (componentName, newTrans)
else: # Scale all cubics or base quads so that their composites will not be scaled multiple times
glyph.draw(scalePen)
# Glyph-specific hinting will be removed upon TTGlyphPen.glyph() call.
scaledGlyphs[glyphName] = ttPen.glyph()
scaledGlyphs[glyphName] = basePen.glyph()

# Apply `glyf` table with scaled glyphs
glyf = newTable("glyf")
Expand Down
2 changes: 1 addition & 1 deletion Package/otRebuilder/otrebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


usageStr = "usage: otrebuild [options] <inputFont>"
descriptionStr = """ OpenType Font Rebuilder: Version 1.5.5, powered by fontTools
descriptionStr = """ OpenType Font Rebuilder: Version 1.5.6, powered by fontTools
This is a simple tool to resolve naming, styling and mapping issues
among OpenType fonts. Without any options given, it can scan and
Expand Down
4 changes: 2 additions & 2 deletions Package/otrebuilder.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Metadata-Version: 1.1
Name: otrebuilder
Version: 1.5.5
Summary: A simple tool to resolve OpenType fonts' mapping and naming issues, powered by fontTools.
Version: 1.5.6
Summary: A simple tool for OpenType standardization with multi-language support, powered by fontTools.
Home-page: https://github.com/Pal3love/otRebuilder
Author: Pal3love
Author-email: [email protected]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

setup(
name = "otrebuilder",
version = "1.5.5",
description = "A simple tool to resolve OpenType fonts' mapping and naming issues, powered by fontTools.",
version = "1.5.6",
description = "A simple tool for OpenType standardization with multi-language support, powered by fontTools.",
author = "Pal3love",
author_email = "[email protected]",
maintainer = "Pal3love",
Expand Down

0 comments on commit ca28bfd

Please sign in to comment.