dnkl/foot
41
2.0k
Fork
You've already forked foot
243

foot detects DPI incorrectly after resing font #9

Closed
opened 2020年03月14日 20:42:50 +01:00 by nikp123 · 5 comments

How to reproduce:

  1. Launch foot
  2. Try to resize font with keyboard shortcut ctrl in combination with either + or -

Expected behaviour:
Font scales properly when trying to resize

Issue in detail:
The font doesn't get scaled linearly because when resizing foot doesn't read the DPI correctly

Attached log - (describes the bug):

nikp123@HP-Laptop /home/nikp123 $ foot
info: config.c:841: loading configuration from /home/nikp123/.config/footrc
info: wayland.c:798: HDMI-A-1: 1920x1080+1092x0@60Hz 2343 23.10" scale=1 PPI=96x98 (physical) PPI=96x98 (logical)
info: wayland.c:798: eDP-1: 1366x768+0x645@60Hz 0x0354 13.23" scale=2 PPI=124x128 (physical) PPI=99x102 (logical)
info: wayland.c:834: cursor theme: (null), size: 24
info: terminal.c:482: using 4 rendering threads
info: wayland.c:1027: requesting SSD decorations
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF.ttf: size=12.00pt/32px, dpi=196
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold.ttf: size=12.00pt/32px, dpi=196
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Italic.ttf: size=12.00pt/32px, dpi=196
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold Italic.ttf: size=12.00pt/32px, dpi=196
info: terminal.c:526: cell width=16, height=35
info: wayland.c:634: using SSD decorations
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF.ttf: size=12.00pt/34px, dpi=204
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold.ttf: size=12.00pt/34px, dpi=204
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Italic.ttf: size=12.00pt/34px, dpi=204
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold Italic.ttf: size=12.00pt/34px, dpi=204
info: terminal.c:526: cell width=17, height=37
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF.ttf: size=12.50pt/13px, dpi=75
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold.ttf: size=12.50pt/13px, dpi=75
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Italic.ttf: size=12.50pt/13px, dpi=75
info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold Italic.ttf: size=12.50pt/13px, dpi=75
info: terminal.c:526: cell width=7, height=14
info: main.c:393: goodbye
nikp123@HP-Laptop /home/nikp123 $ 
How to reproduce: 1. Launch foot 2. Try to resize font with keyboard shortcut ctrl in combination with either + or - Expected behaviour: Font scales properly when trying to resize Issue in detail: The font doesn't get scaled linearly because when resizing foot doesn't read the DPI correctly Attached log - (describes the bug): ``` nikp123@HP-Laptop /home/nikp123 $ foot info: config.c:841: loading configuration from /home/nikp123/.config/footrc info: wayland.c:798: HDMI-A-1: 1920x1080+1092x0@60Hz 2343 23.10" scale=1 PPI=96x98 (physical) PPI=96x98 (logical) info: wayland.c:798: eDP-1: 1366x768+0x645@60Hz 0x0354 13.23" scale=2 PPI=124x128 (physical) PPI=99x102 (logical) info: wayland.c:834: cursor theme: (null), size: 24 info: terminal.c:482: using 4 rendering threads info: wayland.c:1027: requesting SSD decorations info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF.ttf: size=12.00pt/32px, dpi=196 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold.ttf: size=12.00pt/32px, dpi=196 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Italic.ttf: size=12.00pt/32px, dpi=196 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold Italic.ttf: size=12.00pt/32px, dpi=196 info: terminal.c:526: cell width=16, height=35 info: wayland.c:634: using SSD decorations info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF.ttf: size=12.00pt/34px, dpi=204 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold.ttf: size=12.00pt/34px, dpi=204 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Italic.ttf: size=12.00pt/34px, dpi=204 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold Italic.ttf: size=12.00pt/34px, dpi=204 info: terminal.c:526: cell width=17, height=37 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF.ttf: size=12.50pt/13px, dpi=75 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold.ttf: size=12.50pt/13px, dpi=75 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Italic.ttf: size=12.50pt/13px, dpi=75 info: fcft.c:451: /usr/share/fonts/TTF/TerminusTTF-Bold Italic.ttf: size=12.50pt/13px, dpi=75 info: terminal.c:526: cell width=7, height=14 info: main.c:393: goodbye nikp123@HP-Laptop /home/nikp123 $ ```
Owner
Copy link

Thanks!

I've been trying to reproduce this one for a while now, including installing and using the same font you're using, and using the same scale factor. Nothing mattered - it still worked for me.

Until I tried a typo in the font configuration: Terminus (TTF);size=12 instead of Terminus (TTF):size=12 (note the incorrect usage of a semicolon - the attributes should be colon separated).

So first of all I'd like you to check your footrc and the font configuration; make sure it's in the correct format.

