Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for metrics and boxdrawing #1300

Merged
merged 4 commits into from
Oct 13, 2023
Merged

Add option for metrics and boxdrawing #1300

merged 4 commits into from
Oct 13, 2023

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Jun 14, 2023

Description

This PR introduces two new options to the font-patcher that can be used by advanced users to tackle problematic fonts.
See individual commits for explanation.

Is this already featurism? Maybe this amount of detailed options is too much? 🤔

Requirements / Checklist

What does this Pull Request (PR) do?

Add --metrics and --boxdrawing to the font-patcher parameters.

How should this be manually tested?

As the options are disabled by default normal runs are safe.
Debug runs should show the expected (different) behavior.

Any background context you can provide?

#1298

What are the relevant tickets (if any)?

Screenshots (if appropriate or helpful)

@Finii
Copy link
Collaborator Author

Finii commented Jun 14, 2023

Hmm, we could add code that cross-checks our metrics with the box-glyph-metrics, if the font has box glyphs 🤔
We could at least warn if the box-glyphs will be too small afterwards.

@Finii
Copy link
Collaborator Author

Finii commented Oct 13, 2023

Rebase on master, force push

[why]
If the font has contradicting baseline to baseline metrics the patcher
tries to find a sane value and use that. That automatism gets it right
in most cases, but there might be fonts where the user wants a different
metric to be used.

At the moment the use would need to use `font-line` to adjust the
metrics, which is not very convenient.

[how]
Add option to select one of the metricses.
Use that metrics when setting up the patched font.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
When the original font designer's idea of cell height differs from the
height we deduce the box drawing glyphs come out with the wrong size (if
we do not touch them, for example because the font already has a
complete set).

[how]
Add option that enforces patch-in of the box set.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It can be hard to find the 'usual' options in between all the expert
options.

[how]
Regroup the options and sort them alphabetically (most of the time).
Not sure if this helps, but in my personal view this makes it easier.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
It is rather confusing to have so many aliases.

[how]
Remove some long forms and some alternatives, to make the help page
easier to read.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii
Copy link
Collaborator Author

Finii commented Oct 13, 2023

$ fontforge font-patcher --help 2>/dev/null
Nerd Fonts Patcher v3.0.2-79 (4.6.0) (ff 20230101)
usage: font-patcher [-h] [-v] [-s] [--variable-width-glyphs] [--debug [{0,1,2,3}]] [-q] [--careful] [-ext EXTENSION]
                    [-out OUTPUTDIR] [--makegroups [{-1,0,1,2,3,4,5,6}]] [-c] [--codicons] [--fontawesome]
                    [--fontawesomeext] [--fontlogos] [--material] [--octicons] [--powersymbols] [--pomicons]
                    [--powerline] [--powerlineextra] [--weather] [--boxdrawing] [--configfile CONFIGFILE]
                    [--custom CUSTOM] [--dry] [--glyphdir GLYPHDIR] [--has-no-italic] [-l] [--metrics {HHEA,TYPO,WIN}]
                    [--name FORCE_NAME] [--postprocess POSTPROCESS] [--removeligs] [--xavgcharwidth [XAVGWIDTH]]
                    [--progressbars | --no-progressbars]
                    font

Nerd Fonts Font Patcher: patches a given font with programming and development related glyphs

* Website: https://www.nerdfonts.com
* Version: 3.0.2-79
* Development Website: https://github.com/ryanoasis/nerd-fonts
* Changelog: https://github.com/ryanoasis/nerd-fonts/blob/-/changelog.md

positional arguments:
  font                  The path to the font to patch (e.g., Inconsolata.otf)

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -s, --mono, --use-single-width-glyphs
                        Whether to generate the glyphs as single-width not double-width (default is double-width) (Nerd Font Mono)
  --variable-width-glyphs
                        Do not adjust advance width (no "overhang") (Nerd Font Propo)
  --debug [{0,1,2,3}]   Verbose mode (optional: 1=just to file; 2*=just to terminal; 3=display and file)
  -q, --quiet           Do not generate verbose output
  --careful             Do not overwrite existing glyphs if detected
  -ext EXTENSION, --extension EXTENSION
                        Change font file type to create (e.g., ttf, otf)
  -out OUTPUTDIR, --outputdir OUTPUTDIR
                        The directory to output the patched font file to
  --makegroups [{-1,0,1,2,3,4,5,6}]
                        Use alternative method to name patched fonts (default=1)

