vcl/source/outdev/font.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
New commits: commit 47e8763114f12fe14e2a8dd94b5a339f614d23bc Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Fri May 20 08:47:30 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Fri May 20 14:11:33 2022 +0200 work around ImplGlyphFallbackLayout() returning garbage fallback As the comment says, this doesn't make sense to me, and it suggests that GetGlyphFallbackFont() is broken. And in case the missing codes list was in fact modified by the call, then ignoring the font and keeping the modified list meant fallback for those glyphs wasn't provided, which was confusing checkGlyphsEqual() in SalLayoutGlyphsCache. Restoring the missing codes list will not help much will the fallback, as that'll make this loop finding the same font, but at least this stops checkGlyphsEqual() assertion failures. I cannot reproduce this locally, only on the crashtesting server, by running '--headless --convert-to pdf' with ooo#57685. Change-Id: I533c776d1e470e6d6afe39a1363f7a203f345981 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134655 Tested-by: Luboš Luňák <l.lu...@collabora.com> Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 106769eaf1d3..071056e83690 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1225,6 +1225,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt // find a font family suited for glyph fallback // GetGlyphFallbackFont() needs a valid FontInstance // if the system-specific glyph fallback is active + OUString oldMissingCodes = aMissingCodes; if( !pFallbackFont ) pFallbackFont = mxFontCache->GetGlyphFallbackFont( mxFontCollection.get(), aFontSelData, mpFontInstance.get(), nFallbackLevel, aMissingCodes ); @@ -1234,8 +1235,22 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt if( nFallbackLevel < MAX_FALLBACK-1) { // ignore fallback font if it is the same as the original font + // TODO: This seems broken. Either the font does not provide any of the missing + // codes, in which case the fallback should not select it. Or it does provide + // some of the missing codes, and then why weren't they used the first time? + // This will just loop repeatedly finding the same font (it used to remove + // the found font from mxFontCache, but doesn't do that anymore and I don't + // see how doing that would remove the font from consideration for fallback). if( mpFontInstance->GetFontFace() == pFallbackFont->GetFontFace()) + { + if(aMissingCodes != oldMissingCodes) + { + SAL_WARN("vcl.gdi", "Font fallback to the same font, but has missing codes"); + // Restore the missing codes if we're not going to use this font. + aMissingCodes = oldMissingCodes; + } continue; + } } // create and add glyph fallback layout to multilayout