Skip to content

Mark feature in Static fonts isn't able to be built as variable font #440

Description

@benkiel

Problem description
The feature code for the mark, mkmk, gdef feature for the static fonts causes fontmake to not be able to build the variable font. Error is VarLibMergeError: ((2, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), 'int', '.LookupCount', 'Feature', '.Feature', 'FeatureRecord', '[0]', 'list', '.FeatureRecord', 'FeatureList', '.FeatureList', 'GPOS', '.table', 'table_G_P_O_S_').

Currently, the mark, mkmk, and gdef features are being built by fontmake for the var font.

Expected behavior
The same OT code can work for both fonts.

To Reproduce
Steps to reproduce the behavior:

To build_variable.py add:

from fontParts.fontshell import RFont as Font to the head of the file

Change line 7 to from utils import getFiles, make_mark_mkmk_gdef_feature

and then add these lines after line 21 (the end of the buildFeatures function)

    for ufo in ufos:
        font = Font(ufo)
        mark_mkmk_gdef = make_mark_mkmk_gdef_feature(font)
        font.features.text += mark_mkmk_gdef
        font.save(font.path)
    print("🏗  Added mark, mkmk, and GDEF to features")

Then run the variable fonts build.

Environment (please complete the following information):
Standard build environment.

Additional context
To pick this apart, the UFOs that are used for the variable fonts should be built with the static OT code (see above to reproduce). Those UFOs should be built with fontmake as TTFs, and then the GPOS tables compared to see where the difference is, along with an examination of the OT code for what might be triggering the issue. So far the OT code seems as though it should be making the same number of lookups in all fonts, but more investigation is needed.

Activity

  1. arrowtype commented on Mar 1, 2021

    @arrowtype
    Owner

    Thanks for taking the time to note these details, Ben!

  2. added a commit that references this issue on Mar 2, 2021
    948937a
  3. benkiel commented on Mar 3, 2021

    @benkiel
    CollaboratorAuthor

    Update on this. The issue seems to be with adding in the mark and base classes to the gdef table. If the code does not do that, the variable font builds just fine, with the mark and base gdef classes as built by fontmake/ufo2ft.

    I have changed the code to use the ufo2ft mark feature builder for both the variable font and the static fonts however. That writer does generate warnings in makeotf about glyphs. (Example: Glyph 'Z' does not have an anchor point for a mark class that was used in a previous statement in the same lookup table. Setting the anchor point offset to 0.) I don't love that warning, but it does match what the variable font has for feature code. If later there are errors, one could go back to the feature code generator I wrote and use it.

    The variable font code does not write out the gdef classes, but does write the ligature carets. fontmake/ufo2ft will not write the mark and base classes if there is a class defined (the ligature class), so one can't write that one glyph class and have the rest fill in. This is the only difference now between the variable font and static fonts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions