vcl/unx/generic/gdi/cairotextrender.cxx |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 4ec4fee0cf48142e2f4c594fe401f72872dc1bd9
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Aug 22 13:22:04 2022 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Tue Aug 23 06:18:52 2022 +0200

    tdf#150507 set hint style even if the platform returns no default font 
options
    
    if the platform (e.g. gen/kf5) doesn't return anything for
    GetCairoFontOptions() but we have need for specific font options then we
    also need to set them
    
    Change-Id: Ia805341d2ec75bdaf3d9de62955a247c33b106d1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138543
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 7300562d5d68..1e2e75c01d79 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -191,14 +191,15 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
         __lsan_disable();
 #endif
 
-    if (const cairo_font_options_t* pFontOptions = 
GetSalInstance()->GetCairoFontOptions())
-    {
-        const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
-        bool bDisableAA = !rStyleSettings.GetUseFontAAFromSystem() && 
!rGraphics.getAntiAlias();
+    const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
+    const bool bDisableAA = !rStyleSettings.GetUseFontAAFromSystem() && 
!rGraphics.getAntiAlias();
+    const bool bResolutionIndependentLayoutEnabled = 
rGraphics.getTextRenderModeForResolutionIndependentLayoutEnabled();
 
-        const bool bResolutionIndependentLayoutEnabled = 
rGraphics.getTextRenderModeForResolutionIndependentLayoutEnabled();
-        cairo_hint_style_t eHintStyle = 
cairo_font_options_get_hint_style(pFontOptions);
-        cairo_hint_metrics_t eHintMetricsStyle = 
cairo_font_options_get_hint_metrics(pFontOptions);
+    const cairo_font_options_t* pFontOptions = 
GetSalInstance()->GetCairoFontOptions();
+    if (pFontOptions || bDisableAA || bResolutionIndependentLayoutEnabled)
+    {
+        cairo_hint_style_t eHintStyle = pFontOptions ? 
cairo_font_options_get_hint_style(pFontOptions) : CAIRO_HINT_STYLE_DEFAULT;
+        cairo_hint_metrics_t eHintMetricsStyle = pFontOptions ? 
cairo_font_options_get_hint_metrics(pFontOptions) : CAIRO_HINT_METRICS_DEFAULT;
         bool bAllowedHintStyle = !bResolutionIndependentLayoutEnabled || 
(eHintStyle == CAIRO_HINT_STYLE_NONE);
         bool bAllowedHintMetricStyle = !bResolutionIndependentLayoutEnabled || 
(eHintMetricsStyle == CAIRO_HINT_METRICS_OFF);
 
@@ -206,7 +207,7 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
         {
             // Disable font AA in case global AA setting is supposed to affect
             // font rendering (not the default) and AA is disabled.
-            cairo_font_options_t* pOptions = 
cairo_font_options_copy(pFontOptions);
+            cairo_font_options_t* pOptions = pFontOptions ? 
cairo_font_options_copy(pFontOptions) : cairo_font_options_create();
             if (bDisableAA)
                 cairo_font_options_set_antialias(pOptions, 
CAIRO_ANTIALIAS_NONE);
             if (!bAllowedHintMetricStyle)
@@ -216,7 +217,7 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
             cairo_set_font_options(cr, pOptions);
             cairo_font_options_destroy(pOptions);
         }
-        else
+        else if (pFontOptions)
             cairo_set_font_options(cr, pFontOptions);
     }
 

Reply via email to