Skip to content

Commit

Permalink
font-patcher: Remove obsolete metadata on glyph exchange
Browse files Browse the repository at this point in the history
[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 <mangelozzi@gmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
  • Loading branch information
Finii committed Dec 13, 2021
1 parent 97f28f4 commit ef38ad6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef38ad6

Please sign in to comment.