vcl/source/outdev/text.cxx | 17 +++++++++++++++++ vcl/source/window/status.cxx | 8 +++++--- 2 files changed, 22 insertions(+), 3 deletions(-)
New commits: commit cb6f462b193c1e3f740dae4fd269b7e91b638d05 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue May 3 14:02:12 2022 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Wed May 4 16:31:29 2022 +0200 do not allow reusing already used SalLayoutGlyphs (tdf#148477) If the glyphs have already been used, the AdjustLayout() call in OutputDevice::ImplLayout might have altered them, since MultiSalLayout::ImplAdjustMultiLayout() drops glyphs that need falllback from the base layout. And then then GenericSalLayout::LayoutText() would not know to call SetNeedFallback(). Change-Id: I2f79d26c8b861f20d7d52abaa0d917aaeefb37a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133758 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> (cherry picked from commit 22191901bc91535121a5e8dc7ee6137233824d36) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133726 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index b8b599cbc5ba..accbc2cfa0d7 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1309,6 +1309,23 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, SAL_WARN("vcl", "Trying to setup invalid cached glyphs - falling back to relayout!"); pGlyphs = nullptr; } +#ifdef DBG_UTIL + if (pGlyphs) + { + for( int level = 0;; ++level ) + { + SalLayoutGlyphsImpl* glyphsImpl = pGlyphs->Impl(level); + if(glyphsImpl == nullptr) + break; + // It is allowed to reuse only glyphs created with SalLayoutFlags::GlyphItemsOnly. + // If the glyphs have already been used, the AdjustLayout() call below might have + // altered them (MultiSalLayout::ImplAdjustMultiLayout() drops glyphs that need + // fallback from the base layout, but then GenericSalLayout::LayoutText() + // would not know to call SetNeedFallback()). + assert(glyphsImpl->GetFlags() & SalLayoutFlags::GlyphItemsOnly); + } + } +#endif if (!InitFont()) return nullptr; diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 755bf9643585..42ffb05ea5ae 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -394,7 +394,7 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen if(!pLayoutCache) { // update cache - pItem->mxLayoutCache = rRenderContext.ImplLayout(pItem->maText, 0, -1); + pItem->mxLayoutCache = rRenderContext.ImplLayout(pItem->maText, 0, -1, Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly); pLayoutCache = pItem->mxLayoutCache.get(); } @@ -1139,14 +1139,16 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCha tools::Long nWidth; if (nCharsWidth != -1) { - std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout("0",0,-1); + std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout("0",0,-1, + Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly); const SalLayoutGlyphs glyphs = pSalLayout ? pSalLayout->GetGlyphs() : SalLayoutGlyphs(); nWidth = GetTextWidth("0",0,-1,nullptr,pSalLayout ? &glyphs : nullptr); nWidth = nWidth * nCharsWidth + nFudge; } else { - std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout(pItem->maText,0,-1); + std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout(pItem->maText,0,-1, + Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly); const SalLayoutGlyphs glyphs = pSalLayout ? pSalLayout->GetGlyphs() : SalLayoutGlyphs(); nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pSalLayout ? &glyphs : nullptr) + nFudge; // Store the calculated layout.