Skip to content

Commit d665837

Browse files
authored
Merge pull request #948 from googlefonts/fix-order-dependent-anchor-prop
Fix order-dependent anchor propagation in PropagateAnchorsIFilter
2 parents d440b5e + 90a3a5f commit d665837

File tree

15 files changed

+263
-8
lines changed

15 files changed

+263
-8
lines changed

Lib/ufo2ft/filters/propagateAnchors.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ def __call__(self, font, glyphSet=None):
3939
def filter(self, glyph):
4040
if not glyph.components:
4141
return False
42-
before = len(glyph.anchors)
4342
_propagate_glyph_anchors(
4443
self.context.glyphSet,
4544
glyph,
4645
self.context.processed,
4746
self.context.modified,
4847
self.context.categories,
4948
)
50-
return len(glyph.anchors) > before
49+
return glyph.name in self.context.modified
5150

5251

5352
class PropagateAnchorsIFilter(BaseIFilter):
@@ -67,7 +66,6 @@ def filter(self, glyphName, glyphs):
6766
modified = False
6867
if not any(glyph.components for glyph in glyphs):
6968
return modified
70-
before = len(self.context.modified)
7169
for i, (glyphSet, interpolatedLayer) in enumerate(
7270
zip_strict(self.context.glyphSets, self.getInterpolatedLayers())
7371
):
@@ -80,7 +78,7 @@ def filter(self, glyphName, glyphs):
8078
self.context.modified,
8179
self.context.categories,
8280
)
83-
return len(self.context.modified) > before
81+
return glyphName in self.context.modified
8482

8583

8684
def _propagate_glyph_anchors(glyphSet, composite, processed, modified, categories):
@@ -110,8 +108,9 @@ def _propagate_glyph_anchors(glyphSet, composite, processed, modified, categorie
110108
glyph = glyphSet[component.baseGlyph]
111109
except KeyError:
112110
logger.warning(
113-
"Anchors not propagated for inexistent component {} "
114-
"in glyph {}".format(component.baseGlyph, composite.name)
111+
"Anchors not propagated for inexistent component {} in glyph {}".format(
112+
component.baseGlyph, composite.name
113+
)
115114
)
116115
else:
117116
_propagate_glyph_anchors(glyphSet, glyph, processed, modified, categories)

Lib/ufo2ft/instantiator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,10 @@ def __len__(self) -> int:
12441244

12451245
def __getitem__(self, glyph_name: str) -> Glyph:
12461246
try:
1247+
src_glyph = self._get(glyph_name)
12471248
return self._cache.setdefault(
1248-
glyph_name, self._get(glyph_name) or self._interpolate(glyph_name)
1249+
glyph_name,
1250+
src_glyph if src_glyph is not None else self._interpolate(glyph_name),
12491251
)
12501252
except InstantiatorError as e:
12511253
raise KeyError(glyph_name) from e
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<designspace format="4.1">
3+
<axes>
4+
<axis tag="wght" name="Weight" minimum="400" maximum="700" default="400"/>
5+
</axes>
6+
<sources>
7+
<source filename="PropagateAnchorsIFilterTest.ufo" familyname="Acme Sans" stylename="Bold">
8+
<location>
9+
<dimension name="Weight" xvalue="700"/>
10+
</location>
11+
</source>
12+
<source filename="PropagateAnchorsIFilterTest.ufo" familyname="Acme Sans" stylename="Regular">
13+
<location>
14+
<dimension name="Weight" xvalue="400"/>
15+
</location>
16+
</source>
17+
</sources>
18+
</designspace>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="A-cy" format="2">
3+
<advance width="0"/>
4+
<anchor x="335" y="716" name="top"/>
5+
<outline>
6+
<component base="A"/>
7+
</outline>
8+
</glyph>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="A" format="2">
3+
<advance width="0"/>
4+
<anchor x="335" y="0" name="bottom"/>
5+
<anchor x="655" y="0" name="ogonek"/>
6+
<anchor x="335" y="716" name="top"/>
7+
<outline>
8+
<contour>
9+
<point x="9" y="716" type="line"/>
10+
<point x="9" y="0" type="line"/>
11+
<point x="673" y="0" type="line"/>
12+
<point x="673" y="716" type="line"/>
13+
</contour>
14+
</outline>
15+
</glyph>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="Abreve-cy" format="2">
3+
<advance width="0"/>
4+
<outline>
5+
<component base="A-cy"/>
6+
<component base="brevecomb.cap" xOffset="133"/>
7+
</outline>
8+
</glyph>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="Adieresis-cy" format="2">
3+
<advance width="0"/>
4+
<outline>
5+
<component base="A-cy"/>
6+
<component base="dieresiscomb.cap" xOffset="139"/>
7+
</outline>
8+
</glyph>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="brevecomb.cap" format="2">
3+
<advance width="0"/>
4+
<anchor x="202" y="716" name="_top"/>
5+
<outline>
6+
<component base="brevecomb" yOffset="189"/>
7+
</outline>
8+
</glyph>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="brevecomb" format="2">
3+
<advance width="0"/>
4+
<anchor x="200" y="510" name="_top"/>
5+
<outline>
6+
<contour>
7+
<point x="48" y="730" type="line"/>
8+
<point x="138" y="730" type="line"/>
9+
<point x="156" y="678" type="line"/>
10+
<point x="196" y="667" type="line"/>
11+
<point x="244" y="675" type="line"/>
12+
<point x="261" y="698" type="line"/>
13+
<point x="266" y="732" type="line"/>
14+
<point x="354" y="726" type="line"/>
15+
<point x="363" y="677" type="line"/>
16+
<point x="318" y="607" type="line"/>
17+
<point x="300" y="595"/>
18+
<point x="285" y="575"/>
19+
<point x="264" y="572" type="curve"/>
20+
<point x="197" y="567" type="line"/>
21+
<point x="182" y="568"/>
22+
<point x="157" y="570"/>
23+
<point x="153" y="571" type="curve"/>
24+
<point x="84" y="592" type="line"/>
25+
<point x="67" y="620" type="line"/>
26+
<point x="39" y="669" type="line"/>
27+
<point x="38" y="715" type="line"/>
28+
<point x="45" y="732" type="line"/>
29+
</contour>
30+
</outline>
31+
</glyph>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>A</key>
6+
<string>A_.glif</string>
7+
<key>A-cy</key>
8+
<string>A_-cy.glif</string>
9+
<key>Abreve-cy</key>
10+
<string>A_breve-cy.glif</string>
11+
<key>Adieresis-cy</key>
12+
<string>A_dieresis-cy.glif</string>
13+
<key>brevecomb</key>
14+
<string>brevecomb.glif</string>
15+
<key>brevecomb.cap</key>
16+
<string>brevecomb.cap.glif</string>
17+
<key>dieresiscomb</key>
18+
<string>dieresiscomb.glif</string>
19+
<key>dieresiscomb.cap</key>
20+
<string>dieresiscomb.cap.glif</string>
21+
</dict>
22+
</plist>

0 commit comments

Comments
 (0)