Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variable GDEF building #821

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Lib/ufo2ft/featureWriters/gdefFeatureWriter.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from fontTools.feaLib.variableScalar import VariableScalar
from fontTools.misc.fixedTools import otRound

from ufo2ft.featureWriters import BaseFeatureWriter, ast


def caretSortKey(caret):
if isinstance(caret, VariableScalar):
return list(caret.values.values())[0]
return caret


class GdefFeatureWriter(BaseFeatureWriter):
"""Generates a GDEF table based on OpenType Category and glyph anchors.

Expand Down Expand Up @@ -67,9 +74,7 @@ def _getLigatureCarets(self):

if glyphCarets:
if self.context.isVariable:
carets[glyphName] = sorted(
glyphCarets, key=lambda caret: list(caret.values.values())[0]
)
carets[glyphName] = sorted(glyphCarets, key=caretSortKey)
else:
carets[glyphName] = [otRound(c) for c in sorted(glyphCarets)]

Expand Down
Loading