summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-08-09 12:46:06 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-08-12 12:12:33 +0200
commitd21a23cb03b54d423faf6c4a3d706cb9c749916d (patch)
tree2893d29a12ab9345e5d6ee118c0e39b4ff79015e /vcl
parent49a74d07ca38c313ce5cf237b4ac2df892a3fa0e (diff)
use the same vcl::text::TextLayoutCache when comparing text layout
Otherwise OutputDevice::ImplLayout() might use a temporary cache just for the subtext while SalLayoutGlyphsCache would use cache for the whole string, and those two might differ e.g. with an arabic string starting with numbers when the subset is just the numbers. Change-Id: Idea7ef277beae07e39e4a714088a7585361d13e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138143 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/complextext.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index d6c624fa7406..9e96205946b1 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -226,8 +226,10 @@ static void testCachedGlyphsSubstring( const OUString& aText, const OUString& aF
vcl::Font aFont( aFontName, Size(0, 12));
pOutputDevice->SetFont( aFont );
SalLayoutGlyphsCache::self()->clear();
+ std::shared_ptr<const vcl::text::TextLayoutCache> layoutCache = OutputDevice::CreateTextLayoutCache(aText);
// Get the glyphs for the entire text once, to ensure the cache can built subsets from it.
- pOutputDevice->ImplLayout( aText, 0, aText.getLength(), Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly);
+ pOutputDevice->ImplLayout( aText, 0, aText.getLength(), Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly,
+ layoutCache.get());
// Now check for all subsets. Some of them possibly do not make sense in practice, but the code
// should cope with them.
for( sal_Int32 len = 1; len <= aText.getLength(); ++len )
@@ -235,10 +237,10 @@ static void testCachedGlyphsSubstring( const OUString& aText, const OUString& aF
{
std::string message = prefix + " (" + std::to_string(pos) + "/" + std::to_string(len) + ")";
std::unique_ptr<SalLayout> pLayout1 = pOutputDevice->ImplLayout(
- aText, pos, len, Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly);
+ aText, pos, len, Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly, layoutCache.get());
SalLayoutGlyphs aGlyphs1 = pLayout1->GetGlyphs();
const SalLayoutGlyphs* aGlyphs2 = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(
- pOutputDevice, aText, pos, len, 0);
+ pOutputDevice, aText, pos, len, 0, layoutCache.get());
CPPUNIT_ASSERT_MESSAGE(message, aGlyphs2 != nullptr);
checkCompareGlyphs(aGlyphs1, *aGlyphs2, message);
}