vcl/unx/gtk3/salnativewidgets-gtk.cxx |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit a948984f5d43516a7fbe6d75bfc5382cb522898a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Oct 26 10:56:09 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Oct 26 13:04:36 2021 +0200

    gtk4: some fonts have pango_font_description_get_size_is_absolute
    
    and are too large, convert back to points
    
    Change-Id: I34aafb0a0678397c1c3c5780d67bdcea405a3866
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124179
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx 
b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index 47556a97edc5..0505010bea81 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -2211,7 +2211,6 @@ static vcl::Font getFont(GtkStyleContext* pStyle, const 
css::lang::Locale& rLoca
 vcl::Font pango_to_vcl(const PangoFontDescription* font, const 
css::lang::Locale& rLocale)
 {
     OString    aFamily        = pango_font_description_get_family( font );
-    int nPangoHeight    = pango_font_description_get_size( font );
     PangoStyle    eStyle    = pango_font_description_get_style( font );
     PangoWeight    eWeight    = pango_font_description_get_weight( font );
     PangoStretch eStretch = pango_font_description_get_stretch( font );
@@ -2267,9 +2266,17 @@ vcl::Font pango_to_vcl(const PangoFontDescription* font, 
const css::lang::Locale
             << "\".");
 #endif
 
-    int nPointHeight = nPangoHeight/PANGO_SCALE;
+    int nPangoHeight = pango_font_description_get_size(font) / PANGO_SCALE;
 
-    vcl::Font aFont( aInfo.m_aFamilyName, Size( 0, nPointHeight ) );
+    if (pango_font_description_get_size_is_absolute(font))
+    {
+        const sal_Int32 nDPIY = 96;
+        nPangoHeight = nPangoHeight * 72;
+        nPangoHeight = nPangoHeight + nDPIY / 2;
+        nPangoHeight = nPangoHeight / nDPIY;
+    }
+
+    vcl::Font aFont(aInfo.m_aFamilyName, Size(0, nPangoHeight));
     if( aInfo.m_eWeight != WEIGHT_DONTKNOW )
         aFont.SetWeight( aInfo.m_eWeight );
     if( aInfo.m_eWidth != WIDTH_DONTKNOW )

Reply via email to