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

font-patcher: Fix: Fix more 'Nerd Font Mono' too wide #1062

Merged
merged 5 commits into from
Jan 22, 2023

Conversation

Finii
Copy link
Collaborator

@Finii Finii commented Jan 21, 2023

[why]
With commit
99c2608 font-patcher: Fix more 'Nerd Font Mono' too wide

the glyphs 'ij' and 'IJ' are exempted from the advance width calculation, because some fonts (i.e. Overpass Mono) defines them as two cell wide glyphs (Hello? 'Mono'?)

For some obscure reason it was 'IJ' and 'J circumflex' that were exempt, not 'ij'.

[how]
Exempt correct code.

Fixes: #703

Requirements / Checklist

What does this Pull Request (PR) do?

How should this be manually tested?

Any background context you can provide?

What are the relevant tickets (if any)?

Screenshots (if appropriate or helpful)

[why]
With commit
  99c2608  font-patcher: Fix more 'Nerd Font Mono' too wide

the glyphs 'ij' and 'IJ' are exempted from the advance width
calculation, because some fonts (i.e. Overpass Mono) defines them as two
cell wide glyphs (Hello? 'Mono'?)

For some obscure reason it was 'IJ' and 'J circumflex' that were
exempt, not 'ij'.

[how]
Exempt correct code.

Fixes: #703

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
That feature mainlined since ... 2.2.0 or so?

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
If a font is problematic to patch as monospaced font, that is detected
but the reporting is maybe not strong enough and gets overlooked.

[how]
Pull font property reporting into dedicated functions.
Use that function additionally in other warning.

[note]
The monospace check uses all glyphs to determine the advance width, but
the actual advance width later ignores some glyphs (that are problematic
in some fonts and are thus ignored, although that glyphs will 'break'
after patching).
This might or might not be useful, I just leave it as it was before.

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

Finii commented Jan 21, 2023

Checked all fonts in src/unpatched-fonts/, one file choose at random:

find src/unpatched-fonts -iname '*.[ot]tf' | \
    sed -E 's! !\\!g;s!([^/]*/[^/]*/[^/]*).*!\0 \1!' | \
    sort | uniq -f 1 | sed 's! .*!!;s!\\! !g;s!^!"!;s!$!"!' | \
    xargs -l fontforge font-patcher -s > XXX
3270Condensed-Regular.otf                      Advance widths (base/extended): 874 - 874 / 874 - 874                                                                                                                 
agave-r.ttf                                    Advance widths (base/extended): 1024 - 1024 / 1024 - 1024
Anonymice Powerline.ttf                        Advance widths (base/extended): 1118 - 1118 / 1118 - 1118
Arimo-Bold.ttf                                 Advance widths (base/extended): 487 - 487 / 1997 - 2048
AurulentSansMono-Regular.otf                   Advance widths (base/extended): 600 - 600 / 600 - 600
BigBlue_Terminal_437TT.TTF                     Advance widths (base/extended): 800 - 800 / 800 - 800
VeraMono-Bold-Italic.ttf                       Advance widths (base/extended): 1233 - 1233 / 1233 - 1233
CascadiaCode-BoldItalic.otf                    Advance widths (base/extended): 1200 - 1200 / 1200 - 1200
Code New Roman-Bold.otf                        Advance widths (base/extended): 1126 - 1126 / 1126 - 1126
Cousine-Bold.ttf                               Advance widths (base/extended): 1229 - 1229 / 1229 - 1229
DaddyTimeMono.ttf                              Advance widths (base/extended): 588 - 588 / 588 - 588
DejaVuSansMono-Bold.ttf                        Advance widths (base/extended): 1233 - 1233 / 1233 - 1233
Droid Sans Mono for Powerline.otf              Advance widths (base/extended): 1229 - 1229 / 1229 - 1229
FantasqueSansMono-Bold.ttf                     Advance widths (base/extended): 1060 - 1060 / 1060 - 1060
FiraCode-Bold.ttf                              Advance widths (base/extended): 1200 - 1200 / 1200 - 1200
FuraMono-Bold Powerline.otf                    Advance widths (base/extended): 599 - 599 / 599 - 599
gohufont-11.ttf                                Advance widths (base/extended): 1117 - 1117 / 1117 - 1117
Go-Mono-Bold.ttf                               Advance widths (base/extended): 1229 - 1229 / 1229 - 1229
Hack-Bold.ttf                                  Advance widths (base/extended): 1233 - 1233 / 1233 - 1233
Hasklig-Black.otf                              Advance widths (base/extended): 600 - 600 / 600 - 600
heavy_data.ttf                                 Advance widths (base/extended): 351 - 351 / 2079 - 2079
Hermit-bold.otf                                Advance widths (base/extended): 617 - 617 / 707 - 707
iAWriterDuoS-Bold.ttf                          Advance widths (base/extended): 600 - 600 / 900 - 900
IBMPlexMono-BoldItalic.ttf                     Advance widths (base/extended): 600 - 600 / 600 - 600
InconsolataGo-Bold.ttf                         Advance widths (base/extended): 1024 - 1024 / 1024 - 1024
Inconsolata-Bold.otf                           Advance widths (base/extended): 500 - 500 / 500 - 500
Inconsolata-LGC-Bold.ttf                       Advance widths (base/extended): 613 - 613 / 613 - 613
iosevka-bold.ttf                               Advance widths (base/extended): 500 - 500 / 500 - 500
JetBrainsMono-BoldItalic.ttf                   Advance widths (base/extended): 600 - 600 / 600 - 600
Lekton-Bold.ttf                                Advance widths (base/extended): 500 - 500 / 500 - 500
LiberationMono-BoldItalic.ttf                  Advance widths (base/extended): 1229 - 1229 / 1229 - 1229
Lilex-Bold.otf                                 Advance widths (base/extended): 1200 - 1200 / 1200 - 1200
Meslo LG L Bold Italic for Powerline.ttf       Advance widths (base/extended): 1233 - 1233 / 1233 - 1233
Monofur Bold for Powerline.ttf                 Advance widths (base/extended): 1200 - 1200 / 1319 - 1319
Monoid-Bold.ttf                                Advance widths (base/extended): 1024 - 1024 / 1024 - 1024
mononoki-BoldItalic.ttf                        Advance widths (base/extended): 575 - 575 / 575 - 575
mplus-1c-black.ttf                             Advance widths (base/extended): 346 - 346 / 936 - 946
NotoMono-Regular.ttf                           Advance widths (base/extended): 1229 - 1229 / 1229 - 1229
OpenDyslexicAlta-BoldItalic.otf                Advance widths (base/extended): 559 - 559 / 2175 - 2264
overpass-mono-bold.otf                         Advance widths (base/extended): 616 - 616 / 616 - 1232
ProFontIIx.ttf                                 Advance widths (base/extended): 0 - 600 / 600 - 600
ProggyCleanCE.ttf                              Advance widths (base/extended): 896 - 896 / 896 - 896
RobotoMono-BoldItalic.ttf                      Advance widths (base/extended): 1202 - 1202 / 1202 - 1422
ShareTechMono-Regular.ttf                      Advance widths (base/extended): 540 - 540 / 540 - 540
SourceCodePro-BlackIt.ttf                      Advance widths (base/extended): 600 - 600 / 600 - 600
SpaceMono-BoldItalic.ttf                       Advance widths (base/extended): 612 - 612 / 612 - 612
TerminusTTF-Bold Italic-4.40.1.ttf             Advance widths (base/extended): 500 - 500 / 500 - 500
Tinos-BoldItalic.ttf                           Advance widths (base/extended): 451 - 451 / 1821 - 1933
Ubuntu-BI.ttf                                  Advance widths (base/extended): 247 - 247 / 941 - 985
UbuntuMono-BI.ttf                              Advance widths (base/extended): 500 - 500 / 500 - 500
VictorMono-BoldItalic.ttf                      Advance widths (base/extended): 599 - 599 / 600 - 600

