Skip to content

Commit

Permalink
[varLib.avarPlanner] Delete old avar before calculations
Browse files Browse the repository at this point in the history
Ouch!
  • Loading branch information
behdad committed Jul 23, 2023
1 parent 2253722 commit e8caaf9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Lib/fontTools/varLib/avarPlanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def planWeightAxis(
outNormalized[bias + 1] = bias + 1
outNormalized[+1] = +1

Check warning on line 111 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L109-L111

Added lines #L109 - L111 were not covered by tests

from matplotlib import pyplot

Check warning on line 113 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L113

Added line #L113 was not covered by tests
pyplot.plot(sorted(outNormalized), [outNormalized[k] for k in sorted(outNormalized)])
pyplot.show()

Check warning on line 115 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L115

Added line #L115 was not covered by tests

print("Planned mapping:", out)
print("Planned normalized mapping:", outNormalized)
return out, outNormalized

Check warning on line 119 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L117-L119

Added lines #L117 - L119 were not covered by tests
Expand Down Expand Up @@ -141,12 +145,19 @@ def main(args=None):
elif axis.axisTag == "slnt":
slntAxis = axis

Check warning on line 146 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L146

Added line #L146 was not covered by tests

if "avar" in font:
existingMapping = font["avar"].segments["wght"]

Check warning on line 149 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L149

Added line #L149 was not covered by tests
else:
existingMapping = None

Check warning on line 151 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L151

Added line #L151 was not covered by tests

_, mapping = planWeightAxis(

Check warning on line 153 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L153

Added line #L153 was not covered by tests
font, wghtAxis.minValue, wghtAxis.defaultValue, wghtAxis.maxValue
)
if "avar" in font:
print("Existing weight mapping:", font["avar"].segments["wght"])
else:

if existingMapping is not None:
print("Existing weight mapping:", existingMapping)

Check warning on line 158 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L158

Added line #L158 was not covered by tests

if "avar" not in font:
font["avar"] = newTable("avar")
avar = font["avar"]
avar.segments["wght"] = mapping

Check warning on line 163 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L161-L163

Added lines #L161 - L163 were not covered by tests
Expand All @@ -156,6 +167,8 @@ def main(args=None):
font.save(outfile)

Check warning on line 167 in Lib/fontTools/varLib/avarPlanner.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L165-L167

Added lines #L165 - L167 were not covered by tests




if __name__ == "__main__":
import sys

Expand Down

0 comments on commit e8caaf9

Please sign in to comment.