Symbol Fonts:
  -c, --complete        Add all available Glyphs
  --codicons            Add Codicons Glyphs (https://github.com/microsoft/vscode-codicons)
  --fontawesome         Add Font Awesome Glyphs (http://fontawesome.io/)
  --fontawesomeext      Add Font Awesome Extension Glyphs (https://andrelzgava.github.io/font-awesome-extension/)
  --fontlogos           Add Font Logos Glyphs (https://github.com/Lukas-W/font-logos)
  --material, --mdi     Add Material Design Icons (https://github.com/templarian/MaterialDesign)
  --octicons            Add Octicons Glyphs (https://octicons.github.com)
  --powersymbols        Add IEC Power Symbols (https://unicodepowersymbol.com/)
  --pomicons            Add Pomicon Glyphs (https://github.com/gabrielelana/pomicons)
  --powerline           Add Powerline Glyphs
  --powerlineextra      Add Powerline Extra Glyphs (https://github.com/ryanoasis/powerline-extra-symbols)
  --weather             Add Weather Icons (https://github.com/erikflowers/weather-icons)

Expert Options:
  --boxdrawing          Force patching in (over existing) box drawing glyphs
  --configfile CONFIGFILE
                        Specify a file path for JSON configuration file (see sample: src/config.sample.json)
  --custom CUSTOM       Specify a custom symbol font, all glyphs will be copied; absolute path suggested
  --dry                 Do neither patch nor store the font, to check naming
  --glyphdir GLYPHDIR   Path to glyphs to be used for patching
  --has-no-italic       Font family does not have Italic (but Oblique), to help create correct RIBBI set
  -l, --adjust-line-height
                        Whether to adjust line heights (attempt to center powerline separators more evenly)
  --metrics {HHEA,TYPO,WIN}
                        Select vertical metrics source (for problematic cases)
  --name FORCE_NAME     Specify naming source ('full', 'postscript', or concrete free name-string)
  --postprocess POSTPROCESS
                        Specify a Script for Post Processing
  --removeligs, --removeligatures
                        Removes ligatures specificed in JSON configuration file (needs --configfile)
  --xavgcharwidth [XAVGWIDTH]
                        Adjust xAvgCharWidth (optional: concrete value)
  --progressbars        Show percentage completion progress bars per Glyph Set (default)
  --no-progressbars     Don't show percentage completion progress bars per Glyph Set

@Finii Finii merged commit 2870965 into master Oct 13, 2023
5 checks passed
@Finii Finii deleted the feature/metrics-option branch October 13, 2023 18:47
LNKLEO pushed a commit to LNKLEO/Nerd that referenced this pull request Nov 24, 2023
@ptitfred
Copy link

ptitfred commented Jun 2, 2024

To anybody having a look at it afterward: --fontawesomeextension has been renamed to --fontawesomeext too (it's not advertised in the release notes).

Was it on purpose? I don't see the link with the PR's intent.

@Finii
Copy link
Collaborator Author

Finii commented Jun 3, 2024

It is this commit: 99f3b20

Commit:     Fini Jastrow <ulf.fini.jastrow@desy.de>
CommitDate: Fri Oct 13 12:42:46 2023 +0200

    font-patcher: Drop some option alternatives

    [why]
    It is rather confusing to have so many aliases.

    [how]
    Remove some long forms and some alternatives, to make the help page
    easier to read.

    Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
---
 font-patcher | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/font-patcher b/font-patcher
index 62a2554ee..ba8625144 100755
--- a/font-patcher
+++ b/font-patcher
@@ -1858,7 +1858,7 @@ def setup_arguments():
     parser.add_argument('-s', '--mono', '--use-single-width-glyphs', dest='single',           default=False, action='count',      help='Whether to generate the glyphs as single-width not double-width (defaul
     parser.add_argument('--variable-width-glyphs',                   dest='nonmono',          default=False, action='store_true', help='Do not adjust advance width (no "overhang") (Nerd Font Propo)')
     parser.add_argument('--debug',                                   dest='debugmode',        default=0,     type=int, nargs='?', help='Verbose mode (optional: 1=just to file; 2*=just to terminal; 3=display
-    parser.add_argument('-q', '--quiet', '--shutup',                 dest='quiet',            default=False, action='store_true', help='Do not generate verbose output')
+    parser.add_argument('-q', '--quiet',                             dest='quiet',            default=False, action='store_true', help='Do not generate verbose output')
     parser.add_argument('--careful',                                 dest='careful',          default=False, action='store_true', help='Do not overwrite existing glyphs if detected')
     parser.add_argument('-ext', '--extension',                       dest='extension',        default="",    type=str,            help='Change font file type to create (e.g., ttf, otf)')
     parser.add_argument('-out', '--outputdir',                       dest='outputdir',        default=".",   type=str,            help='The directory to output the patched font file to')
@@ -1879,15 +1879,15 @@ def setup_arguments():
     sym_font_group.add_argument('-c', '--complete',                             dest='complete',             default=False, action='store_true', help='Add all available Glyphs')
     sym_font_group.add_argument('--codicons',                                   dest='codicons',             default=False, action='store_true', help='Add Codicons Glyphs (https://github.com/microsoft/vscode
     sym_font_group.add_argument('--fontawesome',                                dest='fontawesome',          default=False, action='store_true', help='Add Font Awesome Glyphs (http://fontawesome.io/)')
-    sym_font_group.add_argument('--fontawesomeextension',                       dest='fontawesomeextension', default=False, action='store_true', help='Add Font Awesome Extension Glyphs (https://andrelzgava.g
-    sym_font_group.add_argument('--fontlogos', '--fontlinux',                   dest='fontlogos',            default=False, action='store_true', help='Add Font Logos Glyphs (https://github.com/Lukas-W/font-l
-    sym_font_group.add_argument('--material', '--materialdesignicons', '--mdi', dest='material',             default=False, action='store_true', help='Add Material Design Icons (https://github.com/templarian
+    sym_font_group.add_argument('--fontawesomeext',                             dest='fontawesomeextension', default=False, action='store_true', help='Add Font Awesome Extension Glyphs (https://andrelzgava.g
+    sym_font_group.add_argument('--fontlogos',                                  dest='fontlogos',            default=False, action='store_true', help='Add Font Logos Glyphs (https://github.com/Lukas-W/font-l
+    sym_font_group.add_argument('--material', '--mdi',                          dest='material',             default=False, action='store_true', help='Add Material Design Icons (https://github.com/templarian
     sym_font_group.add_argument('--octicons',                                   dest='octicons',             default=False, action='store_true', help='Add Octicons Glyphs (https://octicons.github.com)')
     sym_font_group.add_argument('--powersymbols',                               dest='powersymbols',         default=False, action='store_true', help='Add IEC Power Symbols (https://unicodepowersymbol.com/)'
     sym_font_group.add_argument('--pomicons',                                   dest='pomicons',             default=False, action='store_true', help='Add Pomicon Glyphs (https://github.com/gabrielelana/pomi
     sym_font_group.add_argument('--powerline',                                  dest='powerline',            default=False, action='store_true', help='Add Powerline Glyphs')
-    sym_font_group.add_argument('--powerlineextra',                             dest='powerlineextra',       default=False, action='store_true', help='Add Powerline Glyphs (https://github.com/ryanoasis/power
-    sym_font_group.add_argument('--weather', '--weathericons',                  dest='weather',              default=False, action='store_true', help='Add Weather Icons (https://github.com/erikflowers/weathe
+    sym_font_group.add_argument('--powerlineextra',                             dest='powerlineextra',       default=False, action='store_true', help='Add Powerline Extra Glyphs (https://github.com/ryanoasis
+    sym_font_group.add_argument('--weather',                                    dest='weather',              default=False, action='store_true', help='Add Weather Icons (https://github.com/erikflowers/weathe

     expert_group = parser.add_argument_group('Expert Options')
     expert_group.add_argument('--boxdrawing',                              dest='forcebox',         default=False, action='store_true', help='Force patching in (over existing) box drawing glyphs')

It was, together with the commit directly before it, obviously some fly-by change triggered by the fact that the options has been worked on:

Screenshot 2024-06-03 at 05 45 40

This was changed with in-parens version 4.6.0, which ended up in font-release version 3.1.0.

@ptitfred
Copy link

ptitfred commented Jun 3, 2024

Hello Finii,

Thank you for the explanation 🙇

Would it be reasonable to patch the release notes of 3.2.0 to mention those changes?

@Finii
Copy link
Collaborator Author

Finii commented Jun 3, 2024

Well, we could add a line to the 3.1.0 release notes, but that would be rather generic (Some command line options changed name), and this kind of smallish differences are usually omitted from the release notes. The notes say "these are the more important changes, see the commit log for all changes" or something, iirc.

I'm not sure how useful that change is?

Screenshot 2024-06-03 at 13 15 39

@Finii
Copy link
Collaborator Author

Finii commented Jun 3, 2024

In fact Nerd Fonts is two projects:

One is the patcher script that has its own version number (the in-parens version number) and no release notes at all - it is a rolling release and both the patcher-zip and docker image are always updated whenever a commit is merged.

The other project are the prepatched fonts, which are "the Nerd Fonts release" with the main number we mentioned above, and it uses that font-patcher version whichever was newest at the time of font-release. It ALSO includes the patcher script used for the fonts-release, but that usually becomes outdated within a week or so as new rolling releases of the patcher are created.

Anyhow, I try to generate useful release notes, but that means that not every small thing is included (for this you can have a look at the commit list - normally all commits have a meaningful title and why and how sections in the comment). This is about the balance between readability and what-to-expect from the new release versus loosing in small details that noone wants to read though.

The reason the renaming of the options did not make it were (probably):

  • Probably not used by many (if at all)
  • Change is obvious (error message is thrown)
  • Self-fixing is simple (just call for --help)

@ptitfred
Copy link

ptitfred commented Jun 3, 2024

In fact Nerd Fonts is two projects:

This is something I wasn't aware of.

I agree it is marginal usage, and that in retrospect the --help is enough.

Thank you again for the detailed explanations 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants