From ef38ad6324cb11608335a1a6ee87c209e990bf28 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Mon, 13 Dec 2021 16:55:48 +0100 Subject: [PATCH] font-patcher: Remove obsolete metadata on glyph exchange [why] When we overwrite a glyph that originally had some special handling, be it a substitution or position table entry (GPOS/GSUB), that special handling is usually not appropriate anymore and has to be removed. If we need special lookup table entries for the new glyph we would have to add them later anyhow, because we can not rely on their existance. In Issue #509 it was a ligature entry, that replaced 'f' followed by 'i' with the 'fi' ligature. The ligature glyph is overwritten by us with a telephone symbol and the substitution table entry makes no sense anymore. [how] If we overwrite a preexisting codepoint we remove it from all lookup tables. Thanks to all other reporters with details. Fixes: #509 #254 Reported-by: mangelozzi Signed-off-by: Fini Jastrow --- font-patcher | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/font-patcher b/font-patcher index 0e76ab63c..e029eb354 100755 --- a/font-patcher +++ b/font-patcher @@ -706,16 +706,20 @@ class font_patcher: sym_dim = get_glyph_dimensions(sym_glyph) # check if a glyph already exists in this location + if copiedToSlot.startswith("uni"): + copiedToSlot = copiedToSlot[3:] + codepoint = int("0x" + copiedToSlot, 16) if careful or 'careful' in sym_attr['params']: - if copiedToSlot.startswith("uni"): - copiedToSlot = copiedToSlot[3:] - codepoint = int("0x" + copiedToSlot, 16) if codepoint in self.sourceFont: if self.args.quiet is False: print(" Found existing Glyph at {}. Skipping...".format(copiedToSlot)) - # We don't want to touch anything so move to next Glyph continue + else: + # If we overwrite an existing glyph all subtable entries regarding it will be wrong + # (Probably; at least if we add a symbol and do not substitude a ligature or such) + if codepoint in self.sourceFont: + self.sourceFont[codepoint].removePosSub("*") # Select and copy symbol from its encoding point # We need to do this select after the careful check, this way we don't