For lower font sizes, rapidly changing text leaves speckles on the screen #21

Closed
opened 1 year ago by drv28 · 5 comments
drv28 commented 1 year ago

Foot version:

foot version 1.3.0-69-gbd565fe (Jun 01 2020, branch 'master')

Running on compositor:

sway version 1.4

Steps to reproduce:

  • Run cmatrix.
  • Decrease the font size, let cmatrix run for a few seconds, then notice red or blue coloured speckles on the screen.
  • Repeat previous step to notice even more speckles.
### Foot version: `foot version 1.3.0-69-gbd565fe (Jun 01 2020, branch 'master')` ### Running on compositor: `sway version 1.4` ### Steps to reproduce: * Run `cmatrix`. * Decrease the font size, let `cmatrix` run for a few seconds, then notice red or blue coloured speckles on the screen. * Repeat previous step to notice even more speckles.
dnkl commented 1 year ago
Owner
  • Which font(s) are you using?
  • Do you run cmatrix as is, or with non-default options?
  • Do you have antialiasing enabled?
  • If so, grayscale or subpixel?
  • Can you post the log output from foot when running cmatrix?
* Which font(s) are you using? * Do you run `cmatrix` as is, or with non-default options? * Do you have antialiasing enabled? * If so, grayscale or subpixel? * Can you post the log output from foot when running `cmatrix`?
Poster

Which font(s) are you using?

