Skip to content

Commit

Permalink
Merge pull request #3364 from fonttools/interpolatable-remake
Browse files Browse the repository at this point in the history
Interpolatable remake
  • Loading branch information
behdad committed Dec 2, 2023
2 parents 4c527e6 + 0db0b35 commit 9994829
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Lib/fontTools/varLib/interpolatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ def grand_parent(i, glyphname):

# If contour-order is wrong, adjust it
matching = matchings[m1idx]
if matching is not None and m1: # m1 is empty for composite glyphs
m1 = [m1[i] for i in matching]
if (
matching is not None and m1Isomorphisms
): # m1 is empty for composite glyphs
m1Isomorphisms = [m1Isomorphisms[i] for i in matching]
m1Vectors = [m1Vectors[i] for i in matching]
m1VectorsNormalized = [m1VectorsNormalized[i] for i in matching]
recording1 = [recording1[i] for i in matching]
Expand Down
6 changes: 4 additions & 2 deletions Lib/fontTools/varLib/interpolatablePlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class InterpolatablePlot:
/O\
/ \
"""
yay = r""" \o/ """

def __init__(self, out, glyphsets, names=None, **kwargs):
self.out = out
Expand Down Expand Up @@ -501,7 +502,6 @@ def add_problem(
if any(
pt
in (
"nothing",
"wrong_start_point",
"contour_order",
"kink",
Expand Down Expand Up @@ -677,6 +677,8 @@ def add_problem(
emoticon = self.underweight
elif "overweight" in problem_types:
emoticon = self.overweight
elif "nothing" in problem_types:
emoticon = self.yay
self.draw_emoticon(emoticon, x=x, y=y)

if show_page_number:
Expand Down Expand Up @@ -1062,7 +1064,7 @@ def draw_text(self, text, *, x=0, y=0, color=(0, 0, 0), width=None, height=None)
font_ascent = font_extents[0]
for line in text:
extents = cr.text_extents(line)
text_width = max(text_width, extents.width)
text_width = max(text_width, extents.x_advance)
text_height += font_line_height
if not text_width:
return
Expand Down
11 changes: 7 additions & 4 deletions Lib/fontTools/varLib/interpolatableTestStartingPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_starting_point(glyph0, glyph1, ix, tolerance, matching):
m0Vectors = glyph0.greenVectors
m1Vectors = [glyph1.greenVectors[i] for i in matching]

starting_point = 0
proposed_point = 0
reverse = False
min_cost = first_cost = 1

Expand Down Expand Up @@ -96,7 +96,10 @@ def test_starting_point(glyph0, glyph1, ix, tolerance, matching):
min_cost_idx, min_cost = min(enumerate(costs), key=lambda x: x[1])
first_cost = costs[0]
if min_cost < first_cost * tolerance:
this_tolerance = min_cost / first_cost
proposed_point = new_contour1[min_cost_idx][1]
# Don't report this
# min_cost = first_cost
# reverse = False
# proposed_point = 0 # new_contour1[min_cost_idx][1]
pass

return starting_point, reverse, min_cost, first_cost
return proposed_point, reverse, min_cost, first_cost

0 comments on commit 9994829

Please sign in to comment.