Bug 4461 - Gtk3 litehtml dpi glyph scaling
Summary: Gtk3 litehtml dpi glyph scaling
Status: CLOSED DUPLICATE of bug 4326
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: Plugins/LiteHTML Viewer (show other bugs)
Version: 4.0.0
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2021-03-16 23:16 UTC by RaminYT
Modified: 2021-03-17 16:15 UTC (History)
0 users

See Also:


Attachments
Screenshots at manual 86/104 dpi before and after setting Pango Cairo dpi (399.75 KB, image/jpeg)
2021-03-16 23:16 UTC, RaminYT
Details

Description RaminYT 2021-03-16 23:16:03 UTC
Created attachment 2186 [details]
Screenshots at manual 86/104 dpi before and after setting Pango Cairo dpi

The text rendering portion of the litehtml plugin seems to not fully honor manual dpi settings (Gtk3). It appears that the word spacing estimates do scale, but not the physical glyph rendering.

Setting the GDK-derived dpi for Cairo on the PangoContext seems to be a way to fix that; at least it makes HTML mail readable by not overlapping words when I'm using a manual 86 dpi setting.

See attached image and sample patch below (seems to be the central Pango place - don't know if calling GDK there is conceptually acceptable. Also something else might break (?), although it seems fine).

------

From 07f6db8f3d82ead782dfc1d1d78179dd9544e88e Mon Sep 17 00:00:00 2001
From: Ramin Yaghoubzadeh Torky <r.y.t-REMOVETHIS-@web.de>
Date: Tue, 16 Mar 2021 22:19:16 +0100
Subject: [PATCH] Apply GDK dpi to PangoContext to ensure appropriate font size
 selection

---
 src/plugins/litehtml_viewer/lh_widget_text.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/plugins/litehtml_viewer/lh_widget_text.cpp b/src/plugins/litehtml_viewer/lh_widget_text.cpp
index ed290559f..68121c552 100644
--- a/src/plugins/litehtml_viewer/lh_widget_text.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget_text.cpp
@@ -101,6 +101,10 @@ void lh_widget::draw_text( litehtml::uint_ptr hdc, const litehtml::tchar_t* text
 	PangoLayout *layout = pango_cairo_create_layout(cr);
 	PangoContext *context = pango_layout_get_context(layout);
 
+	GdkScreen* screen = gdk_screen_get_default();
+	double dpi = gdk_screen_get_resolution(screen);
+	pango_cairo_context_set_resolution(context, dpi);
+
 	if (fnt != NULL) {
 		/* Set font */
 		pango_layout_set_font_description(layout, fnt->font);
-- 
2.25.1
Comment 1 Paul 2021-03-17 14:36:36 UTC
this is a duplicate of bug #4326 isn't it?
Comment 2 RaminYT 2021-03-17 15:12:01 UTC
Sorry, yes, it is very likely the same root cause. I reported this for 'Claws Mail (Gtk3)' specifically, thought the other one might have been for a different GUI toolkit.

The observed effects here are identical; above patch fixes things for me, but I cannot assess or test whether it'll work universally / in other configurations.
Comment 3 Paul 2021-03-17 16:15:31 UTC
thanks for the patch. it's now in git.
Comment 4 Paul 2021-03-17 16:15:57 UTC

*** This bug has been marked as a duplicate of bug 4326 ***

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