[merge] desubroutinizing with _DesubroutinizingT2Decompiler
No final compression (may happen after, outside merge)
This commit is contained in:
parent
660a057fb3
commit
4966804d9d
@ -19,9 +19,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import operator
|
import operator
|
||||||
import logging
|
import logging
|
||||||
import compreffor
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger("fontTools.merge")
|
log = logging.getLogger("fontTools.merge")
|
||||||
@ -1009,23 +1007,22 @@ class Merger(object):
|
|||||||
cffTables = []
|
cffTables = []
|
||||||
if allOTFs:
|
if allOTFs:
|
||||||
for font in fonts:
|
for font in fonts:
|
||||||
compreffor.decompress(font)
|
cffTable = font.get('CFF ')
|
||||||
cffTables.append(font.get('CFF '))
|
# Desubroutinize
|
||||||
# cffTables = [font.get('CFF ') for font in fonts]
|
cs = cffTable.cff[0].CharStrings
|
||||||
# desubr_cffTables = []
|
for g in cffTable.cff[0].charset:
|
||||||
# for cff in cffTables:
|
c, _ = cs.getItemAndSelector(g)
|
||||||
# # Desubroutinize
|
c.decompile()
|
||||||
# cs = cff.cff[0].CharStrings
|
subrs = getattr(c.private, "Subrs", [])
|
||||||
# for g in cff.cff[0].charset:
|
decompiler = _DesubroutinizingT2Decompiler(subrs, c.globalSubrs)
|
||||||
# c, _ = cs.getItemAndSelector(g)
|
decompiler.execute(c)
|
||||||
# c.decompile()
|
c.program = c._desubroutinized
|
||||||
# subrs = getattr(c.private, "Subrs", [])
|
|
||||||
# decompiler = _DesubroutinizingT2Decompiler(subrs, c.globalSubrs)
|
|
||||||
# decompiler.execute(c)
|
cffTable.cff[0].Private.Subrs = cffLib.SubrsIndex()
|
||||||
# c.program = c._desubroutinized
|
cffTable.cff.GlobalSubrs = cffLib.GlobalSubrsIndex()
|
||||||
# desubr_cffTables.append(cff)
|
|
||||||
# else:
|
cffTables.append(cffTable)
|
||||||
# desubr_cffTables = []
|
|
||||||
|
|
||||||
glyphOrders = [font.getGlyphOrder() for font in fonts]
|
glyphOrders = [font.getGlyphOrder() for font in fonts]
|
||||||
|
|
||||||
@ -1088,23 +1085,23 @@ class Merger(object):
|
|||||||
self._postMerge(mega)
|
self._postMerge(mega)
|
||||||
|
|
||||||
# Compress CFF table
|
# Compress CFF table
|
||||||
if mega.get('CFF '):
|
# if mega.get('CFF '):
|
||||||
tempFile = tempfile.NamedTemporaryFile(suffix='.otf', delete=False)
|
# tempFile = tempfile.NamedTemporaryFile(suffix='.otf', delete=False)
|
||||||
mega.save(tempFile.name)
|
# mega.save(tempFile.name)
|
||||||
f = ttLib.TTFont(tempFile.name)
|
# f = ttLib.TTFont(tempFile.name)
|
||||||
compreffor.compress(f)
|
# compreffor.compress(f)
|
||||||
mega = f
|
# mega = f
|
||||||
os.remove(tempFile.name)
|
# os.remove(tempFile.name)
|
||||||
log.info("FINAL final global subrs: %s." % len(mega.get('CFF ').cff.GlobalSubrs))
|
# log.info("FINAL final global subrs: %s." % len(mega.get('CFF ').cff.GlobalSubrs))
|
||||||
ls = None
|
# ls = None
|
||||||
try:
|
# try:
|
||||||
ls = mega.get('CFF ').cff[0].Private.Subrs
|
# ls = mega.get('CFF ').cff[0].Private.Subrs
|
||||||
except:
|
# except:
|
||||||
pass
|
# pass
|
||||||
if ls is not None:
|
# if ls is not None:
|
||||||
log.info("FINAL font local subrs: %s." % len(ls))
|
# log.info("FINAL font local subrs: %s." % len(ls))
|
||||||
else:
|
# else:
|
||||||
log.info("FINAL font has no local subrs.")
|
# log.info("FINAL font has no local subrs.")
|
||||||
|
|
||||||
return mega
|
return mega
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user