Skip to content

CFF specializer error with fontmake variable-cff2 output #3839

@justvanrossum

Description

@justvanrossum

I have a font that has a glyph with a stray point that gives an error within the CFF specializer.

This happens only when outputting with -o variable-cff2, not with -o variable.

The glyph contains one "normal" shape (a line and a curve) and a stray (single, loose) point.

If I remove the stray point the compile works. But if I delete the other shape, the compile also works, so the problem is not just with the stray point.

It seems to have to do with the exact coordinates of the shape: I have tried to draw a shape with the same topology (but different coordinates), but failed to reproduce the problem.

Now, of course the source data is buggy, but it's at least odd that this only fails for cff2 output.

I have attached a zip with a .designspace file and two UFOs, each containing a single glyph.

Traceback (most recent call last):
  File "xxx/venv/lib/python3.12/site-packages/fontmake/font_project.py", line 1208, in run_from_designspace
    self._run_from_designspace_interpolatable(
  File "xxx/venv/lib/python3.12/site-packages/fontmake/font_project.py", line 1326, in _run_from_designspace_interpolatable
    self.build_variable_fonts(
  File "xxx/venv/lib/python3.12/site-packages/fontmake/font_project.py", line 470, in build_variable_fonts
    fonts = ufo2ft.compileVariableCFF2s(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/ufo2ft/__init__.py", line 295, in compileVariableCFF2s
    return VariableCFF2sCompiler(**kwargs).compile_variable(designSpaceDoc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/ufo2ft/_compilers/baseCompiler.py", line 420, in compile_variable
    vfNameToTTFont = self._merge(designSpaceDoc, excludeVariationTables)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/ufo2ft/_compilers/interpolatableOTFCompiler.py", line 32, in _merge
    return varLib.build_many(
           ^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/fontTools/varLib/__init__.py", line 1141, in build_many
    vf = build(
         ^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/fontTools/varLib/__init__.py", line 1241, in build
    _add_CFF2(vf, model, master_fonts)
  File "xxx/venv/lib/python3.12/site-packages/fontTools/varLib/__init__.py", line 869, in _add_CFF2
    merge_region_fonts(varFont, model, ordered_fonts_list, glyphOrder)
  File "xxx/venv/lib/python3.12/site-packages/fontTools/varLib/cff.py", line 266, in merge_region_fonts
    cvData = merge_charstrings(glyphOrder, num_masters, top_dicts, model)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/fontTools/varLib/cff.py", line 338, in merge_charstrings
    new_cs = var_pen.getCharString(
             ^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/fontTools/varLib/cff.py", line 624, in getCharString
    commands = specializeCommands(
               ^^^^^^^^^^^^^^^^^^^
  File "xxx/venv/lib/python3.12/site-packages/fontTools/cffLib/specializer.py", line 583, in specializeCommands
    commands[i - 1] = ("rmoveto", [v1[0] + v2[0], v1[1] + v2[1]])
                                                  ~~~~~~^~~~~~~
TypeError: can only concatenate list (not "int") to list

specializer-bug.zip

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions