mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
font-patcher: Do not add Box drawing glyphs on propo fonts
[why] It does probably not make too much sense to add the box drawing glyphs to proportional fonts. The boxes that are drawn need to be filled with some text, and if that does not have monospaced property the box will always look ugly and not fit and change when the font is changed. [how] Make the fact if we detect a source font as monospaced or not a property of the patcher object. Always determine that property (before we just determined it when the target font should have monospaced behavior). Use that new property to enable/disable the box drawing glyphs. In a way it is now also prepared to add that as command line parameter should the need for that arise. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
7b4d83c2f3
commit
9834207159
1 changed files with 20 additions and 15 deletions
35
font-patcher
35
font-patcher
|
@ -292,6 +292,7 @@ class font_patcher:
|
|||
self.patch_set = None # class 'list'
|
||||
self.font_dim = None # class 'dict'
|
||||
self.font_extrawide = False
|
||||
self.source_monospaced = None # Later True or False
|
||||
self.onlybitmaps = 0
|
||||
self.essential = set()
|
||||
self.config = configparser.ConfigParser(empty_lines_in_values=False, allow_no_value=True)
|
||||
|
@ -301,8 +302,7 @@ class font_patcher:
|
|||
self.setup_version()
|
||||
self.get_essential_references()
|
||||
self.setup_name_backup(font)
|
||||
if not self.args.nonmono:
|
||||
self.assert_monospace()
|
||||
self.assert_monospace()
|
||||
self.remove_ligatures()
|
||||
self.setup_patch_set()
|
||||
self.get_sourcefont_dimensions()
|
||||
|
@ -716,6 +716,9 @@ class font_patcher:
|
|||
def assert_monospace(self):
|
||||
# Check if the sourcefont is monospaced
|
||||
width_mono, offending_char = is_monospaced(self.sourceFont)
|
||||
self.source_monospaced = width_mono
|
||||
if self.args.nonmono:
|
||||
return
|
||||
panose_mono = check_panose_monospaced(self.sourceFont)
|
||||
# The following is in fact "width_mono != panose_mono", but only if panose_mono is not 'unknown'
|
||||
if (width_mono and panose_mono == 0) or (not width_mono and panose_mono == 1):
|
||||
|
@ -736,19 +739,21 @@ class font_patcher:
|
|||
def setup_patch_set(self):
|
||||
""" Creates list of dicts to with instructions on copying glyphs from each symbol font into self.sourceFont """
|
||||
|
||||
self.sourceFont.selection.select(("ranges",), 0x2500, 0x259f)
|
||||
box_glyphs_target = len(list(self.sourceFont.selection))
|
||||
box_glyphs_current = len(list(self.sourceFont.selection.byGlyphs))
|
||||
if box_glyphs_target > box_glyphs_current:
|
||||
# Sourcefont does not have all of these glyphs, do not mix sets
|
||||
if not self.args.quiet and box_glyphs_current > 0:
|
||||
print("INFO: {}/{} box drawing glyphs will be replaced".format(
|
||||
box_glyphs_current, box_glyphs_target))
|
||||
box_keep = False
|
||||
box_enabled = True
|
||||
else:
|
||||
box_keep = True # just scale do not copy
|
||||
box_enabled = False # Cowardly not scaling existing glyphs, although the code would allow this
|
||||
box_enabled = self.source_monospaced # Box glyph only for monospaced
|
||||
if box_enabled:
|
||||
self.sourceFont.selection.select(("ranges",), 0x2500, 0x259f)
|
||||
box_glyphs_target = len(list(self.sourceFont.selection))
|
||||
box_glyphs_current = len(list(self.sourceFont.selection.byGlyphs))
|
||||
if box_glyphs_target > box_glyphs_current:
|
||||
# Sourcefont does not have all of these glyphs, do not mix sets
|
||||
if not self.args.quiet and box_glyphs_current > 0:
|
||||
print("INFO: {}/{} box drawing glyphs will be replaced".format(
|
||||
box_glyphs_current, box_glyphs_target))
|
||||
box_keep = False
|
||||
box_enabled = True
|
||||
else:
|
||||
box_keep = True # just scale do not copy
|
||||
box_enabled = False # Cowardly not scaling existing glyphs, although the code would allow this
|
||||
|
||||
# Stretch 'xz' or 'pa' (preserve aspect ratio)
|
||||
# Supported params: overlap | careful | xy-ratio | dont_copy
|
||||
|
|
Loading…
Reference in a new issue