ryanoasis / nerd-fonts

Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more
https://NerdFonts.com
Other
52.68k stars 3.59k forks source link

Patched Terminess fonts still blurry #1329

Closed Slabity closed 3 months ago

Slabity commented 11 months ago

🗹 Requirements

(Note that there are some older issues reported for this, but are locked for being stale)

🎯 Subject of the issue

Experienced behavior: Decided to try using the patched Terminess fonts again since #329 was patched, but the font still looks blurry.

Here's a screenshot of the current, patched font at 10px:

image

Expected behavior:

Here's a screenshot of the unpatched font, also at 10px:

image

(Note the size doesn't affect the blurriness, it's blurry at all sizes).

Also, it looks fine when I patch it manually myself (this one is 8px though):

image

Example symbols: Pretty much all of them.

🔧 Your Setup

★ Screenshots (Optional)

Posted above in behavior sections

Slabity commented 11 months ago

I'm mostly creating this issue because I can patch the fonts manually, but I can't seem to figure out how to fix the actual repo to get clean bitmap fonts. I think it might be the same issue as #1174 for AnonymousPro, but I'm not sure what the fix in #1175 actually does to resolve it.

I wouldn't be surprised if a few other bitmap fonts are having the same issue.

Finii commented 11 months ago

Thanks for reporting. Can you provide the output of the patcher with --debug 2 which will help me see some detail.

I'm mostly creating this issue because I can patch the fonts manually

How do you do that?

The AnonymousPro issue was that we used a font without bitmaps as source, of course there are no bitmaps than in the patched version. Changing to a AnonymousPro-with-bitmaps resulted in a patched AnonymousPro with bitmaps :grimacing:

The unpatched Terminus source we use seems to have bitmaps...:

image

and so does the patched font...:

image

Slabity commented 11 months ago

@Finii - Sure, I can replicate this by using the ter-u12n.otb file that came in the terminus-font-4.49.1 package that NixOS provides and just ran nerd-font-patcher ter-u12n.otb without any extra options:

[nix-shell:~]$ cp /nix/store/r3hizlibf6bv79ydaxyd9chfsp1783yl-terminus-font-4.49.1/share/fonts/terminus/ter-u12n.otb .

[nix-shell:~]$ chmod +w ter-u12n.otb

[nix-shell:~]$ nerd-font-patcher ter-u12n.otb
No configfile given, skipping configfile related actions
Nerd Fonts Patcher v2.2.2 (3.0.5) executing

Adding 59 Glyphs from Seti-UI + Custom Set
╢████████████████████████████████████████╟ 100%
Adding 198 Glyphs from Devicons Set
╢████████████████████████████████████████╟ 100%

Done with Patch Sets, generating font...

Changing lowestRecPPEM from 8 to 12

Generated: Terminess Regular Nerd Font in './Terminess Regular Nerd Font.otb'

And the result is this:

image

Note that I have tried playing with my system's fontconfig settings and toggling anti-aliasing and hinting in any combination didn't make it any better.

Maybe the difference is using the TerminessTTF as the base? I could try using that and see what happens.

EDIT: Can't seem to run with that debug option: nerd-font-patcher: error: unrecognized arguments: --debug 2 (same with --debug=2)

Finii commented 11 months ago

Can't seem to run with that debug option

Your patcher is too old Nerd Fonts Patcher v2.2.2 (3.0.5) executing, current is v3.0.2 (4.4.2).

Finii commented 11 months ago

I guess (gut feeling) that alacritty uses the outlines in the font if they are available and uses the bitmaps only if there are no outlines? The ttf font does have bitmaps and outlines, the otb is just bitmaps?

Slabity commented 11 months ago

Can't seem to run with that debug option

Your patcher is too old Nerd Fonts Patcher v2.2.2 (3.0.5) executing, current is v3.0.2 (4.4.2).

Huh, the fonts themselves are v3.0.2 in NixOS, but not the patcher. That's odd. I'll take a look and try to get the patcher updated for this distro.

I guess (gut feeling) that alacritty uses the outlines in the font if they are available and uses the bitmaps only if there are no outlines? The ttf font does have bitmaps and outlines, the otb is just bitmaps?

