font-patcher: Fix patching non-monospaced fonts

[why]
Any non-monospaced font will not be be patched, the patcher crashes.

[how]
This must have happened when the box drawing characters rescaling
feature has been disabled. The default value (False) is not always set.

The box drawing patch has the ability to rescale existing box glyphs.
That used to be done when all box glyphs are already existing in the
source font. We do not patch in a new glyph set then, but we rescale the
existing glyphs to match the possibly new cell size.
But that feature is disabled and the attribute 'dont-copy' is never
utilized. It is disabled because some existing box sets are rather ...
sspecial in their overlap and can not be scaled as we would scale them.

Fixes: #1170

Reported-by: Henrique Monteiro <hrqmonteiro@protonmail.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-04-14 06:52:17 +02:00 committed by Fini
parent 049ca735ca
commit 5823665f1f

View file

@ -774,19 +774,20 @@ class font_patcher:
""" Creates list of dicts to with instructions on copying glyphs from each symbol font into self.sourceFont """ """ Creates list of dicts to with instructions on copying glyphs from each symbol font into self.sourceFont """
box_enabled = self.source_monospaced # Box glyph only for monospaced box_enabled = self.source_monospaced # Box glyph only for monospaced
box_keep = False
if box_enabled: if box_enabled:
self.sourceFont.selection.select(("ranges",), 0x2500, 0x259f) self.sourceFont.selection.select(("ranges",), 0x2500, 0x259f)
box_glyphs_target = len(list(self.sourceFont.selection)) box_glyphs_target = len(list(self.sourceFont.selection))
box_glyphs_current = len(list(self.sourceFont.selection.byGlyphs)) box_glyphs_current = len(list(self.sourceFont.selection.byGlyphs))
if box_glyphs_target > box_glyphs_current: if box_glyphs_target > box_glyphs_current:
# Sourcefont does not have all of these glyphs, do not mix sets # Sourcefont does not have all of these glyphs, do not mix sets (overwrite existing)
if not self.args.quiet and box_glyphs_current > 0: if not self.args.quiet and box_glyphs_current > 0:
print("INFO: {}/{} box drawing glyphs will be replaced".format( print("INFO: {}/{} box drawing glyphs will be replaced".format(
box_glyphs_current, box_glyphs_target)) box_glyphs_current, box_glyphs_target))
box_keep = False
box_enabled = True box_enabled = True
else: else:
box_keep = True # just scale do not copy # Sourcefont does have all of these glyphs
# box_keep = True # just scale do not copy (need to scale to fit new cell size)
box_enabled = False # Cowardly not scaling existing glyphs, although the code would allow this box_enabled = False # Cowardly not scaling existing glyphs, although the code would allow this
# Stretch 'xz' or 'pa' (preserve aspect ratio) # Stretch 'xz' or 'pa' (preserve aspect ratio)