Skip to content

Commit

Permalink
Merge pull request #840 from justvanrossum/better-sparse-masters
Browse files Browse the repository at this point in the history
[variable features] [mark fea writer] Instead of skipping a glyph altogether, only skip missing source layers
  • Loading branch information
anthrotype authored May 17, 2024
2 parents b6d88c7 + d4ed2f0 commit bb3b2cf
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lib/ufo2ft/featureWriters/baseFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def _getAnchor(self, glyphName, anchorName, anchor=None):
found = False
for source in designspace.sources:
if glyphName not in source.font:
return None
continue
glyph = source.font[glyphName]
for anchor in glyph.anchors:
if anchor.name == anchorName:
Expand Down
10 changes: 10 additions & 0 deletions tests/data/TestVarfea-Regular.ufo/fontinfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<integer>-400</integer>
<key>familyName</key>
<string>TestVarfea</string>
<key>guidelines</key>
<array/>
<key>italicAngle</key>
<integer>0</integer>
<key>openTypeHeadCreated</key>
Expand All @@ -25,11 +27,19 @@
<integer>600</integer>
<integer>616</integer>
</array>
<key>postscriptFamilyBlues</key>
<array/>
<key>postscriptFamilyOtherBlues</key>
<array/>
<key>postscriptOtherBlues</key>
<array>
<integer>-416</integer>
<integer>-400</integer>
</array>
<key>postscriptStemSnapH</key>
<array/>
<key>postscriptStemSnapV</key>
<array/>
<key>postscriptUnderlinePosition</key>
<integer>-100</integer>
<key>postscriptUnderlineThickness</key>
Expand Down
14 changes: 14 additions & 0 deletions tests/data/TestVarfea-Regular.ufo/glyphs/a.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="a" format="2">
<advance width="500"/>
<unicode hex="0061"/>
<anchor x="250" y="400" name="top"/>
<outline>
</outline>
<lib>
<dict>
<key>public.markColor</key>
<string>0.5955,0.7484,1,1</string>
</dict>
</lib>
</glyph>
4 changes: 4 additions & 0 deletions tests/data/TestVarfea-Regular.ufo/glyphs/contents.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>a</key>
<string>a.glif</string>
<key>alef-ar.fina</key>
<string>alef-ar.fina.glif</string>
<key>dotabove-ar</key>
<string>dotabove-ar.glif</string>
<key>gravecmb</key>
<string>gravecmb.glif</string>
<key>peh-ar.init</key>
<string>peh-ar.init.glif</string>
<key>peh-ar.init.BRACKET.varAlt01</key>
Expand Down
14 changes: 14 additions & 0 deletions tests/data/TestVarfea-Regular.ufo/glyphs/gravecmb.glif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="gravecmb" format="2">
<advance width="500"/>
<unicode hex="0300"/>
<anchor x="250" y="400" name="_top"/>
<outline>
</outline>
<lib>
<dict>
<key>public.markColor</key>
<string>0.5955,0.7484,1,1</string>
</dict>
</lib>
</glyph>
2 changes: 2 additions & 0 deletions tests/data/TestVarfea-Regular.ufo/glyphs/layerinfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>color</key>
<string>0.5,0,0.5,0.7</string>
<key>lib</key>
<dict>
<key>com.schriftgestaltung.layerId</key>
Expand Down
3 changes: 3 additions & 0 deletions tests/data/TestVarfea-Regular.ufo/lib.plist
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<string>peh-ar.init</string>
<string>space</string>
<string>dotabove-ar</string>
<string>peh-ar.init.BRACKET.varAlt01</string>
<string>a</string>
<string>gravecmb</string>
</array>
<key>public.postscriptNames</key>
<dict>
Expand Down
7 changes: 5 additions & 2 deletions tests/featureWriters/variableFeatureWriter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def test_variable_features(FontClass):
assert dedent("\n" + tmp.getvalue()) == dedent(
"""
markClass dotabove-ar <anchor (wght=100:100 wght=1000:125) (wght=100:320 wght=1000:416)> @MC_top;
markClass gravecmb <anchor 250 400> @MC_top;
lookup kern_Arab {
lookupflag IgnoreMarks;
Expand All @@ -37,6 +38,8 @@ def test_variable_features(FontClass):
lookup mark2base {
pos base alef-ar.fina
<anchor (wght=100:211 wght=1000:214) (wght=100:730 wght=1000:797)> mark @MC_top;
pos base a
<anchor 250 400> mark @MC_top;
} mark2base;
} mark;
Expand All @@ -46,12 +49,12 @@ def test_variable_features(FontClass):
} GDEF;
feature curs {
lookup curs {
lookup curs_rtl {
lookupflag RightToLeft IgnoreMarks;
pos cursive alef-ar.fina <anchor (wght=100:299 wght=1000:330) (wght=100:97 wght=1000:115)> <anchor NULL>;
pos cursive peh-ar.init <anchor NULL> <anchor (wght=100:161 wght=1000:73) (wght=100:54 wght=1000:89)>;
pos cursive peh-ar.init.BRACKET.varAlt01 <anchor NULL> <anchor (wght=100:89 wght=1000:73) (wght=100:53 wght=1000:85)>;
} curs;
} curs_rtl;
} curs;
""" # noqa: B950
Expand Down

0 comments on commit bb3b2cf

Please sign in to comment.