[otBase] Try ExtensionLookup if other offset-overflow methods fail

If offset overflow happens other than between Lookup and SubTable, or
within SubTable, then we don't know how to fix it currently.  Now we
try to put that lookup in an Extension lookup anyway, since that will
isolate it and sharing with other lookups won't happen, hopefully
avoiding the overflow.

This is really a bandaid... What we want is the 99proof branch to
be finished and replace our current packing algorithm.

Fixes https://github.com/fonttools/fonttools/issues/1296
This commit is contained in:
Behdad Esfahbod 2018-07-25 11:04:48 -07:00
parent 642cb03296
commit 05f95f0f58
2 changed files with 12 additions and 5 deletions

View File

@ -86,6 +86,12 @@ class BaseTTXConverter(DefaultTable):
else:
from .otTables import fixSubTableOverFlows
ok = fixSubTableOverFlows(font, overflowRecord)
if not ok:
# Try upgrading lookup to Extension and hope
# that cross-lookup sharing not happening would
# fix overflow...
from .otTables import fixLookupOverFlows
ok = fixLookupOverFlows(font, overflowRecord)
if not ok:
raise

View File

@ -1370,7 +1370,6 @@ def fixSubTableOverFlows(ttf, overflowRecord):
"""
An offset has overflowed within a sub-table. We need to divide this subtable into smaller parts.
"""
ok = 0
table = ttf[overflowRecord.tableType].table
lookup = table.LookupList.Lookup[overflowRecord.LookupListIndex]
subIndex = overflowRecord.SubTableIndex
@ -1391,7 +1390,7 @@ def fixSubTableOverFlows(ttf, overflowRecord):
newExtSubTableClass = lookupTypes[overflowRecord.tableType][extSubTable.__class__.LookupType]
newExtSubTable = newExtSubTableClass()
newExtSubTable.Format = extSubTable.Format
lookup.SubTable.insert(subIndex + 1, newExtSubTable)
toInsert = newExtSubTable
newSubTableClass = lookupTypes[overflowRecord.tableType][subTableType]
newSubTable = newSubTableClass()
@ -1400,7 +1399,7 @@ def fixSubTableOverFlows(ttf, overflowRecord):
subTableType = subtable.__class__.LookupType
newSubTableClass = lookupTypes[overflowRecord.tableType][subTableType]
newSubTable = newSubTableClass()
lookup.SubTable.insert(subIndex + 1, newSubTable)
toInsert = newSubTable
if hasattr(lookup, 'SubTableCount'): # may not be defined yet.
lookup.SubTableCount = lookup.SubTableCount + 1
@ -1413,9 +1412,11 @@ def fixSubTableOverFlows(ttf, overflowRecord):
overflowRecord.tableType,
subTableType,
)
return ok
return False
ok = splitFunc(subtable, newSubTable, overflowRecord)
if ok:
lookup.SubTable.insert(subIndex + 1, toInsert)
return ok
# End of OverFlow logic