[_g_l_y_f] replace print and warnings with logger
This commit is contained in:
parent
ff853c38b8
commit
dff078ed51
@ -13,7 +13,10 @@ from . import ttProgram
|
|||||||
import sys
|
import sys
|
||||||
import struct
|
import struct
|
||||||
import array
|
import array
|
||||||
import warnings
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
#
|
#
|
||||||
# The Apple and MS rasterizers behave differently for
|
# The Apple and MS rasterizers behave differently for
|
||||||
@ -56,10 +59,11 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
|||||||
self.glyphs[glyphName] = glyph
|
self.glyphs[glyphName] = glyph
|
||||||
last = next
|
last = next
|
||||||
if len(data) - next >= 4:
|
if len(data) - next >= 4:
|
||||||
warnings.warn("too much 'glyf' table data: expected %d, received %d bytes" %
|
log.warning(
|
||||||
(next, len(data)))
|
"too much 'glyf' table data: expected %d, received %d bytes",
|
||||||
|
next, len(data))
|
||||||
if noname:
|
if noname:
|
||||||
warnings.warn('%s glyphs have no name' % noname)
|
log.warning('%s glyphs have no name', noname)
|
||||||
if ttFont.lazy is False: # Be lazy for None and True
|
if ttFont.lazy is False: # Be lazy for None and True
|
||||||
for glyph in self.glyphs.values():
|
for glyph in self.glyphs.values():
|
||||||
glyph.expand(self)
|
glyph.expand(self)
|
||||||
@ -145,8 +149,7 @@ class table__g_l_y_f(DefaultTable.DefaultTable):
|
|||||||
if not hasattr(self, "glyphOrder"):
|
if not hasattr(self, "glyphOrder"):
|
||||||
self.glyphOrder = ttFont.getGlyphOrder()
|
self.glyphOrder = ttFont.getGlyphOrder()
|
||||||
glyphName = attrs["name"]
|
glyphName = attrs["name"]
|
||||||
if ttFont.verbose:
|
log.debug("unpacking glyph '%s'", glyphName)
|
||||||
ttLib.debugmsg("unpacking glyph '%s'" % glyphName)
|
|
||||||
glyph = Glyph()
|
glyph = Glyph()
|
||||||
for attr in ['xMin', 'yMin', 'xMax', 'yMax']:
|
for attr in ['xMin', 'yMin', 'xMax', 'yMax']:
|
||||||
setattr(glyph, attr, safeEval(attrs.get(attr, '0')))
|
setattr(glyph, attr, safeEval(attrs.get(attr, '0')))
|
||||||
@ -453,7 +456,9 @@ class Glyph(object):
|
|||||||
self.program.fromBytecode(data[:numInstructions])
|
self.program.fromBytecode(data[:numInstructions])
|
||||||
data = data[numInstructions:]
|
data = data[numInstructions:]
|
||||||
if len(data) >= 4:
|
if len(data) >= 4:
|
||||||
warnings.warn("too much glyph data at the end of composite glyph: %d excess bytes" % len(data))
|
log.warning(
|
||||||
|
"too much glyph data at the end of composite glyph: %d excess bytes",
|
||||||
|
len(data))
|
||||||
|
|
||||||
def decompileCoordinates(self, data):
|
def decompileCoordinates(self, data):
|
||||||
endPtsOfContours = array.array("h")
|
endPtsOfContours = array.array("h")
|
||||||
@ -545,7 +550,8 @@ class Glyph(object):
|
|||||||
xDataLen = struct.calcsize(xFormat)
|
xDataLen = struct.calcsize(xFormat)
|
||||||
yDataLen = struct.calcsize(yFormat)
|
yDataLen = struct.calcsize(yFormat)
|
||||||
if len(data) - (xDataLen + yDataLen) >= 4:
|
if len(data) - (xDataLen + yDataLen) >= 4:
|
||||||
warnings.warn("too much glyph data: %d excess bytes" % (len(data) - (xDataLen + yDataLen)))
|
log.warning(
|
||||||
|
"too much glyph data: %d excess bytes", len(data) - (xDataLen + yDataLen))
|
||||||
xCoordinates = struct.unpack(xFormat, data[:xDataLen])
|
xCoordinates = struct.unpack(xFormat, data[:xDataLen])
|
||||||
yCoordinates = struct.unpack(yFormat, data[xDataLen:xDataLen+yDataLen])
|
yCoordinates = struct.unpack(yFormat, data[xDataLen:xDataLen+yDataLen])
|
||||||
return flags, xCoordinates, yCoordinates
|
return flags, xCoordinates, yCoordinates
|
||||||
@ -734,7 +740,7 @@ class Glyph(object):
|
|||||||
bbox = calcBounds([coords[last], coords[next]])
|
bbox = calcBounds([coords[last], coords[next]])
|
||||||
if not pointInRect(coords[j], bbox):
|
if not pointInRect(coords[j], bbox):
|
||||||
# Ouch!
|
# Ouch!
|
||||||
warnings.warn("Outline has curve with implicit extrema.")
|
log.warning("Outline has curve with implicit extrema.")
|
||||||
# Ouch! Find analytical curve bounds.
|
# Ouch! Find analytical curve bounds.
|
||||||
pthis = coords[j]
|
pthis = coords[j]
|
||||||
plast = coords[last]
|
plast = coords[last]
|
||||||
@ -1005,7 +1011,6 @@ class GlyphComponent(object):
|
|||||||
self.flags = int(flags)
|
self.flags = int(flags)
|
||||||
glyphID = int(glyphID)
|
glyphID = int(glyphID)
|
||||||
self.glyphName = glyfTable.getGlyphName(int(glyphID))
|
self.glyphName = glyfTable.getGlyphName(int(glyphID))
|
||||||
#print ">>", reprflag(self.flags)
|
|
||||||
data = data[4:]
|
data = data[4:]
|
||||||
|
|
||||||
if self.flags & ARG_1_AND_2_ARE_WORDS:
|
if self.flags & ARG_1_AND_2_ARE_WORDS:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user