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

Regression from 2.0.0: icons shifted to the right #485

Closed
powerman opened this issue Jun 8, 2020 · 31 comments
Closed

Regression from 2.0.0: icons shifted to the right #485

powerman opened this issue Jun 8, 2020 · 31 comments

Comments

@powerman
Copy link
Collaborator

powerman commented Jun 8, 2020

🎯 Subject of the issue

Looks like there is a regression since 2.0.0: icons in 2.1.0 doesn't fit their boxes because they're shifted to the right.

🔧 Your Setup

Linux, urxvt with https://github.com/powerman/wcwidth-icons.
I'm using D2Coding font and initially noticed this issue while trying to use font-patcher to update to the latest version both font and icons. But I belive this issue affect all fonts - below screenshots use 3270-Medium Nerd Font Complete.otf downloaded from 1.2.0, 2.0.0 and 2.1.0 release archive.

★ Optional

URxvt*font:             xft:3270Medium Nerd Font:style=Medium:size=24
URxvt*boldFont:         xft:3270Medium Nerd Font:style=Medium:size=24
  • 3270-Medium Nerd Font Complete.otf version 1.2.0 (icons shifted left)
    3270-1 2 0-1
    3270-1 2 0-2
  • 3270-Medium Nerd Font Complete.otf version 2.0.0 (icons at right position)
    3270-2 0 0-1
    3270-2 0 0-2
  • 3270-Medium Nerd Font Complete.otf version 2.1.0 (icons shifted right)
    3270-2 1 0-1
    3270-2 1 0-2

For mentioned above D2Coding results are the same: font-patcher from 2.0.0 produce correct font, from current master produce invalid font with icons shifted to the right.

@umnyaga
Copy link

umnyaga commented Jul 1, 2020

I found similar issue, Font:"MesloLGS NF", style:regular, size:9 in putty on Windows for symbol 'f43a' (clock). It's shifted right and right portion on the glyph is truncated.

@qenya
Copy link

qenya commented Nov 8, 2020

Same issue with Fira Code and Fira Code Mono, style=Regular, with every glyph and font size I tried to use.

@Finii
Copy link
Collaborator

Finii commented Feb 4, 2023

@umnyaga and @qenya Are your issues also related to urxvt and/or wcwidth-icons.

I would need to install such a thing, I have the gut feeling that might be a wcwidth issue.

In the fonts the glyphs are all left aligned.

Maybe you can try the current v2.3.3 and tell me if it is still an issue.
If so, I would appreciate some more hints about your setup.

This F4A3 glyph in your images, it IS left aligned in the 'cell' ... 🤔 (of course that is v2.3.3)

image

@powerman
Copy link
Collaborator Author

powerman commented Feb 4, 2023

I would need to install such a thing, I have the gut feeling that might be a wcwidth issue.

This is really unlikely. The wcwidth is just one 48-line file in C (so you can easily review it), and all it does is patch wcwidth(3) result (which is int - e.g. char width 1 or 2) for some character codes.

@Finii
Copy link
Collaborator

Finii commented Feb 4, 2023

I saw the code and thought that can not be all 😬
But that is only patching the library.
This is all very shady ;-)

So if I understand correctly I build the lib, point LD_LIBRARY_PATH or LD_PRELOAD to the dir it is in and then I shall see the issue with xterm like LD_LIBRARY_PATH=/home/fini/somedir xterm -- ... what were the options to set the font? Oh my god all these X86 old school terminals remind me of 1980s and tkl/tk and HP machines :-D

I would really appreciate a dummy howto reproduce.

@powerman
Copy link
Collaborator Author

powerman commented Feb 4, 2023

Not to the dir, but to the file - as shown in wcwidth's README: export LD_PRELOAD=/usr/lib/libwcwidth-icons.so.

@powerman
Copy link
Collaborator Author

powerman commented Feb 4, 2023

Text from screenshots to reproduce:

# 
# 
# 
# ♥

@powerman
Copy link
Collaborator Author

powerman commented Feb 4, 2023

So, test command may be e.g. LD_PRELOAD=/path/to/libwcwidth-icons.so urxvt --font 'xft:3270Medium Nerd Font:style=Medium:size=24' -e vi /path/to/test-icons.txt

@powerman
Copy link
Collaborator Author

powerman commented Feb 4, 2023

As for xterm - it's probably better to avoid it. :) The option you was looking for is -fa, but it looks like xterm ignores wcwidth(3) - so LD_PRELOAD has no effect - and instead uses own algorithms for detecting char width (enabled by options -cjk_width or -mk_width). All of this works really weird at a glance and I don't believe anyone who wants nice modern icons still works in xterm. 😃

