Skip to content

Commit

Permalink
[postProcessor] fontTools.varLib.cff.convertCFFtoCFF2 is deprecated
Browse files Browse the repository at this point in the history
Try importing fontTools.cffLib.CFFToCFF2.convertCFFToCFF2 first, and
confine the width stripping to when the deprecated method is used, as it
is already fixed in FontTools.
  • Loading branch information
khaledhosny committed Oct 16, 2024
1 parent feeb474 commit 85f07a4
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Lib/ufo2ft/postProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,22 @@ def _get_cff_version(otf):

@staticmethod
def _convert_cff_to_cff2(otf):
from fontTools.varLib.cff import convertCFFtoCFF2

logger.info("Converting CFF table to CFF2")

# convertCFFtoCFF2 doesn't strip T2CharStrings' widths, so we do it ourselves
# https://github.com/fonttools/fonttools/issues/1835
charstrings = otf["CFF "].cff[0].CharStrings
for glyph_name in otf.getGlyphOrder():
cs = charstrings[glyph_name]
cs.decompile()
cs.program = _stripCharStringWidth(cs.program)
try:
from fontTools.cffLib.CFFToCFF2 import convertCFFToCFF2
except ImportError:
from fontTools.varLib.cff import convertCFFtoCFF2 as convertCFFToCFF2

# convertCFFtoCFF2 doesn't strip T2CharStrings' widths, so we do it ourselves
# https://github.com/fonttools/fonttools/issues/1835
charstrings = otf["CFF "].cff[0].CharStrings
for glyph_name in otf.getGlyphOrder():
cs = charstrings[glyph_name]
cs.decompile()
cs.program = _stripCharStringWidth(cs.program)

convertCFFtoCFF2(otf)
convertCFFToCFF2(otf)

@classmethod
def _subroutinize(cls, backend, otf, cffVersion):
Expand Down

0 comments on commit 85f07a4

Please sign in to comment.