Skip to content

Commit

Permalink
Handle rounding of component transforms when calculating glyph hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
jenskutilek committed Sep 4, 2024
1 parent f2ff494 commit 653455b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Lib/extractor/formats/opentype.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import time
from fontTools.misc.fixedTools import floatToFixedToFloat
from fontTools.pens.boundsPen import ControlBoundsPen
from fontTools.pens.hashPointPen import HashPointPen
from fontTools.pens.roundingPen import RoundingPointPen
from fontTools.ttLib import TTFont, TTLibError
from fontTools.ttLib.tables._g_l_y_f import (
OVERLAP_COMPOUND,
ROUND_XY_TO_GRID,
USE_MY_METRICS,
)
from fontTools.ttLib.tables._h_e_a_d import mac_epoch_diff
from functools import partial
from extractor.exceptions import ExtractorError
from extractor.stream import InstructionStream
from extractor.tools import RelaxedInfo, copyAttr
Expand Down Expand Up @@ -157,7 +160,11 @@ def extractGlyphPrograms(source, destination):
continue

hash_pen = HashPointPen(dest_glyph.width, destination)
dest_glyph.drawPoints(hash_pen)
round_pen = RoundingPointPen(
hash_pen,
transformRoundFunc=partial(floatToFixedToFloat, precisionBits=14)
)
dest_glyph.drawPoints(round_pen)
lib = dest_glyph.lib[TRUETYPE_INSTRUCTIONS_KEY] = {
"formatVersion": "1",
"id": hash_pen.hash,
Expand Down

0 comments on commit 653455b

Please sign in to comment.