[ttGlyphPen] add 'decomposeOverflowingTransform' option
if it's false and any transform value overflows, we raise an error instead of decomposing
This commit is contained in:
parent
4377185e29
commit
acb1ebc793
@ -20,8 +20,9 @@ MAX_F2DOT14 = 0x7FFF / (1 << 14)
|
|||||||
class TTGlyphPen(AbstractPen):
|
class TTGlyphPen(AbstractPen):
|
||||||
"""Pen used for drawing to a TrueType glyph."""
|
"""Pen used for drawing to a TrueType glyph."""
|
||||||
|
|
||||||
def __init__(self, glyphSet):
|
def __init__(self, glyphSet, decomposeOverflowingTransform=True):
|
||||||
self.glyphSet = glyphSet
|
self.glyphSet = glyphSet
|
||||||
|
self.decomposeOverflowingTransform = decomposeOverflowingTransform
|
||||||
self.init()
|
self.init()
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
@ -92,6 +93,9 @@ class TTGlyphPen(AbstractPen):
|
|||||||
overflowing = any(s > 2 or s < -2
|
overflowing = any(s > 2 or s < -2
|
||||||
for (glyphName, transformation) in self.components
|
for (glyphName, transformation) in self.components
|
||||||
for s in transformation[:4])
|
for s in transformation[:4])
|
||||||
|
if not self.decomposeOverflowingTransform and overflowing:
|
||||||
|
raise OverflowError("transform value too large to fit F2Dot14; "
|
||||||
|
"valid range is -2.0 <= x <= +2.0")
|
||||||
|
|
||||||
components = []
|
components = []
|
||||||
for glyphName, transformation in self.components:
|
for glyphName, transformation in self.components:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user