From 3432ad667bae70a5da7b682e1d349d327411da15 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Sun, 30 Apr 2023 23:18:23 +0200 Subject: [PATCH] Revert "font-patcher: Use WIN metrics in all conflicting cases" This reverts commit 621008773c1864002a0c178715c062b4b3c9d36b, and adapts the code to more recent changes (logging, enums). [why] Lekton has a too wide line spacing. Lekton was the only font that selected TYPO but we forced it to WIN, because not all glyphs fit into the values from TYPO. But that seems to be wrong. Examining the glyphs that are really bigger than the TYPO line spaces, these are only graphical glyphs that shall span multiple lines. So I guess we should revert that change and render Lekton with the TYPO values. [note] https://github.com/ryanoasis/nerd-fonts/issues/1056#issuecomment-1529141863 --- font-patcher | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/font-patcher b/font-patcher index d987aa608a..68a9dccff7 100755 --- a/font-patcher +++ b/font-patcher @@ -6,7 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals # Change the script version when you edit this script: -script_version = "4.1.0" +script_version = "4.1.1" version = "3.0.0" projectName = "Nerd Fonts" @@ -1113,11 +1113,22 @@ class font_patcher: our_btb = typo_btb if use_typo else win_btb if our_btb == hhea_btb: metrics = Metric.TYPO if use_typo else Metric.WIN # conforming font + elif abs(our_btb - hhea_btb) / our_btb < 0.03: + logger.info("Font vertical metrics slightly off (%.1f%)", (our_btb - hhea_btb) / our_btb * 100.0) + metrics = Metric.TYPO if use_typo else Metric.WIN else: - # We trust the WIN metric more, see experiments in #1056 - logger.warning("Font vertical metrics inconsistent (HHEA %d / TYPO %d / WIN %d), using WIN", hhea_btb, typo_btb, win_btb) - our_btb = win_btb - metrics = Metric.WIN + # Try the other metric + our_btb = typo_btb if not use_typo else win_btb + if our_btb == hhea_btb: + logger.warning("Font vertical metrics probably wrong USE TYPO METRICS, assume opposite (i.e. %s)", 'True' if not use_typo else 'False') + use_typo = not use_typo + self.sourceFont.os2_use_typo_metrics = 1 if use_typo else 0 + metrics = Metric.TYPO if use_typo else Metric.WIN + else: + # We trust the WIN metric more, see experiments in #1056 + logger.warning("Font vertical metrics inconsistent (HHEA %d / TYPO %d / WIN %d), using WIN", hhea_btb, typo_btb, win_btb) + our_btb = win_btb + metrics = Metric.WIN # print("FINI hhea {} typo {} win {} use {} {} {}".format(hhea_btb, typo_btb, win_btb, use_typo, our_btb != hhea_btb, self.sourceFont.fontname))