[hhea,vhea] Use float('inf') instead of INFINITY

This commit is contained in:
Masaya Nakamura 2017-05-19 14:10:26 +09:00
parent b22b59f730
commit d1bc55756f
2 changed files with 8 additions and 10 deletions

View File

@ -47,11 +47,10 @@ class table__h_h_e_a(DefaultTable.DefaultTable):
hmtxTable = ttFont['hmtx'] hmtxTable = ttFont['hmtx']
if 'glyf' in ttFont: if 'glyf' in ttFont:
glyfTable = ttFont['glyf'] glyfTable = ttFont['glyf']
INFINITY = 100000
advanceWidthMax = 0 advanceWidthMax = 0
minLeftSideBearing = +INFINITY # arbitrary big number minLeftSideBearing = float('inf')
minRightSideBearing = +INFINITY # arbitrary big number minRightSideBearing = float('inf')
xMaxExtent = -INFINITY # arbitrary big negative number xMaxExtent = -float('inf')
for name in ttFont.getGlyphOrder(): for name in ttFont.getGlyphOrder():
width, lsb = hmtxTable[name] width, lsb = hmtxTable[name]
@ -69,7 +68,7 @@ class table__h_h_e_a(DefaultTable.DefaultTable):
extent = lsb + (g.xMax - g.xMin) extent = lsb + (g.xMax - g.xMin)
xMaxExtent = max(xMaxExtent, extent) xMaxExtent = max(xMaxExtent, extent)
if xMaxExtent == -INFINITY: if xMaxExtent == -float('inf'):
# No glyph has outlines. # No glyph has outlines.
minLeftSideBearing = 0 minLeftSideBearing = 0
minRightSideBearing = 0 minRightSideBearing = 0

View File

@ -46,11 +46,10 @@ class table__v_h_e_a(DefaultTable.DefaultTable):
vtmxTable = ttFont['vmtx'] vtmxTable = ttFont['vmtx']
if 'glyf' in ttFont: if 'glyf' in ttFont:
glyfTable = ttFont['glyf'] glyfTable = ttFont['glyf']
INFINITY = 100000
advanceHeightMax = 0 advanceHeightMax = 0
minTopSideBearing = +INFINITY # arbitrary big number minTopSideBearing = float('inf')
minBottomSideBearing = +INFINITY # arbitrary big number minBottomSideBearing = float('inf')
yMaxExtent = -INFINITY # arbitrary big negative number yMaxExtent = -float('inf')
for name in ttFont.getGlyphOrder(): for name in ttFont.getGlyphOrder():
height, tsb = vtmxTable[name] height, tsb = vtmxTable[name]
@ -68,7 +67,7 @@ class table__v_h_e_a(DefaultTable.DefaultTable):
extent = tsb + (g.yMax - g.yMin) extent = tsb + (g.yMax - g.yMin)
yMaxExtent = max(yMaxExtent, extent) yMaxExtent = max(yMaxExtent, extent)
if yMaxExtent == -INFINITY: if yMaxExtent == -float('inf'):
# No glyph has outlines. # No glyph has outlines.
minTopSideBearing = 0 minTopSideBearing = 0
minBottomSideBearing = 0 minBottomSideBearing = 0