summaryrefslogtreecommitdiff
path: root/vcl/source/font/PhysicalFontCollection.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-02 15:05:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-02 22:15:59 +0100
commit04f9a8957c04b8c5abaa58140328d2c83381f4ff (patch)
tree568ca45b4be46972ec4bb84bf85fd2c990095bf8 /vcl/source/font/PhysicalFontCollection.cxx
parent8716721f4645078b04770271c71f7687a2b21e07 (diff)
tdf#147283 allow 'fake italic/bold' glyph fallback results to be cached
see also tdf#32665 Change-Id: I69746b815fec3c73f87de4dc3fe84dbc91e61f0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130877 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/font/PhysicalFontCollection.cxx')
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx64
1 files changed, 38 insertions, 26 deletions
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 211e4e65bd57..139e4f133e88 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -196,7 +196,10 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont(FontSelectPatte
while( nStrIndex < rMissingCodes.getLength() )
{
cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
- bCached = pFontInstance->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &rFontSelData.maSearchName );
+ bCached = pFontInstance->GetFallbackForUnicode(cChar, rFontSelData.GetWeight(),
+ &rFontSelData.maSearchName,
+ &rFontSelData.mbEmbolden,
+ &rFontSelData.maItalicMatrix);
// ignore entries which don't have a fallback
if( !bCached || !rFontSelData.maSearchName.isEmpty() )
@@ -210,13 +213,20 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont(FontSelectPatte
int nRemainingLength = 0;
std::unique_ptr<sal_UCS4[]> const pRemainingCodes(new sal_UCS4[rMissingCodes.getLength()]);
OUString aFontName;
+ bool bEmbolden;
+ ItalicMatrix aMatrix;
while( nStrIndex < rMissingCodes.getLength() )
{
cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
- bCached = pFontInstance->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &aFontName );
- if( !bCached || (rFontSelData.maSearchName != aFontName) )
+ bCached = pFontInstance->GetFallbackForUnicode(cChar, rFontSelData.GetWeight(),
+ &aFontName, &bEmbolden, &aMatrix);
+ if (!bCached || rFontSelData.maSearchName != aFontName ||
+ rFontSelData.mbEmbolden != bEmbolden ||
+ rFontSelData.maItalicMatrix != aMatrix)
+ {
pRemainingCodes[ nRemainingLength++ ] = cChar;
+ }
}
rMissingCodes = OUString( pRemainingCodes.get(), nRemainingLength );
}
@@ -231,31 +241,33 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont(FontSelectPatte
else
rFontSelData.maSearchName.clear();
- // See fdo#32665 for an example. FreeSerif that has glyphs in normal
- // font, but not in the italic or bold version
- bool bSubSetOfFontRequiresPropertyFaking = rFontSelData.mbEmbolden || rFontSelData.maItalicMatrix != ItalicMatrix();
-
- // Cache the result even if there was no match, unless its from part of a font for which the properties need
- // to be faked. We need to rework this cache to take into account that fontconfig can return different fonts
- // for different input sizes, weights, etc. Basically the cache is way to naive
- if (!bSubSetOfFontRequiresPropertyFaking)
+ // Cache the result even if there was no match
+ // See tdf#32665 and tdf#147283 for an example where FreeSerif that has glyphs that exist
+ // in the bold font, but not in the bold+italic version where fontconfig suggest the bold
+ // font + applying a matrix to fake the missing italic.
+ for(;;)
{
- for(;;)
- {
- if( !pFontInstance->GetFallbackForUnicode( cChar, rFontSelData.GetWeight(), &rFontSelData.maSearchName ) )
- pFontInstance->AddFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName );
- if( nStrIndex >= aOldMissingCodes.getLength() )
- break;
- cChar = aOldMissingCodes.iterateCodePoints( &nStrIndex );
- }
- if( !rFontSelData.maSearchName.isEmpty() )
+ if (!pFontInstance->GetFallbackForUnicode(cChar, rFontSelData.GetWeight(),
+ &rFontSelData.maSearchName,
+ &rFontSelData.mbEmbolden,
+ &rFontSelData.maItalicMatrix))
+ {
+ pFontInstance->AddFallbackForUnicode(cChar, rFontSelData.GetWeight(),
+ rFontSelData.maSearchName,
+ rFontSelData.mbEmbolden,
+ rFontSelData.maItalicMatrix);
+ }
+ if( nStrIndex >= aOldMissingCodes.getLength() )
+ break;
+ cChar = aOldMissingCodes.iterateCodePoints( &nStrIndex );
+ }
+ if( !rFontSelData.maSearchName.isEmpty() )
+ {
+ // remove cache entries that were still not resolved
+ for( nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); )
{
- // remove cache entries that were still not resolved
- for( nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); )
- {
- cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
- pFontInstance->IgnoreFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName );
- }
+ cChar = rMissingCodes.iterateCodePoints( &nStrIndex );
+ pFontInstance->IgnoreFallbackForUnicode( cChar, rFontSelData.GetWeight(), rFontSelData.maSearchName );
}
}
}