mononoki Nerd Font(https://aur.archlinux.org/packages/nerd-fonts-mononoki/) and Noto Sans Mono. Speckling is
more prominent in the former.

Do you run cmatrix as is, or with non-default options?

I run cmatrix without giving any options.

Do you have antialiasing enabled?

I changed only the font in the default config. All other options are defaults. How can I check whether antialiasing is enabled?

Can you post the log output from foot when running cmatrix?

Log of foot while running cmatrix and decreasing font size:

info: main.c:306: version: 1.3.0-69-gbd565fe (Jun 01 2020, branch 'master')
info: config.c:949: loading configuration from /home/rishabh/.config/footrc
info: main.c:315: locale: en_US.UTF-8
info: wayland.c:841: LVDS-1: 1366x768+0x0@60Hz 0x45EC 15.33" scale=1 PPI=105x109 (physical) PPI=105x109 (logical)
info: wayland.c:877: cursor theme: (null), size: 24
info: wayland.c:1071: requesting SSD decorations
info: fcft.c:139: fontconfig: 2.13.91
info: fcft.c:145: freetype: 2.10.2
info: fcft.c:522: info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=12.00pt/18px, dpi=109
info: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=12.00pt/18px, dpi=109
fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=12.00pt/18px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=12.00pt/18px, dpi=109
info: terminal.c:548: cell width=11, height=26
info: terminal.c:482: using 4 rendering threads
info: wayland.c:507: using SSD decorations
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.50pt/17px, dpi=109
info: fcft.c:522: info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.50pt/17px, dpi=109
/usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.50pt/17px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.50pt/17px, dpi=109
info: terminal.c:548: cell width=10, height=24
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.00pt/16px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.00pt/16px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.00pt/16px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.00pt/16px, dpi=109
info: terminal.c:548: cell width=10, height=23
info: fcft.c:522: info: fcft.c:522: info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.50pt/15px, dpi=109
/usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.50pt/15px, dpi=109
/usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.50pt/15px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.50pt/15px, dpi=109
info: terminal.c:548: cell width=9, height=22
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.00pt/15px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.00pt/15px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.00pt/15px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.00pt/15px, dpi=109
info: terminal.c:548: cell width=9, height=22
info: fcft.c:522: info: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=9.50pt/14px, dpi=109
fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=9.50pt/14px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=9.50pt/14px, dpi=109
info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=9.50pt/14px, dpi=109
info: terminal.c:548: cell width=8, height=20
info: main.c:445: goodbye
> Which font(s) are you using? `mononoki Nerd Font`(https://aur.archlinux.org/packages/nerd-fonts-mononoki/) and `Noto Sans Mono`. Speckling is more prominent in the former. > Do you run `cmatrix` as is, or with non-default options? I run `cmatrix` without giving any options. > Do you have antialiasing enabled? I changed only the font in the default config. All other options are defaults. How can I check whether antialiasing is enabled? > Can you post the log output from foot when running cmatrix? Log of `foot` while running cmatrix and decreasing font size: ``` info: main.c:306: version: 1.3.0-69-gbd565fe (Jun 01 2020, branch 'master') info: config.c:949: loading configuration from /home/rishabh/.config/footrc info: main.c:315: locale: en_US.UTF-8 info: wayland.c:841: LVDS-1: 1366x768+0x0@60Hz 0x45EC 15.33" scale=1 PPI=105x109 (physical) PPI=105x109 (logical) info: wayland.c:877: cursor theme: (null), size: 24 info: wayland.c:1071: requesting SSD decorations info: fcft.c:139: fontconfig: 2.13.91 info: fcft.c:145: freetype: 2.10.2 info: fcft.c:522: info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=12.00pt/18px, dpi=109 info: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=12.00pt/18px, dpi=109 fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=12.00pt/18px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=12.00pt/18px, dpi=109 info: terminal.c:548: cell width=11, height=26 info: terminal.c:482: using 4 rendering threads info: wayland.c:507: using SSD decorations info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.50pt/17px, dpi=109 info: fcft.c:522: info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.50pt/17px, dpi=109 /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.50pt/17px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.50pt/17px, dpi=109 info: terminal.c:548: cell width=10, height=24 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.00pt/16px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.00pt/16px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=11.00pt/16px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=11.00pt/16px, dpi=109 info: terminal.c:548: cell width=10, height=23 info: fcft.c:522: info: fcft.c:522: info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.50pt/15px, dpi=109 /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.50pt/15px, dpi=109 /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.50pt/15px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.50pt/15px, dpi=109 info: terminal.c:548: cell width=9, height=22 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.00pt/15px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=10.00pt/15px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.00pt/15px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=10.00pt/15px, dpi=109 info: terminal.c:548: cell width=9, height=22 info: fcft.c:522: info: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=9.50pt/14px, dpi=109 fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=9.50pt/14px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Bold.ttf: size=9.50pt/14px, dpi=109 info: fcft.c:522: /usr/share/fonts/noto/NotoSansMono-Regular.ttf: size=9.50pt/14px, dpi=109 info: terminal.c:548: cell width=8, height=20 info: main.c:445: goodbye ```
dnkl commented 1 year ago
Owner

Do you have antialiasing enabled?

I changed only the font in the default config. All other options are defaults. How can I check whether antialiasing is enabled?

This is a system-wide fontconfig setting. You can do fc-match -v <font-name> | grep antialias and fc-match -v <font-name> | grep rgba.

That said, I think I have a pretty clear understanding of what's happening. Most of this is going to be a brain dump since I haven't yet decided how to fix this.

The blue and red "speckles" you see are subpixel antialiasing that is "bleeding" into surrounding cells. This happens because the subpixel antialiased glyphs may be larger than the maximum advance width specified by the font (and thus larger than the cell width/height).

There are a couple of approaches to solve this.

One can render e.g. all a-z and A-Z glyphs and look for the widest/tallest glyph, and use that for advance width. For the font I was testing with, the result was not pretty - there's just too much spacing between the characters.

Another way is to always re-render the entire grid. This works, but is way too performance demanding for foot.

The approach I'm currently leaning to is to clip the cells. That is, make sure we never render outside the "current" cell. Incidentally, this appears to be what XTerm is doing.

URXvt on the other hand, calculates a slightly different cell spacing that made it work for the font I was testing with. I don't know yet how it calculates the cell dimensions, and thus I can't say if this is a solution that always works, or if it just happened to work in my test case.

The reason I like the clipping approach is because it will solve several similar bugs; there are other reasons a glyph can bleed into the surrounding cells. For example, glyphs from a fallback font may be larger than the cell.

I have a POC sitting in my local source tree that implements cell clipping. This appears to solve the problem. I think I'll clean that up and then post a PR, but will do some more investigating of other terminals before I make a final decision.

> > Do you have antialiasing enabled? > I changed only the font in the default config. All other options are defaults. How can I check whether antialiasing is enabled? This is a system-wide fontconfig setting. You can do `fc-match -v <font-name> | grep antialias` and `fc-match -v <font-name> | grep rgba`. That said, I think I have a pretty clear understanding of what's happening. Most of this is going to be a brain dump since I haven't yet decided how to fix this. The blue and red "speckles" you see are subpixel antialiasing that is "bleeding" into surrounding cells. This happens because the subpixel antialiased glyphs may be larger than the **maximum** advance width specified by the font (and thus larger than the cell width/height). There are a couple of approaches to solve this. One can render e.g. all `a-z` and `A-Z` glyphs and look for the widest/tallest glyph, and use that for advance width. For the font I was testing with, the result was **not** pretty - there's just too much spacing between the characters. Another way is to **always** re-render the entire grid. This works, but is way too performance demanding for foot. The approach I'm currently leaning to is to clip the cells. That is, make sure we never render outside the "current" cell. Incidentally, this appears to be what XTerm is doing. URXvt on the other hand, calculates a slightly different cell spacing that made it work for the font I was testing with. I don't know yet **how** it calculates the cell dimensions, and thus I can't say if this is a solution that always works, or if it just happened to work in my test case. The reason I like the clipping approach is because it will solve several similar bugs; there are other reasons a glyph can bleed into the surrounding cells. For example, glyphs from a fallback font may be larger than the cell. I have a POC sitting in my local source tree that implements cell clipping. This appears to solve the problem. I think I'll clean that up and then post a PR, but will do some more investigating of other terminals before I make a final decision.
dnkl self-assigned this 1 year ago
Poster
fc-match -v "mononoki Nerd Font" | grep antialias
fc-match -v "mononoki Nerd Font" | grep rgba
fc-match -v "Noto Sans Mono" | grep antialias
fc-match -v "Noto Sans Mono" | grep rgba

All of these commands do not print any output. Does that mean antialias is disabled?

``` fc-match -v "mononoki Nerd Font" | grep antialias fc-match -v "mononoki Nerd Font" | grep rgba fc-match -v "Noto Sans Mono" | grep antialias fc-match -v "Noto Sans Mono" | grep rgba ``` All of these commands do not print any output. Does that mean antialias is disabled?
dnkl closed this issue 1 year ago
dnkl commented 1 year ago
Owner

All of these commands do not print any output. Does that mean antialias is disabled?

No, it means it is neither enabled nor disabled, and that it is up to the application to choose.

Foot will in this case set antialias=true, and rgba=disabled (i.e. it will use grayscale antialiasing).

There is however one more thing I forgot to mention: if you have configured subpixel on your output in Sway (swaymsg -t get_outputs | grep subpixel) then foot will use that instead of fontconfig's rgba property.

> All of these commands do not print any output. Does that mean antialias is disabled? No, it means it is neither enabled nor disabled, and that it is up to the application to choose. Foot will in this case set `antialias=true`, and `rgba=disabled` (i.e. it will use grayscale antialiasing). There is however one more thing I forgot to mention: if you have configured `subpixel` on your output in Sway (`swaymsg -t get_outputs | grep subpixel`) then foot will use that instead of fontconfig's `rgba` property.
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.