The screenshots are actually from font-manager, not alacritty, so it doesn't seem to be just a single program. I'll try again with both TerminessTTF and Terminess Powerline and see if either of those have the same issue. At least, after I update the patcher.

Finii commented 11 months ago

I would use

Slabity commented 11 months ago

Alright, so apparently we did have 3.0.2 in Nixpkgs, but I mistakenly used an out of date version. Here is the output of the current one:

$ nerd-font-patcher --debug 2 ter-u12n.otb
Nerd Fonts Patcher v3.0.2 (4.4.0) (ff 20230101)
DEBUG: Naming mode 1
DEBUG: Monospace check: Panose says "monospaced"; glyph-width-mono True
DEBUG: Final font cell dimensions 512 w x 1024 h
DEBUG: 150/160 box drawing glyphs will be replaced
Adding 180 Glyphs from Seti-UI + Custom Set
╢████████████████████████████████████████╟ 100%
Adding 6 Glyphs from Heavy Angle Brackets Set
╢████████████████████████████████████████╟ 100%
Adding 160 Glyphs from Box Drawing Set
╢████████████████████████████████████████╟ 100%
Adding 198 Glyphs from Devicons Set
╢████████████████████████████████████████╟ 100%
Done with Patch Sets, generating font...
DEBUG: =====> Family (ID 1)      ok       (19 <=31): Terminess Nerd Font
DEBUG: =====> SubFamily (ID 2)   ok       ( 7 <=31): Regular
DEBUG: =====> Fullname (ID 4)    ok       (19 <=63): Terminess Nerd Font
DEBUG: =====> PSN (ID 6)         ok       (19 <=63): TerminessNF-Regular
DEBUG: Preserving bitmaps (12,)
   Terminess Nerd Font
   \===> 'TerminessNerdFont-Regular.otb'

Oddly enough, now the output seems to be blurry:

image

I do notice that the font sizes are not integer based. For some reason I can only select 8.2, 8.7, 9.2, 9.7, 10.2, etc. Perhaps related? (Note, I can "force" 10px, but doesn't make any difference, still has that slight blur)

The fact that the output of v2.2.2 did not look blurry is also interesting, and perhaps provides a bit more info on what the issue might be?

EDIT: I get the same blurry result when patching TerminusTTF. Here's the debug output:

$ nerd-font-patcher --debug 2 TerminusTTF.ttf
Nerd Fonts Patcher v3.0.2 (4.4.0) (ff 20230101)
DEBUG: Naming mode 1
The glyph named Tcommaaccent is mapped to U+021A.
But its name indicates it should be mapped to U+0162.
The glyph named tcommaaccent is mapped to U+021B.
But its name indicates it should be mapped to U+0163.
The glyph named Delta is mapped to U+0394.
But its name indicates it should be mapped to U+2206.
The glyph named Omega is mapped to U+03A9.
But its name indicates it should be mapped to U+2126.
DEBUG: Monospace check: Panose says "monospaced"; glyph-width-mono True
INFO: Redistributing line gap of 90 (45 top and 45 bottom)
DEBUG: Extended glyphs wider bounding box than basic glyphs
DEBUG: Final font cell dimensions 500 w x 1090 h
DEBUG: 150/160 box drawing glyphs will be replaced
Adding 180 Glyphs from Seti-UI + Custom Set
╢████████████████████████████████████████╟ 100%
Adding 6 Glyphs from Heavy Angle Brackets Set
╢████████████████████████████████████████╟ 100%
Adding 160 Glyphs from Box Drawing Set
╢████████████████████████████████████████╟ 100%
Adding 198 Glyphs from Devicons Set
╢████████████████████████████████████████╟ 100%
Done with Patch Sets, generating font...
DEBUG: =====> Family (ID 1)      ok       (19 <=31): Terminess Nerd Font
DEBUG: =====> SubFamily (ID 2)   ok       ( 7 <=31): Regular
DEBUG: =====> Fullname (ID 4)    ok       (19 <=63): Terminess Nerd Font
DEBUG: =====> PSN (ID 6)         ok       (11 <=63): TerminessNF
DEBUG: Preserving bitmaps (12, 14, 16, 18, 20, 22, 24, 28, 32)
DEBUG: Tweaking 1/1
   Terminess Nerd Font
   \===> 'TerminessNerdFont-Regular.ttf'

Let me know if you'd like any other information or anything I should try.

Finii commented 11 months ago

Thanks for the investigation!

I do notice that the font sizes are not integer based. For some reason I can only select 8.2, 8.7, 9.2, 9.7, 10.2, etc

That is, in font manager? Which font-manager is it, I believe there are multiple different almost same-named ones ;-)

