Skip to content

Commit

Permalink
Ignore the on/off curve marker if there is only one point
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Dec 4, 2024
1 parent 28f7e48 commit 03ff94d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions resources/scripts/ttx_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,15 @@ def normalize_glyf_contours(ttx):
glyph.remove(contour)
for contour in normalized:
glyph.append(contour)




# https://github.com/googlefonts/fontc/issues/1173
def erase_type_from_stranded_points(ttx):
for contour in ttx.xpath("//glyf/TTGlyph/contour"):
points = contour.xpath("./pt")
if len(points) == 1:
points[0].attrib["on"] = "irrelevent"


def allow_some_off_by_ones(fontc, fontmake, container, name_attr, coord_holder):
fontmake_num_coords = len(fontmake.xpath(f"//{container}/{coord_holder}"))
Expand Down Expand Up @@ -499,6 +506,8 @@ def reduce_diff_noise(fontc: etree.ElementTree, fontmake: etree.ElementTree):

normalize_glyf_contours(ttx)

erase_type_from_stranded_points(ttx)

allow_some_off_by_ones(fontc, fontmake, "glyf/TTGlyph", "name", "/contour/pt")
allow_some_off_by_ones(
fontc, fontmake, "gvar/glyphVariations", "glyph", "/tuple/delta"
Expand Down Expand Up @@ -775,7 +784,7 @@ def main(argv):
root = Path(".").resolve()
if root.name != "fontc":
sys.exit("Expected to be at the root of fontc")

fontc_bin_path = get_crate_path(FLAGS.fontc_path, root, "fontc")
otl_bin_path = get_crate_path(FLAGS.normalizer_path, root, "otl-normalizer")

Expand Down

0 comments on commit 03ff94d

Please sign in to comment.