Skip to content

Commit

Permalink
[varLib.avarPlanner] Calculate slant axis average perceptually
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Jul 24, 2023
1 parent b06dec0 commit 86cfdcf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Lib/fontTools/varLib/avarPlanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def interpolateLog(t, a, b):


def measureWeight(glyphset, glyphs=None):
"""Measure the perceptual-average weight of the given glyphs."""
"""Measure the perceptual average weight of the given glyphs."""
if isinstance(glyphs, dict):
frequencies = glyphs

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

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L89

Added line #L89 was not covered by tests
else:
Expand Down Expand Up @@ -139,7 +139,7 @@ def measureWidth(glyphset, glyphs=None):


def measureSlant(glyphset, glyphs=None):
"""Measure the average slant angle of the given glyphs."""
"""Measure the perceptual average slant angle of the given glyphs."""
if isinstance(glyphs, dict):
frequencies = glyphs

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

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/varLib/avarPlanner.py#L144

Added line #L144 was not covered by tests
else:
Expand All @@ -160,8 +160,9 @@ def measureSlant(glyphset, glyphs=None):
pen = StatisticsPen(glyphset=glyphset)
glyph.draw(pen)

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L160 - L161 were not covered by tests

slnt_sum += pen.slant * frequency
freq_sum += frequency
mult = glyph.width * frequency
slnt_sum += mult * pen.slant
freq_sum += mult

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L163 - L165 were not covered by tests

return -math.degrees(math.atan(slnt_sum / freq_sum))

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#L167

Added line #L167 was not covered by tests

Expand Down

0 comments on commit 86cfdcf

Please sign in to comment.