vcl/README.vars.md                      |    2 ++
 vcl/qt5/QtGraphics_Text.cxx             |    3 ++-
 vcl/skia/x11/textrender.cxx             |    4 +++-
 vcl/unx/generic/gdi/cairotextrender.cxx |    3 ++-
 4 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 9137bd2dd3ab66ffa783fc15a1add1e9cf541460
Author:     Frank Steiner <fsteiner-bo...@bio.ifi.lmu.de>
AuthorDate: Thu Nov 23 14:31:10 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Fri Nov 24 09:45:29 2023 +0100

    enable using medium/full font hinting even with subpixel positioning
    
    Change-Id: I1be0670d59163070dccf035ec9c7b0cd4f818c69
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159766
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/vcl/README.vars.md b/vcl/README.vars.md
index fd92541a1e11..92931b51f170 100644
--- a/vcl/README.vars.md
+++ b/vcl/README.vars.md
@@ -15,6 +15,8 @@ These are the general environment variables used in the VCL:
 * `SAL_NON_APPLICATION_FONT_USE` - control use of non-bundled fonts, values 
are `deny` or `abort`;
   for now only works on platforms using fontconfig (i.e., on Linux, but 
neither on macOS nor on
   Windows); also see gb_CppunitTest_set_non_application_font_use for using it 
in unit tests
+* `SAL_ALLOW_DEFAULT_HINTING` - use default font hinting for the platform. 
Enables medium/full hinting 
+  style which is otherwise reverted to (s)light.
 
 * `LO_COLLECT_UIINFO` - enable the uitesting logging, value is expected to be 
a relative file name that
 will be used to write the log under `instdir/uitest/`.
diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx
index c7486da26d2e..19837d510f13 100644
--- a/vcl/qt5/QtGraphics_Text.cxx
+++ b/vcl/qt5/QtGraphics_Text.cxx
@@ -160,8 +160,9 @@ std::unique_ptr<GenericSalLayout> 
QtGraphics::GetTextLayout(int nFallbackLevel)
 static QRawFont GetRawFont(const QFont& rFont, bool 
bWithoutHintingInTextDirection)
 {
     QFont::HintingPreference eHinting = rFont.hintingPreference();
+    static bool bAllowDefaultHinting = getenv("SAL_ALLOW_DEFAULT_HINTING") != 
nullptr;
     bool bAllowedHintStyle
-        = !bWithoutHintingInTextDirection
+        = !bWithoutHintingInTextDirection || bAllowDefaultHinting
           || (eHinting == QFont::PreferNoHinting || eHinting == 
QFont::PreferVerticalHinting);
     if (bWithoutHintingInTextDirection && !bAllowedHintStyle)
     {
diff --git a/vcl/skia/x11/textrender.cxx b/vcl/skia/x11/textrender.cxx
index b4083636d2a0..acc930e070e5 100644
--- a/vcl/skia/x11/textrender.cxx
+++ b/vcl/skia/x11/textrender.cxx
@@ -81,8 +81,10 @@ void SkiaTextRender::DrawTextLayout(const GenericSalLayout& 
rLayout, const SalGr
         font.setSubpixel(true);
 
         SkFontHinting eHinting = font.getHinting();
+        static bool bAllowDefaultHinting = getenv("SAL_ALLOW_DEFAULT_HINTING") 
!= nullptr;
         bool bAllowedHintStyle
-            = eHinting == SkFontHinting::kNone || eHinting == 
SkFontHinting::kSlight;
+            = bAllowDefaultHinting
+              || (eHinting == SkFontHinting::kNone || eHinting == 
SkFontHinting::kSlight);
         if (!bAllowedHintStyle)
             font.setHinting(SkFontHinting::kSlight);
     }
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 9b998066954b..7e7ce9ca700f 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -418,12 +418,13 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
 
     const StyleSettings& rStyleSettings = 
Application::GetSettings().GetStyleSettings();
     const bool bDisableAA = !rStyleSettings.GetUseFontAAFromSystem() && 
!rGraphics.getAntiAlias();
+    static bool bAllowDefaultHinting = getenv("SAL_ALLOW_DEFAULT_HINTING") != 
nullptr;
 
     const cairo_font_options_t* pFontOptions = 
GetSalInstance()->GetCairoFontOptions();
     if (pFontOptions || bDisableAA || bSubpixelPositioning)
     {
         cairo_hint_style_t eHintStyle = pFontOptions ? 
cairo_font_options_get_hint_style(pFontOptions) : CAIRO_HINT_STYLE_DEFAULT;
-        bool bAllowedHintStyle = !bSubpixelPositioning || (eHintStyle == 
CAIRO_HINT_STYLE_NONE || eHintStyle == CAIRO_HINT_STYLE_SLIGHT);
+        bool bAllowedHintStyle = !bSubpixelPositioning || bAllowDefaultHinting 
|| (eHintStyle == CAIRO_HINT_STYLE_NONE || eHintStyle == 
CAIRO_HINT_STYLE_SLIGHT);
 
         if (bDisableAA || !bAllowedHintStyle || bSubpixelPositioning)
         {

Reply via email to