Skip to content

Commit b55aabd

Browse files
authored
Merge pull request #962 from justvanrossum/patch-1
Use MathGlyph's "strict" flag
2 parents 391564f + ee91075 commit b55aabd

19 files changed

+289
-3
lines changed

Lib/fontmake/instantiator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def collect_glyph_masters(
603603
source.location, axis_bounds
604604
)
605605
locations_and_masters.append(
606-
(normalized_location, fontMath.MathGlyph(source_glyph))
606+
(normalized_location, fontMath.MathGlyph(source_glyph, strict=True))
607607
)
608608

609609
# Filter out empty glyphs if the default glyph is not empty.

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cu2qu==1.6.7.post1
44
glyphsLib==6.1.0
55
ufo2ft==2.29.0
66
MutatorMath==3.0.1
7-
fontMath==0.9.2
7+
fontMath==0.9.3
88
defcon[lxml]==0.10.2; platform_python_implementation == 'CPython'
99
defcon==0.10.2; platform_python_implementation != 'CPython'
1010
booleanOperations==0.9.0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"fonttools[ufo,unicode]>=4.38.0 ; implementation_name != 'cpython'",
6060
"glyphsLib>=6.1.0",
6161
"ufo2ft[compreffor]>=2.29.0",
62-
"fontMath>=0.9.1",
62+
"fontMath>=0.9.3",
6363
"ufoLib2>=0.13.0",
6464
"attrs>=19",
6565
],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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>ascender</key>
6+
<integer>750</integer>
7+
<key>capHeight</key>
8+
<integer>750</integer>
9+
<key>descender</key>
10+
<integer>-250</integer>
11+
<key>familyName</key>
12+
<string>Test Ufo</string>
13+
<key>guidelines</key>
14+
<array/>
15+
<key>postscriptBlueValues</key>
16+
<array/>
17+
<key>postscriptFamilyBlues</key>
18+
<array/>
19+
<key>postscriptFamilyOtherBlues</key>
20+
<array/>
21+
<key>postscriptOtherBlues</key>
22+
<array/>
23+
<key>postscriptStemSnapH</key>
24+
<array/>
25+
<key>postscriptStemSnapV</key>
26+
<array/>
27+
<key>styleName</key>
28+
<string>Bold</string>
29+
<key>unitsPerEm</key>
30+
<integer>1000</integer>
31+
<key>xHeight</key>
32+
<integer>500</integer>
33+
</dict>
34+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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>test</key>
6+
<string>test.glif</string>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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>color</key>
6+
<string>1,0.75,0,0.7</string>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="test" format="2">
3+
<advance width="500"/>
4+
<outline>
5+
<contour>
6+
<point x="19" y="17" type="curve"/>
7+
<point x="481" y="17" type="line"/>
8+
<point x="481.0" y="17.0"/>
9+
<point x="481.0" y="17.0"/>
10+
<point x="481" y="17" type="curve"/>
11+
<point x="481" y="479" type="line"/>
12+
<point x="481.0" y="479.0"/>
13+
<point x="481.0" y="479.0"/>
14+
<point x="481" y="479" type="curve"/>
15+
<point x="19" y="479" type="line"/>
16+
<point x="19.0" y="479.0"/>
17+
<point x="19.0" y="479.0"/>
18+
<point x="19" y="479" type="curve"/>
19+
<point x="19" y="17" type="line"/>
20+
<point x="19.0" y="17.0"/>
21+
<point x="19.0" y="17.0"/>
22+
</contour>
23+
</outline>
24+
</glyph>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
<array>
5+
<array>
6+
<string>foreground</string>
7+
<string>glyphs</string>
8+
</array>
9+
</array>
10+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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>com.typemytype.robofont.compileSettings.autohint</key>
6+
<true/>
7+
<key>com.typemytype.robofont.compileSettings.checkOutlines</key>
8+
<false/>
9+
<key>com.typemytype.robofont.compileSettings.createDummyDSIG</key>
10+
<true/>
11+
<key>com.typemytype.robofont.compileSettings.decompose</key>
12+
<false/>
13+
<key>com.typemytype.robofont.compileSettings.generateFormat</key>
14+
<integer>0</integer>
15+
<key>com.typemytype.robofont.compileSettings.releaseMode</key>
16+
<false/>
17+
<key>com.typemytype.robofont.italicSlantOffset</key>
18+
<integer>0</integer>
19+
<key>com.typemytype.robofont.segmentType</key>
20+
<string>curve</string>
21+
<key>com.typemytype.robofont.shouldAddPointsInSplineConversion</key>
22+
<integer>1</integer>
23+
<key>public.glyphOrder</key>
24+
<array>
25+
<string>test</string>
26+
</array>
27+
</dict>
28+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>creator</key>
6+
<string>com.github.fonttools.ufoLib</string>
7+
<key>formatVersion</key>
8+
<integer>3</integer>
9+
</dict>
10+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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>ascender</key>
6+
<integer>750</integer>
7+
<key>capHeight</key>
8+
<integer>750</integer>
9+
<key>descender</key>
10+
<integer>-250</integer>
11+
<key>familyName</key>
12+
<string>Test Ufo</string>
13+
<key>guidelines</key>
14+
<array/>
15+
<key>postscriptBlueValues</key>
16+
<array/>
17+
<key>postscriptFamilyBlues</key>
18+
<array/>
19+
<key>postscriptFamilyOtherBlues</key>
20+
<array/>
21+
<key>postscriptOtherBlues</key>
22+
<array/>
23+
<key>postscriptStemSnapH</key>
24+
<array/>
25+
<key>postscriptStemSnapV</key>
26+
<array/>
27+
<key>styleName</key>
28+
<string>Regular</string>
29+
<key>unitsPerEm</key>
30+
<integer>1000</integer>
31+
<key>xHeight</key>
32+
<integer>500</integer>
33+
</dict>
34+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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>test</key>
6+
<string>test.glif</string>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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>color</key>
6+
<string>1,0.75,0,0.7</string>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<glyph name="test" format="2">
3+
<advance width="500"/>
4+
<outline>
5+
<contour>
6+
<point x="219" y="217" type="curve"/>
7+
<point x="281" y="217" type="line"/>
8+
<point x="281.0" y="217.0"/>
9+
<point x="281.0" y="217.0"/>
10+
<point x="281" y="217" type="curve"/>
11+
<point x="281" y="279" type="line"/>
12+
<point x="281.0" y="279.0"/>
13+
<point x="281.0" y="279.0"/>
14+
<point x="281" y="279" type="curve"/>
15+
<point x="219" y="279" type="line"/>
16+
<point x="219.0" y="279.0"/>
17+
<point x="219.0" y="279.0"/>
18+
<point x="219" y="279" type="curve"/>
19+
<point x="219" y="217" type="line"/>
20+
<point x="219.0" y="217.0"/>
21+
<point x="219.0" y="217.0"/>
22+
</contour>
23+
</outline>
24+
</glyph>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
<array>
5+
<array>
6+
<string>foreground</string>
7+
<string>glyphs</string>
8+
</array>
9+
</array>
10+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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>com.typemytype.robofont.compileSettings.autohint</key>
6+
<true/>
7+
<key>com.typemytype.robofont.compileSettings.checkOutlines</key>
8+
<false/>
9+
<key>com.typemytype.robofont.compileSettings.createDummyDSIG</key>
10+
<true/>
11+
<key>com.typemytype.robofont.compileSettings.decompose</key>
12+
<false/>
13+
<key>com.typemytype.robofont.compileSettings.generateFormat</key>
14+
<integer>0</integer>
15+
<key>com.typemytype.robofont.compileSettings.releaseMode</key>
16+
<false/>
17+
<key>com.typemytype.robofont.italicSlantOffset</key>
18+
<integer>0</integer>
19+
<key>com.typemytype.robofont.segmentType</key>
20+
<string>curve</string>
21+
<key>com.typemytype.robofont.shouldAddPointsInSplineConversion</key>
22+
<integer>1</integer>
23+
<key>public.glyphOrder</key>
24+
<array>
25+
<string>test</string>
26+
</array>
27+
</dict>
28+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>creator</key>
6+
<string>com.github.fonttools.ufoLib</string>
7+
<key>formatVersion</key>
8+
<integer>3</integer>
9+
</dict>
10+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<designspace format="4.1">
3+
<axes>
4+
<axis tag="wght" name="Weight" minimum="100" maximum="1000" default="100"/>
5+
</axes>
6+
<sources>
7+
<source filename="SquareOne.ufo" familyname="InstatiatorStrictMathGlyph" stylename="Regular">
8+
<location>
9+
<dimension name="Weight" xvalue="100"/>
10+
</location>
11+
</source>
12+
<source filename="SquareTwo.ufo" familyname="InstatiatorStrictMathGlyph" stylename="Bold">
13+
<location>
14+
<dimension name="Weight" xvalue="1000"/>
15+
</location>
16+
</source>
17+
</sources>
18+
19+
<instances>
20+
<instance filename="SquareIntermediate.ufo" familyname="InstatiatorStrictMathGlyph" stylename="Medium">
21+
<location>
22+
<dimension name="Weight" xvalue="500"/>
23+
</location>
24+
</instance>
25+
</instances>
26+
</designspace>

tests/test_instantiator.py

+16
Original file line numberDiff line numberDiff line change
@@ -656,3 +656,19 @@ def test_designspace_v5_discrete_axis_raises_error(data_dir):
656656
fontmake.instantiator.InstantiatorError, match="splitInterpolable"
657657
):
658658
fontmake.instantiator.Instantiator.from_designspace(designspace)
659+
660+
661+
def test_strict_math_glyph(data_dir):
662+
designspace = designspaceLib.DesignSpaceDocument.fromfile(
663+
data_dir / "InstantiatorStrictMathGlyph" / "StrictMathGlyph.designspace"
664+
)
665+
generator = fontmake.instantiator.Instantiator.from_designspace(
666+
designspace, round_geometry=True
667+
)
668+
fonts = [
669+
generator.generate_instance(instance) for instance in designspace.instances
670+
]
671+
assert len(fonts) == 1
672+
glyph = fonts[0]["test"]
673+
assert len(glyph.contours) == 1
674+
assert len(glyph.contours[0].points) == 16

0 commit comments

Comments
 (0)