vcl/source/gdi/impglyphitem.cxx |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 3d0d3ae9e08b701c0762a751a431ed2b1f5010c7
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed May 4 06:28:49 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Wed May 4 08:43:00 2022 +0200

    don't lay out entire strings for Writer layout tests
    
    The SalLayoutGlyphsCache optimization of laying out an entire string
    if it looks like a caller will call it repeatedly for parts of the string
    conflicts with the SAL_ABORT_ON_NON_APPLICATION_FONT_USE checks
    causing PrintFontManager::Substitute() abort if font fallback happens.
    Simply disable the optimization, the output should be the same.
    
    Change-Id: I0cce6a0c2a1a2ce93b95df54d18fedbdc779f34f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133789
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 23a2b2a96fc9..ed7e2895310e 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -322,6 +322,14 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const 
OutputDevice> outputDevice, c
             // and then return subsets of them. So if the first call is for a 
prefix of the string,
             // remember that, and if the next call follows the previous part 
of the string,
             // cache the entire string.
+            // Writer layouts tests enable 
SAL_ABORT_ON_NON_APPLICATION_FONT_USE in order
+            // to make PrintFontManager::Substitute() abort if font fallback 
happens. When
+            // laying out the entire string the chance this happens increases 
(e.g. testAbi11870
+            // normally calls this function only for a part of a string, but 
this optimization
+            // lays out the entire string and causes a fallback). Since this 
optimization
+            // does not change result of this function, simply disable it for 
those tests.
+            static bool bAbortOnFontSubstitute
+                = getenv("SAL_ABORT_ON_NON_APPLICATION_FONT_USE") != nullptr;
             if (nIndex == 0)
             {
                 mLastPrefixKey = key;
@@ -330,7 +338,8 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const 
OutputDevice> outputDevice, c
             else if (mLastPrefixKey.has_value() && mLastPrefixKey->len == 
nIndex
                      && mLastPrefixKey
                             == CachedGlyphsKey(outputDevice, text, 
mLastPrefixKey->index,
-                                               mLastPrefixKey->len, 
nLogicWidth))
+                                               mLastPrefixKey->len, 
nLogicWidth)
+                     && !bAbortOnFontSubstitute)
             {
                 assert(mLastPrefixKey->index == 0);
                 std::unique_ptr<SalLayout> layout

Reply via email to