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

View File

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