Powerlevel10k glyphs overlap #264

Closed
opened 1 year ago by zsolt-donca · 9 comments

The zsh theme powerlevel10k heavily relies on glyphs, and even has a step in its configure command that lets you check whether your terminal correctly displays them. The issue is that in foot these glyphs seem to be of the wrong size and overlapping, as visible on the screenshot below (left is foot, right is alacritty for reference):

image

For the record, besides alacritty, the terminal kitty also display these glyphs correctly, but other terminals such as gnome-terminal and terminator don't.

I am using foot version: 1.6.2 +ime, installed from the AUR on Arch Linux. The above screenshot was made using the font MesloLGS Nerd Font.

The zsh theme [powerlevel10k](https://github.com/romkatv/powerlevel10k) heavily relies on glyphs, and even has a step in its configure command that lets you check whether your terminal correctly displays them. The issue is that in foot these glyphs seem to be of the wrong size and overlapping, as visible on the screenshot below (left is foot, right is alacritty for reference): ![image](/attachments/2483231e-4f92-4305-a283-b4c9c577d98d) For the record, besides `alacritty`, the terminal `kitty` also display these glyphs correctly, but other terminals such as `gnome-terminal` and `terminator` don't. I am using `foot version: 1.6.2 +ime`, installed from the [AUR](https://aur.archlinux.org/packages/foot/) on Arch Linux. The above screenshot was made using the font `MesloLGS Nerd Font`.
487 KiB
dnkl commented 1 year ago
Owner

I assume those glyphs between the X are supposed to be loaded from MesloLGS Nerd Font? If so, can you verify that really is the primary font is using (run foot from another terminal and check its log output).

If that is indeed the primary font, check that those glyphs are loaded from it, by starting foot (again, from another terminal), like this: foot sh, then paste some of the glyphs into foot. If there are no other fonts loaded (as seen in the log output) when you paste the glyphs, then they are loaded from the primary font.

I assume those glyphs between the `X` are supposed to be loaded from `MesloLGS Nerd Font`? If so, can you verify that really is the primary font is using (run foot from another terminal and check its log output). If that is indeed the primary font, check that those glyphs are loaded from it, by starting foot (again, from another terminal), like this: `foot sh`, then paste some of the glyphs into foot. If there are no other fonts loaded (as seen in the log output) when you paste the glyphs, then they are loaded from the primary font.
Poster

I think the font is loaded correctly. Both suggestions print pretty much the same thing, and I got the below output with nothing printed in it after I pasted the line with the glyphs:

❯ foot sh       
info: main.c:356: version: 1.6.2 +ime
info: main.c:363: arch: x86_64/64-bit
info: main.c:367: locale: en_US.UTF-8
info: config.c:2081: loading configuration from /home/zdonca/.config/foot/foot.ini
info: wayland.c:1142: eDP-1: 3840x2160+0x0@60Hz 0x14B9 15.33" scale=2 PPI=295x308 (physical) PPI=147x154 (logical), DPI=287.32
info: wayland.c:1288: requesting SSD decorations
info: fcft.c:256: fcft: 2.3.2 +graphemes
info: fcft.c:266: fontconfig: 2.13.91
info: fcft.c:272: freetype: 2.10.4
info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Bold Italic Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32
info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Italic Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32
info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Bold Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32
info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Regular Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32
info: terminal.c:632: cell width=19, height=40
info: terminal.c:570: using 16 rendering threads
info: wayland.c:700: using SSD decorations
info: wayland.c:1434: cursor theme: (null), size: 24, scale: 2

And it produced this image:
image

The only non-commented parts in my config are as follows:

font=MesloLGS Nerd Font
dpi-aware=yes

Btw, I have the same font set as my system-default monospaced font, and these glyphs look fine for me in the browser as well (which is Chromium):

--->  XXXXXXXXX  <---

And it looks like this:
image

I think the font is loaded correctly. Both suggestions print pretty much the same thing, and I got the below output with nothing printed in it after I pasted the line with the glyphs: ``` ❯ foot sh info: main.c:356: version: 1.6.2 +ime info: main.c:363: arch: x86_64/64-bit info: main.c:367: locale: en_US.UTF-8 info: config.c:2081: loading configuration from /home/zdonca/.config/foot/foot.ini info: wayland.c:1142: eDP-1: 3840x2160+0x0@60Hz 0x14B9 15.33" scale=2 PPI=295x308 (physical) PPI=147x154 (logical), DPI=287.32 info: wayland.c:1288: requesting SSD decorations info: fcft.c:256: fcft: 2.3.2 +graphemes info: fcft.c:266: fontconfig: 2.13.91 info: fcft.c:272: freetype: 2.10.4 info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Bold Italic Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32 info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Italic Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32 info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Bold Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32 info: fcft.c:716: /usr/share/fonts/TTF/Meslo LG S Regular Nerd Font Complete.ttf: size=8.00pt/31px, dpi=287.32 info: terminal.c:632: cell width=19, height=40 info: terminal.c:570: using 16 rendering threads info: wayland.c:700: using SSD decorations info: wayland.c:1434: cursor theme: (null), size: 24, scale: 2 ``` And it produced this image: ![image](/attachments/7739349e-1e1c-4719-a3fb-ecdd4917960c) The only non-commented parts in my config are as follows: ``` font=MesloLGS Nerd Font dpi-aware=yes ``` Btw, I have the same font set as my system-default monospaced font, and these glyphs look fine for me in the browser as well (which is Chromium): ``` ---> XXXXXXXXX <--- ``` And it looks like this: ![image](/attachments/233eac40-d852-4617-9a1c-2206b0bdf1fc)
dnkl commented 1 year ago
Owner

Hmm, the symbols are obviously much larger in foot. I'll take a look; perhaps there is a downscaling issue in fcft (foot's font rasterizing library).

