Skip to content

Commit

Permalink
font-patcher: Use WIN metrics in all conflicting cases
Browse files Browse the repository at this point in the history
[why]
When HHEA and (depending on USE-TYPO-METRIC) TYPO or WIN are not
consistent it is unclear which metric we should trust.

In #1056 the complete font bounding box (i.e. yMin and yMax) has been
compared to the baseline to baseline distances, and in all these cases
the WIN values seem to be best (preserve the glyph bounding box).

    font-line report fontname.ttf | grep metrics:
    ttfdump -t head fontname.ttf | grep "yM(in|ax)"

[note]
Roboto will still be clipped?! There seem to be ridiculously high glyphs
in there. Did not check which.

Signed-off-by: Fini Jastrow <[email protected]>
  • Loading branch information
Finii committed Jan 22, 2023
1 parent 04c682f commit 80c1519
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -950,17 +950,10 @@ class font_patcher:
print("{}: Font vertical metrics slightly off ({:.1f}%)".format(projectName, (our_btb - hhea_btb) / our_btb * 100.0))
metrics = 1 if use_typo else 2
else:
# Try the other metric
our_btb = typo_btb if not use_typo else win_btb
if our_btb == hhea_btb:
print("{}: Font vertical metrics probably wrong USE TYPO METRICS, assume opposite (i.e. {})".format(projectName, not use_typo))
use_typo = not use_typo
self.sourceFont.os2_use_typo_metrics = 1 if use_typo else 0
metrics = 1 if use_typo else 2
else:
print("{}: WARNING Font vertical metrics inconsistent ({:.1f}%), using HHEA".format(projectName, (our_btb - hhea_btb) / our_btb * 100.0))
our_btb = hhea_btb
metrics = 0
# We trust the WIN metric more, see experiments in #1056
print("{}: WARNING Font vertical metrics inconsistent (HHEA {} / TYPO {} / WIN {}), using WIN".format(projectName, hhea_btb, typo_btb, win_btb))
our_btb = win_btb
metrics = 1

# print("FINI hhea {} typo {} win {} use {} {} {}".format(hhea_btb, typo_btb, win_btb, use_typo, our_btb != hhea_btb, self.sourceFont.fontname))

Expand Down

0 comments on commit 80c1519

Please sign in to comment.