nerd-fonts
nerd-fonts copied to clipboard
Hack characters stretched when font size is <= 11
🎯 Subject of the issue
When font size is below or equal to 11 the patched Hack
font is stretched and noticeably differs from original font.
Happens in terminals and native (probably gtk) font picker, but not in libre-office
🔧 Your Setup
-
Font:
Hack Regular Nerd Font Complete.ttf
-
Terminal:
xfce4-terminal
andtilda
- OS: Linux, Debian 10, xfce4
★ Optional
I attach a gif displaying this behavior:
Thanks!
I have the same exact issue too. It seem that the patched fonts size is actually 11.5 instead of 11.
Strange.
- I can not see the current
Hack Regular Nerd Font Complete.ttf
in the font chooser at all - If I prepare a patched Hack font manually, I do not see the issue:
Where did you get the Hack Regular Nerd Font Complete.ttf
that is recognized as monospaced by the font chooser?
Also strange, why does the Nerd Font show up as 'Regular' 'Bold' etc in the chooser and the original Hack isn't?
I assume you installed only the Regular
font files in both cases?
Hack Regular Nerd Font Complete.ttf
I downloaded from this repo.
It is indeed strange that Hack Nerd Font
has multiple styles - right now I see the same regular/bold/italic options, even though I have only Hack Regular Nerd Font Complete.ttf
in ~/.fonts
and fc-list
only lists Regular
also.
When recording my original gif, I probably had other original Hack variants deleted to make animation easier.
Interestingly xfce4-terminal
shows the 4 variants (although not installed thus they would be autogenerated), but still, no issue:
Let me search for a 'new' Hack Nerd Font that you could try... I believe I have some in a branch.
Could it be DPI related? Mine is at 96.
Same here. My guess was... maybe the ~~hinting~~ antialiasing goes wrong, but then I tried a lot different settings to no avail.
Let me upload the file I patched half an hour ago somewhere.
Btw, did you use the original Hack from this repo? i.e. https://github.com/ryanoasis/nerd-fonts/blob/master/src/unpatched-fonts/Hack/Regular/Hack-Regular.ttf
If you have a different original version that could also be an explanation.
So I installed that file (in this comment, top) and the patched one I put here: https://github.com/ryanoasis/nerd-fonts/blob/experimental/hack-small-size-issue/patched-fonts/Hack/Regular/complete/Hack%20Regular%20Nerd%20Font%20Complete.ttf
Maybe you want to compare these two. These are exactly the files I used.
Yes the original Hack-Regular.ttf
files are identical.
I tried with the one you linked, and issue is exactly the same.
Attaching output of font-manager's font-viewer:
Hack-Regular.ttf
:
Hack Regular Nerd Font Complete.ttf
provided by you:
I vaguely remember trying to repatch these myself, but just getting Hack through font-forge was enough to mess them up, so I eventually gave up.
It's strange that you don't see this issue.
Also, the patched fonts from this repo built in recent days do not work for me at all, probably something's wrong with them.
There are even horizontal sub-pixel changes in the 14px rendering :-o
These are your images at 400% in Gimp as layers, changing the opacity of the top image so that we can see the lower one.
And the dots move, and that by a whole pixel this is not subpixel stuff?
Maybe try if greyscale antialising fixes this? Could be that the subpixel LCD antialising assumes the wrong colour sequence? The the antialising would make it worse not better. In former times there was a way to select the colour sequence? Hmm.
Yes, hinting it is! I am using BGR anti-aliasing for my monitor, but switching to grayscale had the same issue. However, when switching from full hinting to slight in my xfce4-font settings, the issue is no longer visible.
Reproducible :tada:
I swear, I did try 'full' in the comment 2 hours ago :grimacing:
Ok. Lets see if there is something with the hinting tables.
The glyphs look unhinted, but this is contradicted by the version information that contains ttfautohint
:
instructions depend on size ... hmm.
It is the head.flags:
$ showttf ~/git/nerd-fonts/Hack\ Regular\ Nerd\ Font\ Complete_prior.ttf | grep flags
flags=1f baseline_at_0 lsb_at_0 instrs_depend_on_size ppem_to_int instr_set_width
$ showttf ~/.local/share/fonts/Hack-Regular.ttf | grep flags
flags=6 lsb_at_0 instrs_depend_on_size
If I force it to be 6 in the generated font, the Issue is gone.
diff --git a/fontforge/tottf.c b/fontforge/tottf.c
index 811711e67..dbfd1bc6d 100644
--- a/fontforge/tottf.c
+++ b/fontforge/tottf.c
@@ -3565,7 +3565,7 @@ static void redohead(struct alltabs *at) {
putlong(at->headf,at->head.revision);
putlong(at->headf,at->head.checksumAdj);
putlong(at->headf,at->head.magicNum);
- putshort(at->headf,at->head.flags);
+ putshort(at->headf, 6);
putshort(at->headf,at->head.emunits);
putlong(at->headf,at->head.createtime[1]);
putlong(at->headf,at->head.createtime[0]);
Let's see how we can influence the flags in an official way ;-)
Maybe something like this?
from fontTools import ttLib
originalTTF = ttLib.TTFont("Hack-Regular.ttf")
patchedTTF = ttLib.TTFont("Hack Regular Nerd Font Complete.ttf")
patchedTTF['head'].flags = originalTTF['head'].flags
patchedTTF.save("Hack Regular Nerd Font Complete Fixed.ttf")
Yes, almost. And we also need to copy the lowestRecPPEM
.
And then I do not like to pull another dependency in that all users of font-patcher
would need.
Rather something like this ;)
source = TableHEADWriter(sys.argv[1])
source.calc_table_checksum(True)
source.close()
dest = TableHEADWriter(sys.argv[2])
dest.calc_table_checksum(True)
dest.calc_full_checksum(True)
if source.flags & 0x08 == 0 and dest.flags & 0x08 != 0:
print("Changing flags from 0x{:X} to 0x{:X}".format(dest.flags, dest.flags & ~0x08))
dest.putshort(dest.flags & ~0x08, 'flags') # clear 'ppem_to_int'
if source.lowppem != dest.lowppem:
print("Changing lowestRecPPEM from {} to {}".format(dest.lowppem, source.lowppem))
dest.putshort(source.lowppem, 'lowestRecPPEM')
if dest.modified:
print("Correcting checksums")
dest.reset_table_checksum()
dest.reset_full_checksum()
else:
print("Nothing to be done")
dest.close()
Where TableHEADWriter
is just a small class without dependencies.
After the holdidays today normal work begun so time dwindles away... :roll_eyes:
Autoclosing by the PR #761 did not work, doing manually now.
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a new issue, complete the issue template with all the details necessary to reproduce, and mention this issue as reference.