mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-12 09:41:47 +02:00
font-patcher: Add possibility to generate proportional font
[why] Theoretically we can produce 3 types on fonts: * A: Strictly monospaced font * B: Allow bigger symbols, but advance width still monospaced * C: Allow bigger symbols, advance width will vary All have their uses. Historically Nerd Fonts produced A and B. Then we had kind of a breaking change with 2.2.0 that it produces now A and C. The commit b9b7a5080 Revert "Remove negative bearings on 2048-em glyphs" restores the old (pre 2.2.0) behavior. But the type C fonts can be useful, so maybe we can have them as option? [how] Add commandline option to be able to create all fonts types: * A: specify -s or --mono or --use-single-width-glyphs * B: specify nothing * C: specify --variable-width-glyphs Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
1bb174e6bd
commit
63db683b1a
1 changed files with 14 additions and 1 deletions
15
font-patcher
15
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 = "3.0.3"
|
||||
script_version = "3.0.4"
|
||||
|
||||
version = "2.2.1"
|
||||
projectName = "Nerd Fonts"
|
||||
|
@ -320,6 +320,7 @@ class font_patcher:
|
|||
parser.add_argument('-out', '--outputdir', dest='outputdir', default=".", type=str, nargs='?', help='The directory to output the patched font file to')
|
||||
parser.add_argument('--glyphdir', dest='glyphdir', default=__dir__ + "/src/glyphs/", type=str, nargs='?', help='Path to glyphs to be used for patching')
|
||||
parser.add_argument('--makegroups', dest='makegroups', default=False, action='store_true', help='Use alternative method to name patched fonts (experimental)')
|
||||
parser.add_argument('--variable-width-glyphs', dest='nonmono', default=False, action='store_true', help='Do not adjust advance width (no "overhang")')
|
||||
|
||||
# progress bar arguments - https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
|
||||
progressbars_group_parser = parser.add_mutually_exclusive_group(required=False)
|
||||
|
@ -380,6 +381,10 @@ class font_patcher:
|
|||
if self.args.alsowindows:
|
||||
self.args.windows = False
|
||||
|
||||
if self.args.nonmono and self.args.single:
|
||||
print("Warniung: Specified contradicting --variable-width-glyphs and --use-single-width-glyph. Ignoring --variable-width-glyphs.")
|
||||
self.args.nonmono = False
|
||||
|
||||
# this one also works but it needs to be updated every time a font is added
|
||||
# it was a conditional in self.setup_font_names() before, but it was missing
|
||||
# a symbol font, so it would name the font complete without being so sometimes.
|
||||
|
@ -1065,6 +1070,10 @@ class font_patcher:
|
|||
# It should come after setting the glyph bearings
|
||||
self.set_glyph_width_mono(self.sourceFont[currentSourceFontGlyph])
|
||||
|
||||
# Re-remove negative bearings for target font with variable advance width
|
||||
if self.args.nonmono:
|
||||
self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph])
|
||||
|
||||
# Check if the inserted glyph is scaled correctly for monospace
|
||||
if self.args.single:
|
||||
(xmin, _, xmax, _) = self.sourceFont[currentSourceFontGlyph].boundingBox()
|
||||
|
@ -1115,6 +1124,10 @@ class font_patcher:
|
|||
self.font_dim.width is set with self.get_sourcefont_dimensions().
|
||||
"""
|
||||
try:
|
||||
# Fontforge handles the width change like this:
|
||||
# - Keep existing left_side_bearing
|
||||
# - Set width
|
||||
# - Calculate and set new right_side_bearing
|
||||
glyph.width = self.font_dim['width']
|
||||
except:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue