From 1bb174e6bd4dd9edecbe6ad99d1e9e9dce6e98a5 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 1 Sep 2022 07:38:00 +0200 Subject: [PATCH 1/6] Revert "Remove negative bearings on 2048-em glyphs" This reverts commit 59c45ba4eff539d2a83a7d7004f056b9860d3253. [why] The commit breaks the non-mono Nerd Fonts for a lot of people. The issue was not very good documented and investigation can not be seen. For the TITLE it should have affected only the 2048-em Symbols only font, but in fact all patched fonts were changed. Maybe that was intended, maybe not. [how] This will make the advance width again equal for all glyphs. This enables the use of the non-mono variant in more terminals. For wider symbols a space is now (again) needed after the symbol. That is expected by a lot applications. [note] See Pull Request 764 for more details. See next commits for alternative solution for original problem. Signed-off-by: Fini Jastrow --- font-patcher | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/font-patcher b/font-patcher index fe7d9e8ea..d633abec1 100755 --- a/font-patcher +++ b/font-patcher @@ -1054,16 +1054,17 @@ class font_patcher: align_matrix = psMat.translate(x_align_distance, y_align_distance) self.sourceFont[currentSourceFontGlyph].transform(align_matrix) + # Ensure after horizontal adjustments and centering that the glyph + # does not overlap the bearings (edges) + self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph]) + # Needed for setting 'advance width' on each glyph so they do not overlap, # also ensures the font is considered monospaced on Windows by setting the # same width for all character glyphs. This needs to be done for all glyphs, # even the ones that are empty and didn't go through the scaling operations. + # It should come after setting the glyph bearings self.set_glyph_width_mono(self.sourceFont[currentSourceFontGlyph]) - # Ensure after horizontal adjustments and centering that the glyph - # does not overlap the bearings (edges) - 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() From 63db683b1a6c4a7341ec5872f437a8953a321bb0 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 1 Sep 2022 08:43:55 +0200 Subject: [PATCH 2/6] 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 --- font-patcher | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/font-patcher b/font-patcher index d633abec1..0ef33bf93 100755 --- a/font-patcher +++ b/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 From b83d1cfacbcbbd695781e78a46a2ff77dcb84b89 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 1 Sep 2022 12:36:51 +0200 Subject: [PATCH 3/6] Create NerdFontsSymbolsOnly with proportional widths [why] The commit 59c45ba4e Remove negative bearings on 2048-em glyphs has been introduced to fix some problems with the symbols only font, at least from the commit message. That font is intended to be used in font-fallback situations, and so we do not know the advance width of the current font anyhow. It does not make sense to enforce an advance width with these. [how] Create the NerdFontsSymbolsOnly as if 59c45ba4e would be still in effect, i.e. with variable advance width. [note] There have been a lot discussions about the reverted commit, some can be found here: * #900 * #764 * #731 Signed-off-by: Fini Jastrow --- src/unpatched-fonts/NerdFontsSymbolsOnly/config.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unpatched-fonts/NerdFontsSymbolsOnly/config.cfg b/src/unpatched-fonts/NerdFontsSymbolsOnly/config.cfg index fe1bf3137..e96c2cf4c 100755 --- a/src/unpatched-fonts/NerdFontsSymbolsOnly/config.cfg +++ b/src/unpatched-fonts/NerdFontsSymbolsOnly/config.cfg @@ -1 +1 @@ -config_patch_flags="--ext ttf" +config_patch_flags="--ext ttf --variable-width-glyphs" From f4d96f2258cb4cd2c036a06fd40df2dde4fd167c Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 1 Sep 2022 12:43:36 +0200 Subject: [PATCH 4/6] Update readme files Reported-by: Saumyajyoti Mukherjee Signed-off-by: Fini Jastrow --- readme.md | 4 +++- readme_cn.md | 4 +++- readme_es.md | 4 +++- readme_fr.md | 4 +++- readme_hi.md | 4 +++- readme_it.md | 4 +++- readme_ja.md | 4 +++- readme_ko.md | 4 +++- readme_pl.md | 4 +++- readme_pt-pt.md | 4 +++- readme_ru.md | 4 +++- readme_tw.md | 4 +++- readme_uk.md | 4 +++- 13 files changed, 39 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index 6acb5f684..8145a942c 100644 --- a/readme.md +++ b/readme.md @@ -373,7 +373,7 @@ Full options: usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -416,6 +416,8 @@ options: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Show percentage completion progress bars per Glyph Set --no-progressbars Don't show percentage completion progress bars per Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_cn.md b/readme_cn.md index fd978f11c..443530283 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -384,7 +384,7 @@ The list is not complete, but you can [search for a complete list here](https:// usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -427,6 +427,8 @@ optional arguments: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars 显示每个Glyph Set的完成度进度条 --no-progressbars 不显示每个Glyph Set的完成度进度条 --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_es.md b/readme_es.md index 9d810c285..ac61fb4f3 100644 --- a/readme_es.md +++ b/readme_es.md @@ -332,7 +332,7 @@ Parcha la fuente de tu preferencia para usar los [VimDevIcons ➶][vim-devicons] uso: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -375,6 +375,8 @@ argumentos opcionales: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Muestra barras de progreso con porcentajes de completitud por cada Conjunto de Glifos --no-progressbars No muestra barras de progreso con porcentajes de completitud por cada Conjunto de Glifos --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_fr.md b/readme_fr.md index 4fa37de72..3afb97cd8 100644 --- a/readme_fr.md +++ b/readme_fr.md @@ -410,7 +410,7 @@ Générer la police de votre choix pour l'utiliser avec [VimDevIcons ➶][vim-de usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -453,6 +453,8 @@ options: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Show percentage completion progress bars per Glyph Set --no-progressbars Don't show percentage completion progress bars per Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_hi.md b/readme_hi.md index 428db9fde..b85f162ca 100644 --- a/readme_hi.md +++ b/readme_hi.md @@ -365,7 +365,7 @@ The list is not complete, but you can [search for a complete list here](https:// प्रयोग: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -408,6 +408,8 @@ The list is not complete, but you can [search for a complete list here](https:// --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars प्रति ग्लिफ़ सेट प्रतिशत पूर्णता प्रगति बार दिखाएं --no-progressbars प्रति ग्लिफ़ सेट प्रतिशत पूर्णता प्रगति बार न दिखाएं --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_it.md b/readme_it.md index acd198799..2074ca6c9 100644 --- a/readme_it.md +++ b/readme_it.md @@ -333,7 +333,7 @@ Modificare il font di tua scelta per utilizzare i [VimDevIcons ➶][vim-devicons usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -376,6 +376,8 @@ options: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Show percentage completion progress bars per Glyph Set --no-progressbars Don't show percentage completion progress bars per Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_ja.md b/readme_ja.md index c8b05ac9a..8fa99f981 100644 --- a/readme_ja.md +++ b/readme_ja.md @@ -328,7 +328,7 @@ The list is not complete, but you can [search for a complete list here](https:// usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -371,6 +371,8 @@ optional arguments: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars グリフセットごとに進捗を百分率で表示します。 --no-progressbars グリフセットごとの進捗を表示しません。 --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_ko.md b/readme_ko.md index b0056dafe..b692ce271 100644 --- a/readme_ko.md +++ b/readme_ko.md @@ -329,7 +329,7 @@ The list is not complete, but you can [search for a complete list here](https:// usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -372,6 +372,8 @@ options: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Show percentage completion progress bars per Glyph Set --no-progressbars Don't show percentage completion progress bars per Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_pl.md b/readme_pl.md index 7fe4bb537..042d93df3 100644 --- a/readme_pl.md +++ b/readme_pl.md @@ -405,7 +405,7 @@ Patchowanie wybranych przez ciebie fontów z wykorzystaniem [VimDevIcons ➶][vi usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -448,6 +448,8 @@ options: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Show percentage completion progress bars per Glyph Set --no-progressbars Don't show percentage completion progress bars per Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_pt-pt.md b/readme_pt-pt.md index 51eae3ac7..3a9050f3c 100644 --- a/readme_pt-pt.md +++ b/readme_pt-pt.md @@ -329,7 +329,7 @@ Modificar o tipo de letra à tua escolha com [VimDevIcons ➶][vim-devicons]: usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -372,6 +372,8 @@ argumentos opcionais: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Mostrar barras de progresso de conclusão percentual por Glyph Set --no-progressbars Não mostrar barras de progresso de conclusão percentual por Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_ru.md b/readme_ru.md index 6c188ce19..7ad00369b 100644 --- a/readme_ru.md +++ b/readme_ru.md @@ -384,7 +384,7 @@ The list is not complete, but you can [search for a complete list here](https:// usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -427,6 +427,8 @@ options: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Show percentage completion progress bars per Glyph Set --no-progressbars Don't show percentage completion progress bars per Glyph Set --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_tw.md b/readme_tw.md index 38f9dc828..4a7f5e48a 100644 --- a/readme_tw.md +++ b/readme_tw.md @@ -384,7 +384,7 @@ The list is not complete, but you can [search for a complete list here](https:// usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -427,6 +427,8 @@ optional arguments: --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars 顯示每個Glyph Set的完成度進度條 --no-progressbars 不顯示每個Glyph Set的完成度進度條 --also-windows Create two fonts, the normal and the --windows version diff --git a/readme_uk.md b/readme_uk.md index ee38c4d4f..70867adbd 100644 --- a/readme_uk.md +++ b/readme_uk.md @@ -326,7 +326,7 @@ The list is not complete, but you can [search for a complete list here](https:// usage: font-patcher [-h] [-v] [-s] [-l] [-q] [-w] [-c] [--careful] [--removeligs] [--postprocess [POSTPROCESS]] [--configfile [CONFIGFILE]] [--custom [CUSTOM]] [-ext [EXTENSION]] [-out [OUTPUTDIR]] - [--glyphdir [GLYPHDIR]] [--makegroups] + [--glyphdir [GLYPHDIR]] [--makegroups] [--variable-width-glyphs] [--progressbars | --no-progressbars] [--also-windows] [--fontawesome] [--fontawesomeextension] [--fontlinux] [--octicons] [--codicons] [--powersymbols] [--pomicons] @@ -369,6 +369,8 @@ The list is not complete, but you can [search for a complete list here](https:// --glyphdir [GLYPHDIR] Path to glyphs to be used for patching --makegroups Use alternative method to name patched fonts (experimental) + --variable-width-glyphs + Do not adjust advance width (no "overhang") --progressbars Показати прогресбар виконання обробки кожного гліфу --no-progressbars Не показувати прогресбар виконання обробки кожного гліфу --also-windows Create two fonts, the normal and the --windows version From 8f8776cf30154738cbb73be9a9f02eceb6a3dfa4 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Mon, 7 Feb 2022 15:05:54 +0100 Subject: [PATCH 5/6] font-patcher: Make patch_set[attributes][params] a dict [why] The params are half way handled as dict, but if unset it is an empty string. That makes accessing it needlessly complicated. [how] With no functional change the params becomes now a dict, also when it does not contain any particular information. At the moment that seems not nessecary, as it can only contain one key: 'overlap'. We could also rename 'params' to 'overlap' and just store the value. But we keep the generic params dictionary as it might come in handy some time in the far future when more parameters are added. Signed-off-by: Fini Jastrow --- font-patcher | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/font-patcher b/font-patcher index 0ef33bf93..e86969ec1 100755 --- a/font-patcher +++ b/font-patcher @@ -678,7 +678,7 @@ class font_patcher: # Supported params: overlap | careful # Powerline dividers SYM_ATTR_POWERLINE = { - 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': ''}, + 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {}}, # Arrow tips 0xe0b0: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {'overlap': 0.02}}, @@ -711,23 +711,23 @@ class font_patcher: 0xe0c3: {'align': 'r', 'valign': 'c', 'stretch': 'xy', 'params': {'overlap': 0.01}}, # Small squares - 0xe0c4: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': ''}, - 0xe0c5: {'align': 'r', 'valign': 'c', 'stretch': 'xy', 'params': ''}, + 0xe0c4: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {}}, + 0xe0c5: {'align': 'r', 'valign': 'c', 'stretch': 'xy', 'params': {}}, # Bigger squares - 0xe0c6: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': ''}, - 0xe0c7: {'align': 'r', 'valign': 'c', 'stretch': 'xy', 'params': ''}, + 0xe0c6: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {}}, + 0xe0c7: {'align': 'r', 'valign': 'c', 'stretch': 'xy', 'params': {}}, # Waveform 0xe0c8: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {'overlap': 0.01}}, # Hexagons - 0xe0cc: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': ''}, - 0xe0cd: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': ''}, + 0xe0cc: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {}}, + 0xe0cd: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {}}, # Legos - 0xe0ce: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': ''}, - 0xe0cf: {'align': 'c', 'valign': 'c', 'stretch': 'xy', 'params': ''}, + 0xe0ce: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {}}, + 0xe0cf: {'align': 'c', 'valign': 'c', 'stretch': 'xy', 'params': {}}, 0xe0d1: {'align': 'l', 'valign': 'c', 'stretch': 'xy', 'params': {'overlap': 0.02}}, # Top and bottom trapezoid @@ -737,22 +737,22 @@ class font_patcher: SYM_ATTR_DEFAULT = { # 'pa' == preserve aspect ratio - 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': ''} + 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {}} } SYM_ATTR_FONTA = { # 'pa' == preserve aspect ratio - 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': ''}, + 'default': {'align': 'c', 'valign': 'c', 'stretch': 'pa', 'params': {}}, # Don't center these arrows vertically - 0xf0dc: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': ''}, - 0xf0dd: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': ''}, - 0xf0de: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': ''} + 0xf0dc: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': {}}, + 0xf0dd: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': {}}, + 0xf0de: {'align': 'c', 'valign': '', 'stretch': 'pa', 'params': {}} } CUSTOM_ATTR = { # 'pa' == preserve aspect ratio - 'default': {'align': 'c', 'valign': '', 'stretch': '', 'params': ''} + 'default': {'align': 'c', 'valign': '', 'stretch': '', 'params': {}} } # Most glyphs we want to maximize during the scale. However, there are some @@ -1017,13 +1017,10 @@ class font_patcher: # Currently stretching vertically for both monospace and double-width scale_ratio_y = self.font_dim['height'] / sym_dim['height'] - if 'overlap' in sym_attr['params']: - overlap = sym_attr['params']['overlap'] - else: - overlap = 0 + overlap = sym_attr['params'].get('overlap') if scale_ratio_x != 1 or scale_ratio_y != 1: - if overlap != 0: + if overlap: scale_ratio_x *= 1 + overlap scale_ratio_y *= 1 + overlap self.sourceFont[currentSourceFontGlyph].transform(psMat.scale(scale_ratio_x, scale_ratio_y)) @@ -1049,7 +1046,7 @@ class font_patcher: # Right align x_align_distance += self.font_dim['width'] - sym_dim['width'] - if overlap != 0: + if overlap: overlap_width = self.font_dim['width'] * overlap if sym_attr['align'] == 'l': x_align_distance -= overlap_width @@ -1077,7 +1074,7 @@ class font_patcher: # Check if the inserted glyph is scaled correctly for monospace if self.args.single: (xmin, _, xmax, _) = self.sourceFont[currentSourceFontGlyph].boundingBox() - if int(xmax - xmin) > self.font_dim['width'] * (1 + overlap): + if int(xmax - xmin) > self.font_dim['width'] * (1 + (overlap or 0)): print("\n Warning: Scaled glyph U+{:X} wider than one monospace width ({} / {} (overlap {}))".format( currentSourceFontGlyph, int(xmax - xmin), self.font_dim['width'], overlap)) From f67de4d7b0adc2bb34f19560e1f884bc482163ff Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Mon, 7 Feb 2022 15:11:08 +0100 Subject: [PATCH 6/6] font-patcher: Fix glyphs with overlap [why] For some powerline symbols we add a certain amount of overlap into the previous or next character to cover up a small gap between the symbols that otherwise can show up as ugly thin (usually colored) line. But after we carefully design that glyph with a bit overlap (over-sized and having negative bearings) we remove all bearings. That breaks of course the glyph and no actual overlap on the left side happens. [how] Just do not remove negative bearings on overlap-enabled glyphs. As they are rescaled in both directions anyhow all bearings are wanted and must be kept. Reported-by: Mihail Ivanchev <@MIvanchev> Signed-off-by: Fini Jastrow --- font-patcher | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/font-patcher b/font-patcher index e86969ec1..85ac64430 100755 --- a/font-patcher +++ b/font-patcher @@ -1058,7 +1058,8 @@ class font_patcher: # Ensure after horizontal adjustments and centering that the glyph # does not overlap the bearings (edges) - self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph]) + if not overlap: + self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph]) # Needed for setting 'advance width' on each glyph so they do not overlap, # also ensures the font is considered monospaced on Windows by setting the