Hmm, the symbols are obviously much larger in foot. I'll take a look; perhaps there is a downscaling issue in fcft (foot's font rasterizing library).
dnkl commented 1 year ago
Owner

I installed ttf-meslo-nerd-font-powerlevel10k from AUR, and it looks much better than in your screenshots (see attached screenshot).

I'm wondering if perhaps you are using an older version of the patched Meslo font?

Now, some of the glyphs are still getting clipped a bit, but that's because they are overflowing into their neighbouring cells. I.e. they are still a bit too large. The clock is one example of that.

All these glyphs are just "regular" font glyphs; i.e. to fcft they are just like regular letters. This is opposed to them being e.g. colored emojis. In other words, it is up to the font to ensure these glyphs are sized correctly.

Many terminals have more or less issues with overflowing glyphs. Alacritty is one of the better ones, simply because it always re-renders the entire screen (whereas e.g. foot only draws the cells that has changed since the last rendered frame). See #207 and #261 for more information.

I also tested kitty, which besides having some weird sizing issues with the glyphs, also clipped them in ways similar to foot.

I installed [ttf-meslo-nerd-font-powerlevel10k](https://aur.archlinux.org/packages/ttf-meslo-nerd-font-powerlevel10k/) from AUR, and it looks much better than in your screenshots (see attached screenshot). I'm wondering if perhaps you are using an older version of the patched Meslo font? Now, some of the glyphs are still getting clipped a bit, but that's because they are overflowing into their neighbouring cells. I.e. they are still a bit too large. The clock is one example of that. All these glyphs are just "regular" font glyphs; i.e. to fcft they are just like regular letters. This is opposed to them being e.g. colored emojis. In other words, it is up to the font to ensure these glyphs are sized correctly. Many terminals have more or less issues with overflowing glyphs. Alacritty is one of the better ones, simply because it always re-renders the entire screen (whereas e.g. foot only draws the cells that has changed since the last rendered frame). See https://codeberg.org/dnkl/foot/issues/207 and https://codeberg.org/dnkl/foot/issues/261 for more information. I also tested kitty, which besides having some weird sizing issues with the glyphs, also clipped them in ways similar to foot.
dnkl commented 1 year ago
Owner

Reading through issues in powerline10k, I stumbled upon this https://github.com/romkatv/powerlevel10k/issues/571#issuecomment-601650834:

If you want large icons, you need to use a non-monospace font. Here "non-monospace" refers to any font with glyphs wider than a single column, or wider than two columns for glyphs designated as "wide" in the Unicode standard. The easiest way to get a non-monospace terminal font is to download a ttf file without " Mono" in its name from https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/. For example, here's non-monospace regular Meslo from Nerd Fonts: Meslo LG S Regular Nerd Font Complete Windows Compatible.ttf.

That font name matches yours... are you sure you are using a monospaced font?

Finally, it should be possible to workaround the remaining clipping issues in foot by using a non-patched font as primary font (i.e. it must not have the custom symbols), and then use a patched font as a fallback font, using a slightly smaller font size. I.e. something like this, in foot.ini:

font=Meslo:size=8,MesloLGS NF:size=7

You are not limited to integer sizes; i.e. you can fine tune your fallback font's size to, for example, size=8.5.

Reading through issues in powerline10k, I stumbled upon this https://github.com/romkatv/powerlevel10k/issues/571#issuecomment-601650834: > If you want large icons, you need to use a non-monospace font. Here "non-monospace" refers to any font with glyphs wider than a single column, or wider than two columns for glyphs designated as "wide" in the Unicode standard. The easiest way to get a non-monospace terminal font is to download a ttf file without " Mono" in its name from https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/. For example, here's non-monospace regular Meslo from Nerd Fonts: Meslo LG S Regular Nerd Font Complete Windows Compatible.ttf. That font name matches yours... are you sure you are using a **monospaced** font? Finally, it should be possible to workaround the remaining clipping issues in foot by using a **non-patched** font as primary font (i.e. it **must** not have the custom symbols), and then use a **patched** font as a fallback font, using a slightly smaller font size. I.e. something like this, in `foot.ini`: ``` font=Meslo:size=8,MesloLGS NF:size=7 ``` You are not limited to integer sizes; i.e. you can fine tune your fallback font's size to, for example, `size=8.5`.
dnkl commented 1 year ago
Owner

Well, almost, but not quite: Meslo LG S:size=10,MesloLGS NF:size=8.5

There's still some clipping on the left side, because the font uses negative offsets for e.g. the clock glyph.

Unfortunately, it's not that much more we can do about this :/

Well, almost, but not quite: `Meslo LG S:size=10,MesloLGS NF:size=8.5` There's still some clipping on the left side, because the font uses negative offsets for e.g. the clock glyph. Unfortunately, it's not that much more we can do about this :/
Poster

Thanks, @dnkl for your prompt answer!

It seems fonts are much more difficult than I thought. :P

You were right on the spot:

That font name matches yours... are you sure you are using a monospaced font?

I was indeed using the nerd-fonts through the nerd-fonts-meslo AUR package. I did not realize that I wasn't fully following the powerlevel10k instructions (if I did, I would have mentioned it). The font I was using was indeed the non-monospaced variant of the otherwise monospaced font, with the glyphs made larger for the large icons effect.

You are not limited to integer sizes; i.e. you can fine tune your fallback font's size to, for example, size=8.5.
Well, almost, but not quite: Meslo LG S:size=10,MesloLGS NF:size=8.5

This indeed makes the "icon" glyphs better, but it unfortunately breaks the powerline icons in other places, such as in Vim:

image

What I found to work the best is using the truly monospaced version of my original font, that is, MesloLGS Nerd Font Mono (once again, from nerd-fonts through the nerd-fonts-meslo AUR package), which makes the glyphs look like this:

image

The only downside is that the icons look slightly smaller, but there is absolutely no clipping or anything. The powerline glyphs in Vim also look perfect. I wonder why don't the powerlevel10k people advertise this font instead, while with their own many terminals difficulties, just as you confirmed above.

In my opinion, this issue is mostly resolved: foot does not allow overlapping and bleeding of the fonts at all; I was using a font that had larger glyphs than normal (the font was not truly monospaced), and that's the reason for the clipping. Disallowing overlapping is understandable, so I don't think that this is a bug in any way with foot. If you also agree, then this issue can be closed.

I just have one last idea: what do you think of adding some kind of a warning to the readme of the project to warn people of clipping issues such as this?

Thanks again, @dnkl, and happy holidays!

Thanks, @dnkl for your prompt answer! It seems fonts are much more difficult than I thought. :P You were right on the spot: > That font name matches yours... are you sure you are using a monospaced font? I was indeed using the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) through the [nerd-fonts-meslo AUR package](https://aur.archlinux.org/packages/nerd-fonts-meslo/). I did not realize that I wasn't fully following the powerlevel10k instructions (if I did, I would have mentioned it). The font I was using was indeed the non-monospaced variant of the otherwise monospaced font, with the glyphs made larger for the large icons effect. > You are not limited to integer sizes; i.e. you can fine tune your fallback font's size to, for example, size=8.5. > Well, almost, but not quite: Meslo LG S:size=10,MesloLGS NF:size=8.5 This indeed makes the "icon" glyphs better, but it unfortunately breaks the powerline icons in other places, such as in Vim: ![image](/attachments/5b90fbf8-28d1-4f09-8d5b-e9e29fd0b65a) What I found to work the best is using the truly monospaced version of my original font, that is, `MesloLGS Nerd Font Mono` (once again, from [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) through the [nerd-fonts-meslo AUR package](https://aur.archlinux.org/packages/nerd-fonts-meslo/)), which makes the glyphs look like this: ![image](/attachments/06a1c5d3-765d-4636-a1aa-1006e2c1f272) The only downside is that the icons look slightly smaller, but there is absolutely no clipping or anything. The powerline glyphs in Vim also look perfect. I wonder why don't the powerlevel10k people advertise this font instead, while with their own many terminals difficulties, just as you confirmed above. In my opinion, this issue is mostly resolved: foot does not allow overlapping and bleeding of the fonts at all; I was using a font that had larger glyphs than normal (the font was not truly monospaced), and that's the reason for the clipping. Disallowing overlapping is understandable, so I don't think that this is a bug in any way with foot. If you also agree, then this issue can be closed. I just have one last idea: what do you think of adding some kind of a warning to the readme of the project to warn people of clipping issues such as this? Thanks again, @dnkl, and happy holidays!
dnkl commented 1 year ago
Owner

The powerline glyphs in Vim also look perfect. I wonder why don't the powerlevel10k people advertise this font instead, while with their own many terminals difficulties, just as you confirmed above.

Good question. My best guess is they prefer the larger icons (because it works in "their" terminal(s)?). I don't really see any other reasons....

Glad you got it working, and thanks for posting a follow up!

> The powerline glyphs in Vim also look perfect. I wonder why don't the powerlevel10k people advertise this font instead, while with their own many terminals difficulties, just as you confirmed above. Good question. My best guess is they prefer the larger icons (because it works in "their" terminal(s)?). I don't really see any other reasons.... Glad you got it working, and thanks for posting a follow up!
dnkl closed this issue 1 year ago
dnkl added the
not-a-bug
label 1 year ago
dnkl commented 1 year ago
Owner

what do you think of adding some kind of a warning to the readme of the project to warn people of clipping issues such as this?

It is (somewhat) documented in the wiki, although I guess we could stress the fact that foot clips glyphs.

https://codeberg.org/dnkl/foot/wiki#user-content-emojis-get-cut-off

Feel free to submit updates to it :)

It can't be edited inline by users, but you can clone its repo and then submit a patch to me, either via email, or attach a patch to an issue.

> what do you think of adding some kind of a warning to the readme of the project to warn people of clipping issues such as this? It is (somewhat) documented in the wiki, although I guess we could stress the fact that foot clips glyphs. https://codeberg.org/dnkl/foot/wiki#user-content-emojis-get-cut-off Feel free to submit updates to it :) It can't be edited inline by users, but you can clone its repo and then submit a patch to me, either via email, or attach a patch to an issue.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.