[Snippets] Handle post table overflow in otf2ttf.py
Fixes https://github.com/fonttools/fonttools/issues/1329
This commit is contained in:
parent
c9f79af8ce
commit
5ad27dfb40
@ -43,6 +43,7 @@ def otf_to_ttf(ttFont, post_format=POST_FORMAT, **kwargs):
|
|||||||
glyf.glyphOrder = glyphOrder
|
glyf.glyphOrder = glyphOrder
|
||||||
glyf.glyphs = glyphs_to_quadratic(ttFont.getGlyphSet(), **kwargs)
|
glyf.glyphs = glyphs_to_quadratic(ttFont.getGlyphSet(), **kwargs)
|
||||||
del ttFont["CFF "]
|
del ttFont["CFF "]
|
||||||
|
glyf.compile(ttFont)
|
||||||
|
|
||||||
ttFont["maxp"] = maxp = newTable("maxp")
|
ttFont["maxp"] = maxp = newTable("maxp")
|
||||||
maxp.tableVersion = 0x00010000
|
maxp.tableVersion = 0x00010000
|
||||||
@ -56,12 +57,19 @@ def otf_to_ttf(ttFont, post_format=POST_FORMAT, **kwargs):
|
|||||||
maxp.maxComponentElements = max(
|
maxp.maxComponentElements = max(
|
||||||
len(g.components if hasattr(g, 'components') else [])
|
len(g.components if hasattr(g, 'components') else [])
|
||||||
for g in glyf.glyphs.values())
|
for g in glyf.glyphs.values())
|
||||||
|
maxp.compile(ttFont)
|
||||||
|
|
||||||
post = ttFont["post"]
|
post = ttFont["post"]
|
||||||
post.formatType = post_format
|
post.formatType = post_format
|
||||||
post.extraNames = []
|
post.extraNames = []
|
||||||
post.mapping = {}
|
post.mapping = {}
|
||||||
post.glyphOrder = glyphOrder
|
post.glyphOrder = glyphOrder
|
||||||
|
try:
|
||||||
|
post.compile(ttFont)
|
||||||
|
except OverflowError:
|
||||||
|
post.formatType = 3
|
||||||
|
print("Glyph names do not fit in 'post' table format 2, using format 3 instead.")
|
||||||
|
|
||||||
|
|
||||||
ttFont.sfntVersion = "\000\001\000\000"
|
ttFont.sfntVersion = "\000\001\000\000"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user