+
Skip to content

Fixes to voltLib and VoltToFea #3818

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

Merged
merged 22 commits into from
May 6, 2025
Merged

Fixes to voltLib and VoltToFea #3818

merged 22 commits into from
May 6, 2025

Conversation

khaledhosny
Copy link
Collaborator

This PR add some missing functionality and fixes to voltLib and VoltToFea, making the conversion to feature files more robust. Together with the recent feaLib changes, this allowed me to compile a large corpus of VOLT sources (which I can not share). The PR also adds a script that uses voltLib and feaLib to compile VOLT sources directly (doing an intermediate fea conversion internally) to be used as fonttools voltLib from command line.

@khaledhosny
Copy link
Collaborator Author

Python 3.8 does not have graphlib module, I tried adding graphlib-backport==1.1.0; python_version <= '3.8' to requirements.txt, but we run the tests once with requirements and once without, so that one is failing on 3.8.

Suggestions are welcome. 3.8 is EOL’d already, if dropping support for it is an option.

khaledhosny added 22 commits May 6, 2025 12:01
Swap the actual and expected strings in self.assertEqual() calls so that
the diffs are shown correctly.
See inline comments and the example in the test.
This seems to be what VOLT does.
If any of the input glyphs is a glyph class, we need to explode it into
multiple statements since feature file syntax does not support classes
in ligature substitutions.
VOLT ranges are GID-based, while feature files ranges are glyph
names-based, so the two are not compatible and we should expand VOLT
ranges.
Since we need to map VOLT glyph names to font glyph names and groups
reference glyphs.
If only some of the glyphs are ligatures or marks, then VOLT makes it a
mark to base lookup and uses the anchor of the first ligature component
(in case of ligatures).
In VOLT group definitions can be ordered in any order, but in FEA a
group must be defined before being referenced in another group. We had
some code to sort the groups to fix this, but it was broken in several
ways. We now use the more appropriate TopologicalSorter(), and nested
enums when getting what groups a group references.
Without this fix we would output invalid fea code like:

    pos [[a b] [c d] [e f g h i j k l] [m n o p q]]' lookup lookup_target space;
Rename variables to be less cryptic.
In FEA syntax aalt is not allowed to have script or language statements,
but in OpenType and VOLT it is a regular feature like any other. We now
emit a warning and use only lookups from first script and language.
No functional change. Prepares for next commit.
Using inline syntax results in very inefficient lookups, with each
statement going into a subtable. Some fonts get too big lookups and even
fail to compile. Using explicit lookup blocks for the chained lookups
fixes most of such undesired subtable breaks.
VOLT might skip the padding spaces, but feaLib.ast will assert if not
equal to 4.
VOLT ignores it unless it is a single substitution lookup, so we now do
the same instead of raising.
Add __main__.py CLI that takes a MS VOLT project and compiles it to
font tables. Layout tables are currently converted first to feature
files and compiled with feaLib. Support for other tables (e.g. cmap)
will be added later.

At some point direct compilation of layout tables (without converting to
feature files first) might be added.
@khaledhosny
Copy link
Collaborator Author

Python 3.8 does not have graphlib module, I tried adding graphlib-backport==1.1.0; python_version <= '3.8' to requirements.txt, but we run the tests once with requirements and once without, so that one is failing on 3.8.

Suggestions are welcome. 3.8 is EOL’d already, if dropping support for it is an option.

Python 3.8 support was dropped in #3819, so this is fixed now.

Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks Khaled

@khaledhosny khaledhosny merged commit 627e7e7 into main May 6, 2025
11 checks passed
@khaledhosny khaledhosny deleted the voltlib-build branch May 6, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载