simoncozens / fontFeatures

Python library for manipulating OpenType font features
BSD 3-Clause "New" or "Revised" License
71 stars 9 forks source link

Redundant features #63

Closed ryanbugden closed 6 months ago

ryanbugden commented 6 months ago

It seems there are often lots of redundancies in the unparsed features. In a roundtrip, they cause compile errors. Could these be consolidated?

Test script:

from fontFeatures.ttLib import unparse
from fontTools.ttLib import TTFont

source = TTFont('SourceSerifPro-Regular.otf')
fea = unparse(source).asFea()
print(fea)
feature ordn {
    script latn;
    language CRT;
            script latn;
        language CRT;
        lookup SingleSubstitution9;

} ordn;

feature ordn {
    script latn;
    language CRT;
            script latn;
        language CRT;
        lookup SingleSubstitution9;

} ordn;

...

feature sinf {
    script DFLT;
    language dflt;
            script DFLT;
        language dflt;
        lookup SingleSubstitution12;

} sinf;

feature sinf {
    script DFLT;
    language dflt;
            script DFLT;
        language dflt;
        lookup SingleSubstitution12;

} sinf;
...