Skip to content

Commit 3b78bea

Browse files
authored
More otfautohint rounding fixes (#1772)
* More otfautohint rounding fixes * work around build problems
1 parent 4999028 commit 3b78bea

File tree

7 files changed

+66
-23
lines changed

7 files changed

+66
-23
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
3838

3939
add_definitions(-DANTLR4CPP_STATIC)
4040
set(ANTLR4_WITH_STATIC_CRT OFF)
41-
# 4.9.3 is the latest ANTLR4 version
42-
set(ANTLR4_TAG tags/4.13.2)
41+
# set(ANTLR4_TAG tags/4.13.2)
42+
# This is a more recent commit than 4.13.2 that addresses a missing
43+
# include directive needed in more recent Visual Studio releases
44+
set(ANTLR4_TAG df4d68c09cdef73e023b8838a8bc7ca4dff1d1de)
4345
include(ExternalAntlr4Cpp)
4446

4547

python/afdko/otfautohint/hinter.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ def addStemValue(self, lloc, uloc, val, spc, lseg, useg):
11741174
if not useg:
11751175
return
11761176

1177+
if self.options.roundCoords:
1178+
lloc = round(lloc)
1179+
uloc = round(uloc)
1180+
11771181
sv = stemValue(lloc, uloc, val, spc, lseg, useg, ghst)
11781182
self.insertStemValue(sv)
11791183

@@ -1721,7 +1725,9 @@ def addBBox(self, doSubpaths=False):
17211725
utype, 0, self.isV(), self.isV(), "u bbox")
17221726
self.hs.getPEState(pbs.extpes[1][peidx],
17231727
True).m_segs.append(useg)
1724-
hv = stemValue(mn_pt.o, mx_pt.o, 100, 0, lseg, useg, False)
1728+
lloc = round(mn_pt.o) if self.options.roundCoords else mn_pt.o
1729+
uloc = round(mx_pt.o) if self.options.roundCoords else mx_pt.o
1730+
hv = stemValue(lloc, uloc, 100, 0, lseg, useg, False)
17251731
self.insertStemValue(hv, "bboxadd")
17261732
self.hs.mainValues.append(hv)
17271733
self.hs.mainValues.sort(key=lambda sv: sv.compVal(self.SpcBonus),

python/afdko/otfautohint/hintstate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ def addToLoc(self, loc, score, strong=False, bb=False, seg=None):
468468
if sid in self.usedSegs:
469469
return
470470
self.usedSegs.add(sid)
471+
if self.dhinter.options.roundCoords:
472+
loc = round(loc)
471473
if loc in self.candDict:
472474
sLC = self.candDict[loc]
473475
else:

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
lxml==4.9.3
66
booleanOperations==0.9.0
77
defcon[lxml,pens]==0.10.3
8-
fontMath==0.9.3
9-
fontTools[unicode,woff,lxml,ufo]==4.43.0
8+
fontMath==0.9.4
9+
fontTools[unicode,woff,lxml,ufo]==4.56.0
1010
tqdm==4.66.1
11-
ufonormalizer==0.6.1
11+
ufonormalizer==0.6.2
1212
ufoProcessor==1.13.1

tests/otfautohint_data/input/dummy/decimals.ufo/glyphs.com.adobe.type.processedglyphs/braceleft.glif

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
<point x="153.6" y="-84"/>
1212
<point x="142.4" y="-63.2"/>
1313
<point x="142.4" y="-11.2" type="curve"/>
14-
<point x="142.4" y="37.6"/>
14+
<point x="142.4" y="37.6" name="hintRef0001"/>
1515
<point x="147.2" y="79.2"/>
1616
<point x="147.2" y="133.6" type="curve"/>
17-
<point x="147.2" y="184.8" name="hintRef0001"/>
17+
<point x="147.2" y="184.8" name="hintRef0002"/>
1818
<point x="133.6" y="211.2"/>
1919
<point x="99.2" y="220.8" type="curve"/>
2020
<point x="99.2" y="224" type="line"/>
2121
<point x="133.6" y="233.6"/>
2222
<point x="147.2" y="259.2"/>
2323
<point x="147.2" y="311.2" type="curve"/>
24-
<point x="147.2" y="365.6" name="hintRef0002"/>
24+
<point x="147.2" y="365.6"/>
2525
<point x="142.4" y="407.2"/>
2626
<point x="142.4" y="456" type="curve"/>
27-
<point x="142.4" y="508"/>
27+
<point x="142.4" y="508" name="hintRef0003"/>
2828
<point x="153.6" y="528.8"/>
2929
<point x="196.8" y="528.8" type="curve"/>
3030
<point x="218.4" y="528.8" type="line"/>
@@ -33,17 +33,17 @@
3333
<point x="119.2" y="566.4"/>
3434
<point x="88.8" y="542.4"/>
3535
<point x="88.8" y="460" type="curve"/>
36-
<point x="88.8" y="401.6"/>
36+
<point x="88.8" y="401.6" name="hintRef0004"/>
3737
<point x="96" y="359.2"/>
3838
<point x="96" y="304.8" type="curve"/>
39-
<point x="96" y="274.4" name="hintRef0003"/>
39+
<point x="96" y="274.4"/>
4040
<point x="81.6" y="244"/>
4141
<point x="27.2" y="243.2" type="curve"/>
42-
<point x="27.2" y="201.6" type="line"/>
43-
<point x="81.6" y="200.8"/>
42+
<point x="27.2" y="201.6" type="line" name="hintRef0005"/>
43+
<point x="81.6" y="200.8" name="hintRef0006"/>
4444
<point x="96" y="170.4"/>
4545
<point x="96" y="139.2" type="curve"/>
46-
<point x="96" y="85.6" name="hintRef0004"/>
46+
<point x="96" y="85.6"/>
4747
<point x="88.8" y="43.2"/>
4848
<point x="88.8" y="-15.2" type="curve"/>
4949
<point x="88.8" y="-97.6"/>
@@ -75,7 +75,7 @@
7575
<string>hstem -121.6 37.6</string>
7676
<string>hstem 201.6 41.6</string>
7777
<string>hstem 528.8 37.6</string>
78-
<string>vstem 27.2 72</string>
78+
<string>vstem 96 51.2</string>
7979
</array>
8080
</dict>
8181
<dict>
@@ -86,7 +86,7 @@
8686
<string>hstem -121.6 37.6</string>
8787
<string>hstem 201.6 41.6</string>
8888
<string>hstem 528.8 37.6</string>
89-
<string>vstem 88.8 53.6</string>
89+
<string>vstem 96 51.2</string>
9090
</array>
9191
</dict>
9292
<dict>
@@ -97,7 +97,7 @@
9797
<string>hstem -121.6 37.6</string>
9898
<string>hstem 201.6 41.6</string>
9999
<string>hstem 528.8 37.6</string>
100-
<string>vstem 27.2 72</string>
100+
<string>vstem 88.8 53.6</string>
101101
</array>
102102
</dict>
103103
<dict>
@@ -108,7 +108,29 @@
108108
<string>hstem -121.6 37.6</string>
109109
<string>hstem 201.6 41.6</string>
110110
<string>hstem 528.8 37.6</string>
111-
<string>vstem 88.8 53.6</string>
111+
<string>vstem 96 51.2</string>
112+
</array>
113+
</dict>
114+
<dict>
115+
<key>pointTag</key>
116+
<string>hintRef0005</string>
117+
<key>stems</key>
118+
<array>
119+
<string>hstem -121.6 37.6</string>
120+
<string>hstem 201.6 41.6</string>
121+
<string>hstem 528.8 37.6</string>
122+
<string>vstem 27.2 72</string>
123+
</array>
124+
</dict>
125+
<dict>
126+
<key>pointTag</key>
127+
<string>hintRef0006</string>
128+
<key>stems</key>
129+
<array>
130+
<string>hstem -121.6 37.6</string>
131+
<string>hstem 201.6 41.6</string>
132+
<string>hstem 528.8 37.6</string>
133+
<string>vstem 96 51.2</string>
112134
</array>
113135
</dict>
114136
</array>

tests/otfautohint_data/input/dummy/decimals.ufo/glyphs.com.adobe.type.processedglyphs/braceright.glif

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<point x="161.6" y="244" name="hintRef0003"/>
2020
<point x="146.4" y="274.4"/>
2121
<point x="146.4" y="304.8" type="curve"/>
22-
<point x="146.4" y="359.2"/>
22+
<point x="146.4" y="359.2" name="hintRef0004"/>
2323
<point x="153.6" y="401.6"/>
2424
<point x="153.6" y="460" type="curve"/>
2525
<point x="153.6" y="542.4"/>
@@ -34,14 +34,14 @@
3434
<point x="100" y="407.2"/>
3535
<point x="96" y="365.6"/>
3636
<point x="96" y="311.2" type="curve"/>
37-
<point x="96" y="259.2" name="hintRef0004"/>
37+
<point x="96" y="259.2" name="hintRef0005"/>
3838
<point x="108.8" y="233.6"/>
3939
<point x="143.2" y="224" type="curve"/>
4040
<point x="143.2" y="220.8" type="line"/>
4141
<point x="108.8" y="211.2"/>
4242
<point x="96" y="184.8"/>
4343
<point x="96" y="133.6" type="curve"/>
44-
<point x="96" y="79.2" name="hintRef0005"/>
44+
<point x="96" y="79.2" name="hintRef0006"/>
4545
<point x="100" y="37.6"/>
4646
<point x="100" y="-11.2" type="curve"/>
4747
<point x="100" y="-63.2"/>
@@ -108,13 +108,24 @@
108108
<string>hstem -121.6 37.6</string>
109109
<string>hstem 201.6 41.6</string>
110110
<string>hstem 528.8 37.6</string>
111-
<string>vstem 96 50.4</string>
111+
<string>vstem 100 53.6</string>
112112
</array>
113113
</dict>
114114
<dict>
115115
<key>pointTag</key>
116116
<string>hintRef0005</string>
117117
<key>stems</key>
118+
<array>
119+
<string>hstem -121.6 37.6</string>
120+
<string>hstem 201.6 41.6</string>
121+
<string>hstem 528.8 37.6</string>
122+
<string>vstem 96 50.4</string>
123+
</array>
124+
</dict>
125+
<dict>
126+
<key>pointTag</key>
127+
<string>hintRef0006</string>
128+
<key>stems</key>
118129
<array>
119130
<string>hstem -121.6 37.6</string>
120131
<string>hstem 201.6 41.6</string>
32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)