Filtering out all standard cases we have these problematic ones:

Arimo-Bold.ttf                                 Advance widths (base/extended): 487 - 487 / 1997 - 2048  
heavy_data.ttf                                 Advance widths (base/extended): 351 - 351 / 2079 - 2079  
Hermit-bold.otf                                Advance widths (base/extended): 617 - 617 / 707 - 707    
iAWriterDuoS-Bold.ttf                          Advance widths (base/extended): 600 - 600 / 900 - 900    
Monofur Bold for Powerline.ttf                 Advance widths (base/extended): 1200 - 1200 / 1319 - 1319
mononoki-BoldItalic.ttf                        Advance widths (base/extended): 575 - 575 / 575 - 575   
mplus-1c-black.ttf                             Advance widths (base/extended): 346 - 346 / 936 - 946    
OpenDyslexicAlta-BoldItalic.otf                Advance widths (base/extended): 559 - 559 / 2175 - 2264  
overpass-mono-bold.otf                         Advance widths (base/extended): 616 - 616 / 616 - 1232   
RobotoMono-BoldItalic.ttf                      Advance widths (base/extended): 1202 - 1202 / 1202 - 1422
Tinos-BoldItalic.ttf                           Advance widths (base/extended): 451 - 451 / 1821 - 1933  
Ubuntu-RI.ttf                                  Advance widths (base/extended): 236 - 236 / 931 - 960    
VictorMono-BoldItalic.ttf                      Advance widths (base/extended): 599 - 599 / 600 - 600  

Where mononoki, Overpass, and RobotoMono are solved already.

  • Arimo ✔️ (has no NFM)
  • HeavyData ✔️ (has no NFM)
  • Hermit patched slightly too wide ✔️ Fixed with new commit
  • iA writer Duo ... should not have NFM?! ✔️
  • Monofur fixed in new commit ✔️
  • mononoki ✔️
  • M+ ✔️
  • OpenDyslexic ✔️
  • Overpass ✔️
  • Roboto Mono ✔️
  • Tinos ✔️
  • Ubuntu ✔️
  • Victormono ✔️

[why]
If a `Nerd Font Mono` font is to be created we need to make sure the
original font is indeed monospaced. If it is not and we enforce the same
adavnce width on all glyphs they will look very ugly. Fonts need to be
designed to be monospaced.

We spot check only some characteristic glyphs for that.

Hermit Bold has a problem. Although it looks more or less monospaced it
has some glyphs wider than all the others, for example the small letter
`m`.
Creating a `Nerd Font Mono` (a font where all glyphs have the same
width) will either: Add too much space to the right of all the other
(smaller) glyphs, or will have the wider glyphs cut off on the right.

[how]
Add small letter 'm' to the spot check list. Now the patcher will by
default refuse to --mono patch that font.

Also add output of first char that fails the monospace check. This makes
debugging easier.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
[why]
Although Monofur is monospaced it has one glyph (hyphen) that is
slightly wider than all others. This results in a Monospaced font that
is slightly too wide.

[how]
Ignore the hyphen width.

[note]
Additionally improve (commented out) debug code (shows now hex
codepoint).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
@Finii Finii merged commit 7493cd7 into master Jan 22, 2023
@Finii Finii deleted the bugfix/Overpass-Mono-NFM branch January 22, 2023 14:08
LNKLEO pushed a commit to LNKLEO/Nerd that referenced this pull request Nov 24, 2023
…-NFM

font-patcher: Fix: Fix more 'Nerd Font Mono' too wide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overpass Nerdfont kerning is incorrect
1 participant