Assuming this is the issue, I pushed a fix to the fcft library. You can either update your foot-git AUR package, or do a git pull in foot/subprojects/fcft.

If none of the above helps, I'd like you to apply this patch to foot/subprojects/fcft:

diff --git a/fcft.c b/fcft.c
index 96c2005..c198e70 100644
--- a/fcft.c
+++ b/fcft.c
@@ -650,6 +650,8 @@ pattern_from_font_with_adjusted_size(const struct font_priv *font, double amount
 
 setlocale(LC_ALL, cur_locale);
 free(cur_locale);
+ LOG_INFO("adjust: amount=%f, pattern \"%s\" -> \"%s\"",
+ amount, font->pattern, pattern);
 return pattern;
 }
 

Then recompile foot and run. You should see the new log message when you try to change the font size with e.g. ctrl-+.

Thanks! I've been trying to reproduce this one for a while now, including installing and using the same font you're using, and using the same scale factor. Nothing mattered - it still worked for me. Until I tried a typo in the font configuration: `Terminus (TTF);size=12` instead of `Terminus (TTF):size=12` (note the incorrect usage of a semicolon - the attributes should be colon separated). So first of all I'd like you to check your `footrc` and the font configuration; make sure it's in the correct format. Assuming this is the issue, I pushed a fix to the **fcft** library. You can either update your `foot-git` AUR package, or do a `git pull` in `foot/subprojects/fcft`. If none of the above helps, I'd like you to apply this patch to `foot/subprojects/fcft`: ```diff diff --git a/fcft.c b/fcft.c index 96c2005..c198e70 100644 --- a/fcft.c +++ b/fcft.c @@ -650,6 +650,8 @@ pattern_from_font_with_adjusted_size(const struct font_priv *font, double amount setlocale(LC_ALL, cur_locale); free(cur_locale); + LOG_INFO("adjust: amount=%f, pattern \"%s\" -> \"%s\"", + amount, font->pattern, pattern); return pattern; } ``` Then recompile foot and run. You should see the new log message when you try to change the font size with e.g. <kbd>ctrl</kbd>-<kbd>+</kbd>.
Owner
Copy link

... and post the new log ;)

... and post the new log ;)
Owner
Copy link

Assuming this is the issue, I pushed a fix to the fcft library.

Just to clarify: the fix ensures the DPI attribute isn't "lost". However, a typo in the font specification is still a typo...

> Assuming this is the issue, I pushed a fix to the fcft library. Just to clarify: the fix ensures the DPI attribute isn't "lost". However, a typo in the font specification is still a typo...
Author
Copy link

@dnkl I used fontsize instead of size in footrc. Maybe that's the issue?

Also can confirm that by using size instead of fontsize everything works as expected.

@dnkl I used ``fontsize`` instead of ``size`` in footrc. Maybe that's the issue? Also can confirm that by using ``size`` instead of ``fontsize`` everything works as expected.
Owner
Copy link

@nikp123 yup, that was the issue. Using an unpatched fcft, <font-name>:fontsize=12:dpi=154 was replaced with <font-name>:fontdpi=154.

@nikp123 yup, that was the issue. Using an unpatched fcft, `<font-name>:fontsize=12:dpi=154` was replaced with `<font-name>:fontdpi=154`.
Sign in to join this conversation.
No Branch/Tag specified
master
osc-5522
sixel-heap-buffer-overflow
releases/1.27
releases/1.26
releases/1.25
releases/1.24
multi-cursor
releases/1.23
pixman-16f-2
releases/1.22
releases/1.21
releases/1.20
releases/1.19
releases/1.18
releases/1.17
releases/1.16
releases/1.15
releases/1.14
releases/1.13
releases/1.12
releases/1.11
releases/1.10
releases/1.9
releases/1.8
releases/1.7
releases/1.6
releases/1.5
releases/1.4
releases/1.3
releases/1.2
releases/1.1
releases/1.0
1.27.0
1.26.1
1.26.0
1.25.0
1.24.0
1.23.1
1.23.0
1.22.3
1.22.2
1.22.1
1.22.0
1.21.0
1.20.2
1.20.1
1.20.0
1.19.0
1.18.1
1.18.0
1.17.2
1.17.1
1.17.0
1.16.2
1.16.1
1.16.0
1.15.3
1.15.2
1.15.1
1.15.0
1.14.0
1.13.1
1.13.0
1.12.1
1.12.0
1.11.0
1.10.3
1.10.2
1.10.1
1.10.0
1.9.2
1.9.1
1.9.0
1.8.2
1.8.1
1.8.0
1.7.2
1.7.1
1.7.0
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.0
1.2.3
1.2.2
1.2.1
1.2.0
1.1.0
1.0.0
0.9.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/foot#9
Reference in a new issue
dnkl/foot
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?