[geany/geany] db6f67: GTK: Fix autoc font size on GTK >= 3.21.0

Colomban Wendling git-noreply at xxxxx
Wed Sep 7 09:05:17 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 07 Sep 2016 09:05:17 UTC
Commit:      db6f671135511bd107d18d512270503047eb19ac
             https://github.com/geany/geany/commit/db6f671135511bd107d18d512270503047eb19ac

Log Message:
-----------
GTK: Fix autoc font size on GTK >= 3.21.0

GTK 3.21.0 fixed font size handling, leading to properly interpreting
pixels and points in CSS declarations.  However, as older versions
incorrectly handled those, the code has to handle both behaviours.

>From CSS, GTK < 3.21.0 actually applied the conversion to points, but
incorrectly: 10px was used as 10pt, but 10pt was scaled up twice.

So, assuming 96 DPI, it leads to:

font-size | 3.20.0  | 3.21.0  |
----------|---------|---------|
10px      | 13.33px | 10px    |
10pt      | 17.77px | 13.33px |

So, we need to fix the code to accommodate for both (either scaling
ourselves, or adapting the unit: I chose the second, simpler, option).

See https://git.gnome.org/browse/gtk+/commit/?id=df08fc91bdc1d2e4c866122304fabe4dd298a7de

X-Scintilla-Bug-URL: https://sourceforge.net/p/scintilla/bugs/1859/
X-Scintilla-Commit-ID: a4b5da8b3a0a05a1e67ba7eb08474106d421b088


Modified Paths:
--------------
    scintilla/gtk/PlatGTK.cxx

Modified: scintilla/gtk/PlatGTK.cxx
10 lines changed, 9 insertions(+), 1 deletions(-)
===================================================================
@@ -1494,7 +1494,15 @@ void ListBoxX::SetFont(Font &scint_font) {
 			ssFontSetting << "font-family: " << pango_font_description_get_family(pfd) <<  "; ";
 			ssFontSetting << "font-size:";
 			ssFontSetting << static_cast<double>(pango_font_description_get_size(pfd)) / PANGO_SCALE;
-			ssFontSetting << "px; ";
+			// On GTK < 3.21.0 the units are incorrectly parsed, so a font size in points
+			// need to use the "px" unit.  Normally we only get fonts in points here, so
+			// don't bother to handle the case the font is actually in pixels on < 3.21.0.
+			if (gtk_check_version(3, 21, 0) != NULL || // on < 3.21.0
+			    pango_font_description_get_size_is_absolute(pfd)) {
+				ssFontSetting << "px; ";
+			} else {
+				ssFontSetting << "pt; ";
+			}
 			ssFontSetting << "font-weight:"<< pango_font_description_get_weight(pfd) << "; ";
 			ssFontSetting << "}";
 			gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(cssProvider),



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list