@Finii
Copy link
Collaborator

Finii commented Feb 4, 2023

Tnx for info, will check out tomorrow.

@Finii
Copy link
Collaborator

Finii commented Feb 5, 2023

Installed on Ubuntu apt install rxvt-unicode.

Created resource file ~/.Xdefaults

URxvt*foreground: Green
URxvt*background: Black

Install some fonts

cp ~/git/nerd-fonts/patched-fonts/CascadiaCode/Regular/complete/Caskaydia\ Cove\ Nerd\ Font\ Complete\ Regular.otf ~/.local/share/fonts
cp ~/git/nerd-fonts/patched-fonts/CascadiaCode/Regular/complete/Caskaydia\ Cove\ Nerd\ Font\ Complete\ Mono\ Regular.otf ~/.local/share/fonts
cp ~/git/nerd-fonts/patched-fonts/CascadiaCode/Regular/complete/Caskaydia\ Cove\ Nerd\ Font\ Complete\ Italic.otf ~/.local/share/fonts

(Using italic font to see that I really get what I want)

Running

LD_PRELOAD=/home/fini/git/wcwidth-icons/libwcwidth-icons.so urxvt --font 'xft:CaskaydiaCove Nerd Font:style=Italic:size=12' -e vi ~/testtext

image

If I switch to a size different from 12 (here 24):

image

Some symbols vanish??!

Whatever, the symbols are left aligned.
The width is only '1', though. In the bottom line I interspaced the symbols with blanks.

?

@Finii
Copy link
Collaborator

Finii commented Feb 5, 2023

Btw the 3270 name changed meanwhile, there is no Medium anymore...

$ fc-list ':charset=f4a3' | grep 'Cask|327'
/home/fini/.local/share/fonts/Caskaydia Cove Nerd Font Complete Regular.otf: CaskaydiaCove Nerd Font:style=Regular
/home/fini/.local/share/fonts/Caskaydia Cove Nerd Font Complete Italic.otf: CaskaydiaCove Nerd Font:style=Italic
/home/fini/.local/share/fonts/IBM 3270 Nerd Font Complete.ttf: 3270 Nerd Font:style=Regular
/home/fini/.local/share/fonts/Caskaydia Cove Nerd Font Complete Mono Regular.otf: CaskaydiaCove Nerd Font Mono:style=Regular

@powerman
Copy link
Collaborator Author

powerman commented Feb 5, 2023

$ fc-list ':charset=f4a3' | grep -E 'Cask|327'
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/Caskaydia Cove Nerd Font Complete Mono Regular.otf: CaskaydiaCove Nerd Font Mono:style=Regular
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/Caskaydia Cove Nerd Font Complete Italic.otf: Cas aydiaCove Nerd Font:style=Italic
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/Caskaydia Cove Nerd Font Complete Regular.otf: CaskaydiaCove Nerd Font:style=Regular
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/Caskaydia Cove Nerd Font Complete Mono Italic.otf: CaskaydiaCove Nerd Font Mono:style=Italic
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/Caskaydia Cove Nerd Font Complete Bold.otf: CaskaydiaCove Nerd Font:style=Bold
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/Caskaydia Cove Nerd Font Complete Mono Bold.otf: CaskaydiaCove Nerd Font Mono:style=Bold
/home/powerman/.local/share/fonts/NerdFonts-2.3.3/IBM 3270 Nerd Font Complete Mono.otf: 3270 Nerd Font Mono:style=Regular

