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.lunak@collabora.com>
This commit is contained in:
Luboš Luňák
2022-05-04 06:28:49 +02:00
parent 51c9862303
commit 3d0d3ae9e0

View File

@@ -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