I must confess I personally never use bitmap fonts and my knowledge about bitmap fonts is centuries old (i.e. before ttf and / or when X was more or less bitmap fonts only). But I will try to find something out. In the light of the changed selectable sizes I fear it might be fontforge has yet another bug.

Finii commented 11 months ago

Hmm, looks similar but slightly different :grimacing:

image

Edit:

Ahh, dark theme...

image

Slabity commented 11 months ago

The font-manager package in Nixpkgs appears to be version 0.8.8 of FontManager/font-manager. I think all of those screenshots might be the same app with different themes. I'm specifically using arc-dark, while the two you have might be the default light and dark themes.

Though I can confirm the same result in alacritty as well, so it's not just the GTK applications. Here's the two versions side-by-side:

image

There's a difference in both the characters and the spacing from the looks of it. I'm not certain both font-manager and alacritty use the same font-rendering backend, but if you know of another app I should try I can do that as well.

EDIT: Also, just in case it might have been an issue with the nerdfonts package in Nixpkgs, I can also confirm the blurriness exists on the patched font directly from the Git repo itself.

Slabity commented 11 months ago

Just to add another datapoint for a different font renderer, here is Firefox rendering the different versions of the font. Only the Nerd Fonts version has the blur:

image

Not sure what other apps I can use to see if it's a rendering issue or not. Unfortunately my knowledge of how fonts, font rendering, and how the font patcher works is next to nothing.

herself commented 7 months ago

Found this issue while having the same exact problem as OP, managed to figure a workaround. I'll post it in case someone else stumbles here:

2023-12-06-010411

Had to change the font.offset.y to -2 in Alacritty to achieve the same effect and adjust the exact font size according to the table below, but at this point I'm just glad it works :smile_cat:

    12 px or 9 pt
    14 px or 10.5 pt
    16 px or 12 pt
    18 px or 13.5 pt
    20 px or 15 pt
    22 px or 16.5 pt
    24 px or 18 pt
    28 px or 21 pt
    32 px or 24 pt
Finii commented 7 months ago

Thanks for the feedback @herself I will look into it before 3.2.

Finii commented 3 months ago

@allcontributors please add @Slabity for bug

allcontributors[bot] commented 3 months ago

@Finii

I've put up a pull request to add @Slabity! :tada:

Finii commented 3 months ago

In fact I do not really know if that solves @Slabity blurryness problem. At least the outlines are broken in the version we had.

It can also be a hinting problem, if the embedded bitmaps are not used. Ah, yes, the font seems to be unhinted:

image

If your problem persists I can try and throw ttfautohint unto the font, and then you can try that font. Please let me know :-)

Finii commented 3 months ago

Ah yes...

image

Hmm, but ... of course the original also has no hints, so that should not be the problem. Maybe the bitmap part of the font is still broken. And/or the renderer switches to outlines if not all glyphs are available as bitmaps. My knowledge of bitmap fonts is not very good (next to nonexisting)

You use alacritty, I guess I have that installed (i.e. have it self-built somewhere, lets see)

image

testing

On my machine even the unpatched font is unsharp in alacritty:

image

Interestingly alacritty ignores the system wide hinting and antialiasing setting. Turned off everything system wide, see how bad the window titles and tilix text window looks now, but alacritty does what it wants :roll_eyes:

image

tbc

Finii commented 3 months ago

Alacritty seems to have 'a problem' when a font is not all-bitmaps it will switch to LCD subpixel rendering and there is no way to prevent that?

See for example

Maybe they fixed it in the meantime, but not having an option to influence antialiasing (subpixel rendering) is a strange choice.

If this is the problem we can not do anything about it. You can patch your alacritty source like described in the linked Issue, to turn the unwanted antialiasing off and get sharp glyphs back. If that works at all.

I guess bitmap fonts and patching just does not blend very well.

Slabity commented 3 weeks ago

@Finii - I don't think this is fixed. I'm seeing the same results on v3.2.1