Bug 4326 - Xft.dpi != 96 messes with text display in litehtml viewer
Summary: Xft.dpi != 96 messes with text display in litehtml viewer
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Plugins/LiteHTML Viewer (show other bugs)
Version: 3.17.5
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
: 4461 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-03-30 16:42 UTC by Jazz Fan
Modified: 2021-07-17 08:45 UTC (History)
1 user (show)

See Also:


Attachments
messed up text display with 168 dpi (11.44 KB, image/png)
2020-03-30 16:42 UTC, Jazz Fan
no flags Details
normal display with 96 dpi (13.78 KB, image/png)
2020-03-30 16:43 UTC, Jazz Fan
no flags Details
font size too big so lines are touching (27.57 KB, image/png)
2021-07-17 08:44 UTC, diffset
no flags Details
Same mail in firefox. Lines do not touch. (25.94 KB, image/png)
2021-07-17 08:45 UTC, diffset
no flags Details

Description Jazz Fan 2020-03-30 16:42:33 UTC
Created attachment 2051 [details]
messed up text display with 168 dpi

Hi,

I use a laptop with a display of 168 dpi. The variable Xft.dpi is set to 168 in my ~/.Xdefaults. When viewing the html part of an email the spacing between words and between lines is way too big. Setting Xft.dpi to 96 solves the problem but then the fonts displayed in claws-mail itself but not(!) in the plugin window are too small. Interestingly, the different dpi settings don't effect litehtml's font sizes but only the spacing as you can see in the attached png files. The (separately built) lite browser doesn't have that problem (but then of course that is built using gtk3).
Comment 1 Jazz Fan 2020-03-30 16:43:44 UTC
Created attachment 2052 [details]
normal display with 96 dpi
Comment 2 Paul 2020-03-30 17:19:53 UTC
Using the newer .Xresources, I can confirm that this happens in GTK3 Claws as well as the GTK2 version. So, GTK3 is not the key to this.
Comment 3 Jazz Fan 2020-03-31 16:12:57 UTC
I tried to pinpoint the problem a bit. However, being more of a Qt guy I am not really familiar with gtk, pango, etc. At least I replaced almost all litehmtl files bundled with the plugin with those of the current litehtml files (except for container_linux.{cpp,h} whose newer versions gave me a nightmare when I tried to compile the plugin with them. After a small change in document.h it compiled and was loadable but the problem remained. So I assume that litehtml itself is not to blame. My guess is that the function lh_widget::draw_text in file lh_widget_text.cpp is the culprit as it contains the comment "/* Draw the text where it's supposed to be */". But as I said, I really don't know (and don't have the time to learn) how all this stuff is supposed to play together.
Comment 4 bugmenotter 2020-07-17 20:15:04 UTC
i have the same problem and made a issue on the litehtml github page.
(https://github.com/litehtml/litehtml/issues/113)

It seems the plugin should adapt the width of litehtml::document_container if dpi is !=96
Comment 5 diffset 2020-07-18 10:33:59 UTC
Hm, how can your observations be the same issue? As I said in my OP I don't see that problem in the litehtml browser but only in the plugin. And for the spacing is too wide whereas in your bug report you have overlapping text. I don't think that your dpi setting is less then 96.
Comment 6 bugmenotter 2020-07-19 10:36:38 UTC
My dpi is 84! (https://www.necdisplay.com/products/displays/lcd1990fxp-bk)

When i set dpi to 168 it looks like Jazz Fan's screenshoot.
Comment 7 diffset 2020-07-19 12:07:07 UTC
Ah okay. But obviously you see this bug also in the standalone browser. I don't! That's why I reported the bug here…
Comment 8 Paul 2021-03-17 16:15:43 UTC
fixed in git
Comment 9 Paul 2021-03-17 16:15:57 UTC
*** Bug 4461 has been marked as a duplicate of this bug. ***
Comment 10 diffset 2021-03-20 11:47:36 UTC
(In reply to Paul from comment #8)
Thanks Paul, this fixes the spacing. However, now the font sizes are incorrect. I was able to fix that for me in a very inelegant way. Since I know that my scaling factor is 168/96=7/4 I changed all three occurrences of PANGO_SCALE in lh_widget_text.cpp to PANGO_SCALE1 and added

#define PANGO_SCALE1 ((PANGO_SCALE*4)/7)

on line 25 of that file.
Comment 11 diffset 2021-07-17 08:43:19 UTC
Now that the fix has hit version 3.18 I wanted to say again that the font sizes are still wrong. In simple html mails this just leads to an enlarged display of the text which is not dramatic (and may be the reason that the problem is not spotted immediately). But in complex mails this can be very disturbing. I'll attach two screenshots, one with the litehtml plugin in clawsmail and one after opening the same mail in firefox.
Comment 12 diffset 2021-07-17 08:44:54 UTC
Created attachment 2226 [details]
font size too big so lines are touching
Comment 13 diffset 2021-07-17 08:45:52 UTC
Created attachment 2227 [details]
Same mail in firefox. Lines do not touch.

Note You need to log in before you can comment on or make changes to this bug.