diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-10-26 10:56:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-10-26 13:04:36 +0200 |
commit | a948984f5d43516a7fbe6d75bfc5382cb522898a (patch) | |
tree | b2c91cb32f8d6675b2fe66fbc2485c163fcbf663 /vcl | |
parent | bc92028fdf7f52f555702386a6862631e08a3919 (diff) |
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 <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/salnativewidgets-gtk.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
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 ) |