Skip to content

Commit

Permalink
Fix rounding in otfautohint (#1759)
Browse files Browse the repository at this point in the history
* Deal with rounding

* Update tests to match updated otfautohint

* Fix extrapolation test expected output (#1758)

---------

Co-authored-by: Zachary Quinn Scheuren <scheuren@adobe.com>
  • Loading branch information
skef and punchcutter authored Oct 14, 2024
1 parent 564ad94 commit c284ff7
Show file tree
Hide file tree
Showing 68 changed files with 647 additions and 914 deletions.
1 change: 1 addition & 0 deletions python/afdko/otfautohint/glyphData.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ def convertToCurve(self, sRatio=.333333, eRatio=None, roundCoords=False):
if eRatio is None:
eRatio = sRatio
self.is_line = False
# XXX deal with roundCoords properly
self.cs = self.s * (1 - sRatio) + self.e * sRatio
self.ce = self.s * eRatio + self.e * (1 - eRatio)

Expand Down
5 changes: 3 additions & 2 deletions python/afdko/otfautohint/hinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ def addSegment(self, fr, to, loc, pe1, pe2, typ, desc, mid=False):
not pe2.e.__eq__(ope2.e, ope2.getAssocFactor())):
mid2 = True
pe2 = ope2

if self.options.roundCoords:
loc = round(loc)
if not pe1 and not pe2:
return
self.hs.addSegment(fr, to, loc, pe1, pe2, typ, self.Bonus,
Expand Down Expand Up @@ -988,7 +989,7 @@ def genSegsForPathElement(self, c):
if abs(adist) < self.BendLength:
adist = math.copysign(adist, self.BendLength)
self.addSegment(aavg - adist, aavg + adist,
round(extp.o + 0.5), c, None,
extp.o, c, None,
hintSegment.sType.CURVE,
"curve extrema", True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<array>
<string>hstem -12 8</string>
<string>hstem 727 -20</string>
<string>vstem 104 39.5</string>
<string>vstem 104 40</string>
</array>
</dict>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<array>
<string>hstem -12 7</string>
<string>hstem 467 7</string>
<string>vstem 109.5 150.5</string>
<string>vstem 110 150</string>
</array>
</dict>
<dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<key>stems</key>
<array>
<string>hstem 9 -21</string>
<string>hstem 523 -20</string>
<string>hstem 330 193</string>
<string>vstem 21 248</string>
</array>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
<string>hintRef0002</string>
<key>stems</key>
<array>
<string>hstem 0 183.861</string>
<string>hstem 523 -20</string>
<string>hstem 0 184</string>
<string>hstem 327 196</string>
<string>hstem 683 -20</string>
<string>vstem 27 248</string>
<string>vstem 318 243</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<point x="509" y="190"/>
<point x="515" y="230"/>
<point x="515" y="270" type="curve"/>
<point x="515" y="400"/>
<point name="hintRef0001" x="515" y="400"/>
<point x="445" y="523"/>
<point x="278" y="523" type="curve"/>
<point x="148" y="523"/>
Expand All @@ -24,16 +24,16 @@
</contour>
<contour>
<point x="254" y="178" type="curve"/>
<point x="386" y="178" type="line"/>
<point name="hintRef0001" x="367" y="172"/>
<point name="hintRef0002" x="386" y="178" type="line"/>
<point name="hintRef0003" x="367" y="172"/>
<point x="350" y="169"/>
<point x="334" y="169" type="curve"/>
<point x="307" y="169"/>
<point x="278" y="152"/>
</contour>
<contour>
<point x="251" y="332" type="line"/>
<point name="hintRef0002" x="261" y="346"/>
<point name="hintRef0004" x="261" y="346"/>
<point x="270" y="342"/>
<point x="284" y="342" type="curve"/>
<point x="303" y="342"/>
Expand All @@ -47,8 +47,8 @@
<dict>
<key>flexList</key>
<array>
<string>hintRef0001</string>
<string>hintRef0002</string>
<string>hintRef0003</string>
<string>hintRef0004</string>
</array>
<key>hintSetList</key>
<array>
Expand All @@ -59,7 +59,16 @@
<array>
<string>hstem 9 -21</string>
<string>hstem 178 154</string>
<string>hstem 523 -20</string>
<string>vstem 21 494</string>
</array>
</dict>
<dict>
<key>pointTag</key>
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 9 -21</string>
<string>hstem 342 181</string>
<string>vstem 21 494</string>
</array>
</dict>
Expand All @@ -69,7 +78,17 @@
<key>stems</key>
<array>
<string>hstem 9 -21</string>
<string>hstem 342.2869 180.7131</string>
<string>hstem 178 154</string>
<string>vstem 21 494</string>
</array>
</dict>
<dict>
<key>pointTag</key>
<string>hintRef0004</string>
<key>stems</key>
<array>
<string>hstem 9 -21</string>
<string>hstem 342 181</string>
<string>vstem 21 494</string>
</array>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<point x="435" y="-192"/>
<point x="560" y="-121"/>
<point x="560" y="1" type="curve"/>
<point x="560" y="102"/>
<point name="hintRef0001" x="560" y="102"/>
<point x="476" y="142"/>
<point x="342" y="142" type="curve"/>
<point x="282" y="142" type="line"/>
<point name="hintRef0001" x="244" y="142"/>
<point x="244" y="142"/>
<point x="224" y="139"/>
<point x="224" y="154" type="curve"/>
<point x="224" y="158"/>
Expand Down Expand Up @@ -94,7 +94,7 @@
<string>hintRef0000</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 339 172</string>
<string>vstem 25 224</string>
<string>vstem 330 230</string>
Expand All @@ -116,7 +116,7 @@
<string>hintRef0002</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 161 139</string>
<string>hstem 339 172</string>
<string>vstem 279 206</string>
Expand All @@ -127,7 +127,7 @@
<string>hintRef0003</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 339 172</string>
<string>vstem 279 273</string>
</array>
Expand All @@ -137,7 +137,7 @@
<string>hintRef0004</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 523 -20</string>
<string>vstem 279 273</string>
</array>
Expand All @@ -147,7 +147,7 @@
<string>hintRef0005</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 161 139</string>
<string>hstem 523 -20</string>
<string>vstem 25 224</string>
Expand All @@ -159,7 +159,7 @@
<string>hintRef0006</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 366 157</string>
<string>vstem 25 224</string>
<string>vstem 330 230</string>
Expand All @@ -170,7 +170,7 @@
<string>hintRef0007</string>
<key>stems</key>
<array>
<string>hstem -192 144.9921</string>
<string>hstem -192 145</string>
<string>hstem 366 157</string>
<string>vstem 279 273</string>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<point x="619" y="0" type="line"/>
<point x="862" y="0" type="line"/>
<point x="862" y="308" type="line"/>
<point x="862" y="432"/>
<point name="hintRef0001" x="862" y="432"/>
<point x="814" y="523"/>
<point x="696" y="523" type="curve"/>
<point x="621" y="523"/>
Expand All @@ -38,7 +38,7 @@
<point x="295" y="491"/>
<point x="257" y="458" type="curve"/>
<point x="252" y="458" type="line"/>
<point name="hintRef0001" x="236" y="511" type="line"/>
<point name="hintRef0002" x="236" y="511" type="line"/>
<point x="39" y="511" type="line"/>
</contour>
</outline>
Expand All @@ -56,14 +56,24 @@
<key>stems</key>
<array>
<string>hstem 21 -21</string>
<string>hstem 318.0075 204.9925</string>
<string>hstem 318 193</string>
<string>vstem3 39 243 329 243 619 243</string>
</array>
</dict>
<dict>
<key>pointTag</key>
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 21 -21</string>
<string>hstem 523 -20</string>
<string>vstem3 39 243 329 243 619 243</string>
</array>
</dict>
<dict>
<key>pointTag</key>
<string>hintRef0002</string>
<key>stems</key>
<array>
<string>hstem 21 -21</string>
<string>hstem 511 -20</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
<point x="330" y="0" type="line"/>
<point x="573" y="0" type="line"/>
<point x="573" y="308" type="line"/>
<point x="573" y="432"/>
<point name="hintRef0001" x="573" y="432"/>
<point x="527" y="523"/>
<point x="411" y="523" type="curve"/>
<point x="342" y="523"/>
<point x="292" y="491"/>
<point x="257" y="459" type="curve"/>
<point x="252" y="459" type="line"/>
<point name="hintRef0001" x="236" y="511" type="line"/>
<point name="hintRef0002" x="236" y="511" type="line"/>
<point x="39" y="511" type="line"/>
</contour>
</outline>
Expand All @@ -41,7 +41,7 @@
<key>stems</key>
<array>
<string>hstem 21 -21</string>
<string>hstem 523 -20</string>
<string>hstem 318 193</string>
<string>vstem 39 243</string>
<string>vstem 330 243</string>
</array>
Expand All @@ -50,6 +50,17 @@
<key>pointTag</key>
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 21 -21</string>
<string>hstem 523 -20</string>
<string>vstem 39 243</string>
<string>vstem 330 243</string>
</array>
</dict>
<dict>
<key>pointTag</key>
<string>hintRef0002</string>
<key>stems</key>
<array>
<string>hstem 21 -21</string>
<string>hstem 511 -20</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<array>
<string>hstem -12 193</string>
<string>hstem 330 193</string>
<string>vstem 21 248</string>
<string>vstem 305 248</string>
<string>vstem 21 247</string>
<string>vstem 306 247</string>
</array>
</dict>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<string>hintRef0002</string>
<key>stems</key>
<array>
<string>hstem 0 192.9926</string>
<string>hstem 0 193</string>
<string>hstem 511 -20</string>
<string>vstem 37 243</string>
<string>vstem 323 243</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 0 55.5</string>
<string>hstem 0 56</string>
<string>hstem 191 58</string>
<string>hstem 658 -20</string>
<string>vstem 9 215</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 0 55.5</string>
<string>hstem 0 56</string>
<string>hstem 191 58</string>
<string>hstem 658 -20</string>
<string>hstem 734 -20</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 0 55.5</string>
<string>hstem 0 56</string>
<string>hstem 191 58</string>
<string>hstem 658 -20</string>
<string>hstem 713 138</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 0 55.5</string>
<string>hstem 0 56</string>
<string>hstem 191 58</string>
<string>hstem 658 -20</string>
<string>hstem 720 -20</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<string>hintRef0000</string>
<key>stems</key>
<array>
<string>hstem 0 58.5</string>
<string>hstem 598.5 58.5</string>
<string>hstem 0 58</string>
<string>hstem 598 59</string>
<string>vstem 415 207</string>
</array>
</dict>
Expand All @@ -52,7 +52,7 @@
<string>hintRef0001</string>
<key>stems</key>
<array>
<string>hstem 0 58.5</string>
<string>hstem 0 58</string>
<string>hstem 600 57</string>
<string>vstem 230 168</string>
</array>
Expand All @@ -62,7 +62,7 @@
<string>hintRef0002</string>
<key>stems</key>
<array>
<string>hstem 0 58.5</string>
<string>hstem 0 58</string>
<string>hstem 600 57</string>
<string>vstem 415 207</string>
</array>
Expand Down
Loading

0 comments on commit c284ff7

Please sign in to comment.