Cask Mono font looks okay, except icons are small (AFAIR it's configurable at build time, but I took released fonts as is):
urxvt --font 'xft:CaskaydiaCove Nerd Font Mono:style=Italic:size=20'
image
Same for 3270 Mono:
urxvt --font 'xft:3270 Nerd Font Mono:style=Regular:size=24'
image
But Cask non-Mono shows shifted icon position (and also icons are not small anymore):
urxvt --font 'xft:CaskaydiaCove Nerd Font:style=Regular:size=20'
image
(The underlines are from vim syntax checker, forget to disable it, sorry.)

@powerman
Copy link
Collaborator Author

powerman commented Feb 5, 2023

Here is what I get using Cask Mono (one with small icons) without wc-width and without patching vim (using patch from wcwidth repo):
LD_PRELOAD= urxvt --font 'xft:CaskaydiaCove Nerd Font Mono:style=Italic:size=20'
image
and here is same command without wc-width but using patched vim (note there are no real "space" symbol between icons, while moving cursor jumps from icon right to next icon):
image

@powerman
Copy link
Collaborator Author

powerman commented Feb 5, 2023

Anyway, lets leave alone vim and it's patch (which is needed for large icons case).

  1. Non-Mono font with wcwidth: large icons, shifted.
LD_PRELOAD=/usr/lib64/libwcwidth-icons.so urxvt --font 'xft:CaskaydiaCove Nerd Font:style=Italic:size=20'

image

  1. Non-Mono font without wcwidth: large icons fit into width 1, so they overlap, some missing (maybe some side-effect of trying to fit wide icons into width 1)
LD_PRELOAD= urxvt --font 'xft:CaskaydiaCove Nerd Font:style=Italic:size=20'

image

  1. Mono font with wcwidth: small icons, okay.
LD_PRELOAD=/usr/lib64/libwcwidth-icons.so urxvt --font 'xft:CaskaydiaCove Nerd Font Mono:style=Italic:size=20'

image

  1. Mono font without wcwidth: small icons, okay (actually there is some issue with zsh prompt, but, again, this may be related to my wcwidth-expecting setup, so let's ignore it).
LD_PRELOAD= urxvt --font 'xft:CaskaydiaCove Nerd Font Mono:style=Italic:size=20'

image

P.S. Regular works mostly same way as Italic, except in case "2. Non-Mono font without wcwidth" there are much more missing icons:

LD_PRELOAD= urxvt --font 'xft:CaskaydiaCove Nerd Font:style=Regular:size=20'

image

@powerman
Copy link
Collaborator Author

powerman commented Feb 5, 2023

BTW, is I'm doing something wrong trying to use Mono font with large icons (with wcwidth lib and vim patch required to make it work)?

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

Still trying to reproduce.

If I take the simplest image from here #485 (comment)
The second case "Non-Mono font without wcwidth"

That works and looks exactly the same. Note that we see identical icons not, mostly from the F4xx range it seems:

image

Icons leak into next cell as intended, unless next cell is empty-block thing

But then, when I PRELOAD your lib (and it actually happens, see here:)

image

what urxvt shows is exactly the same as before. No change at all.

My urxvt version is this:

$ urxvt -h
rxvt-unicode (urxvt) v9.30 - released: 2021-11-27
options: perl,xft,styles,combining,blink,iso14755,unicode3,
encodings=eu+vn+jp+jp-ext+kr+zh+zh-ext,fade,transparent,
tint,pixbuf,XIM,frills,selectionscrolling,wheel,slipwheel,smart-resize,
cursorBlink,pointerBlank,scrollbars=plain+rxvt+NeXT+xterm
Usage: urxvt [-help] [--help]

Further debugging shows that neither of the two functions in your library is ever called.
I experimented a bit with the LC_ locales, but to no avail.
Also tried to build urxvt from source, but make fails with some ../libev/ev++.h that is obviously not there?
That needs to be downloaded separately, ok, trying.

Ok, builds and it DOES use your library.

But now something with loading the fonts is amiss...

image

At least they are detected as 2 cell wide now.

Ah, obviously I need to use rxvtc, but THAT again does not use wcwidth() ??!

image

Hmm, maybe it uses the system-installed rxvt demon.

@powerman
Copy link
Collaborator Author

powerman commented Feb 9, 2023

urxvtc uses already running urxvtd daemon, so it does not actually run just-installed urxvt binary, so just don't use it for testing.

$ urxvt -h
rxvt-unicode (urxvt) v9.30 - released: 2021-11-27
options: perl,xft,styles,combining,unicode3,encodings=eu+vn+jp+jp-ext+kr+zh+zh-ext,fade,transparent,tint,XIM,frills,selectionscrolling,wheel,slipwheel,cursorBlink,pointerBlank,scrollbars=plain+rxvt+NeXT+xterm
...

@powerman
Copy link
Collaborator Author

powerman commented Feb 9, 2023

And for the same reason it doesn't makes sense to set LD_PRELOAD for urxvtc, it should be set for urxvtd to have effect. Anyway, just avoid both and run only urxvt for testing.

As for missing fonts - I've no idea, but it's unlikely urxvt issue, maybe fc-cache should be executed or it's because urxvtc/urxvtd (e.g. already running urxvtd doesn't detected newly installed fonts).

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

Ah, reconfigured with --enable-everything...

image

At colors do not work but the rest looks good. At last.

ahh...

image

Now we can start actual work.

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

Some glyphs look centered but the majority looks indeed right aligned.

image

Lets find out why, because they are left aligned in the font. And what is the difference between the centered and the right aligned glyphs?

@powerman
Copy link
Collaborator Author

powerman commented Feb 9, 2023

It's also important to do final testing using Mono font built with wide icons, because it's an actual use case.

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

Ah I guess I know...
All glyphs are centered, but the wider glyphs have a right side bearing (overhang), that is rendered but not taken into account when placing.

Yes.

image

They are not right aligned, they are centered and some even extend into the next cell.

Here, the heart F004

image

The advance width is the box (which is one monospace width wide), but the visual width is of course wider.

I guess what you need is the Nerd Font Propo variant. There the glyphs do not have bearings (overhang) and advance width is the same as visual width.

See also


Let me quickly check

image

'Fixed'.

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

It's also important to do final testing using Mono font built with wide icons, because it's an actual use case.

Hmm? Mono? But that did work as far as I remember our discussion, *scroll scroll*

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

I guess I do not get the meaning of Mono in your comment.

In Nerd Font Mono all glyphs have the same width -> completely monospaced. There can be no 'wide icons'.
But you never mention Nerd Font Mono above, and there would be no issue and no need to use the wcwidth-patch (because it is strictly monospaced).

From the two fonts with 'wide' icons most clients need the 'I pretend to be monospaced' (Nerd Font without suffix), and some need the Nerd Font Propo variant which is just a normal font where all glyphs claim the space they need.

Obviously rxvt works best with

  • Nerd Font Mono (regular icon size, i.e. only as wide as X)
  • Nerd Font Propo and wcwidth-patch (increased icon size)

@powerman
Copy link
Collaborator Author

powerman commented Feb 9, 2023

I guess I do not get the meaning of Mono in your comment.

Well, when the issue was reported (2.5 years ago) there was no "Propo" thing (or at least I don't remember it), but there was Mono font which can be compiled using two ways - one with non-wide but small icons, second with large but wide icons. So, I was talking about using Mono font in second way, as it was a couple of years ago. I don't tend to update fonts unless I get some annoying "missing icon" issue, so I'm still using D2Coding font patched using Nerd's Mono wide icons.

Sounds like today I should learn how to patch D2Coding using modern Nerd's Propo to fix the issue? :)

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

Yes, 2.5 years ago was just discussions about that and what the actual requirements are, what possible solutions could be etc.

Somewhere I commented with a 'History' writeup that explains all the decisions with reasons then and in retrospect.

Nerd Font Propo is rather new, meaning it is not available prepatched, and the NAME is not even in the code, that is #1028.
As a third variant would take quite some space I would like to get rid of the Windows Compatible fonts first. In principle there is no need for them (and I never use them on Windows machines), but that also takes quite some considerations...

This will all come in v3.0.0 which is to be ready soon (for some definitions of soon ;-)

Sounds like today I should learn how to patch D2Coding using modern Nerd's Propo to fix the issue?

You can use the FontPatcher.zip from the release, or the docker image (which is up to date with master always). There should also be a zip archive in sync with master, but that is also not ready (#1044)

You just need to specify --variable when patching. Probably
fontforge font-patcher --complete --variable your-font.ttf
or
docker run --rm -v ~/myfont_dir:/in -v ~/myfontdir:/out nerdfonts/patcher --complete --variable
(You specify in and out directories and all fonts in the in dir will be patched.)

Edit: Actually link to the zip file
Edit: Correct PR number for master-font-patcher

@powerman
Copy link
Collaborator Author

powerman commented Feb 9, 2023

Used docker way, looks like everything works. Thanks!

@powerman powerman closed this as completed Feb 9, 2023
@powerman
Copy link
Collaborator Author

powerman commented Feb 9, 2023

BTW, --variable is not documented in docker's readme: https://hub.docker.com/r/nerdfonts/patcher

@Finii
Copy link
Collaborator

Finii commented Feb 9, 2023

Thanks for the feedback!

Yes. Unfortunately I have no access rights for the docker account and I can just push new versions because Ryan put the key into this repo's secrets... I also have very few right here, that prevent some clean up. But maybe at some point Ryan will have a day or so and we resolve access issues. The (his) plan was to move the project to the https://github.com/nerdfonts organization, but ... sigh.

The full font-patcher documentation is only here or on www.nerdfonts.com. Or call the docker image with --help.
I keep the websites up to date, they show only 2.2.2 but nothing changed since then, parameter-wise.

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants