Kaydet (Commit) 03bff1b6 authored tarafından Khaled Hosny's avatar Khaled Hosny

tdf#71603: Improve font fallback on Windows a bit

Check all missing characters, not just the first one. Also the calling
sites for GlyphFallbackFontSubstitution hook expect the OUString to be
updated to have only any characters not supported by the returned font.

Change-Id: Ife56d692c05433f2f7fe02db3ef1562181dc3d53
üst d66ec48f
......@@ -151,7 +151,7 @@ public:
bool FindFontSubstitute( FontSelectPattern&, OUString& rMissingChars ) const override;
private:
HDC mhDC;
bool HasMissingChars( PhysicalFontFace*, const OUString& rMissingChars ) const;
bool HasMissingChars(PhysicalFontFace*, OUString& rMissingChars) const;
};
inline WinGlyphFallbackSubstititution::WinGlyphFallbackSubstititution( HDC hDC )
......@@ -159,7 +159,7 @@ inline WinGlyphFallbackSubstititution::WinGlyphFallbackSubstititution( HDC hDC )
{}
// does a font face hold the given missing characters?
bool WinGlyphFallbackSubstititution::HasMissingChars( PhysicalFontFace* pFace, const OUString& rMissingChars ) const
bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OUString& rMissingChars) const
{
WinFontFace* pWinFont = static_cast< WinFontFace* >(pFace);
FontCharMapRef xFontCharMap = pWinFont->GetFontCharMap();
......@@ -194,19 +194,24 @@ bool WinGlyphFallbackSubstititution::HasMissingChars( PhysicalFontFace* pFace, c
return false;
int nMatchCount = 0;
// static const int nMaxMatchCount = 1; // TODO: tolerate more missing characters?
std::vector<sal_UCS4> rRemainingCodes;
const sal_Int32 nStrLen = rMissingChars.getLength();
for( sal_Int32 nStrIdx = 0; nStrIdx < nStrLen; /* ++nStrIdx unreachable code, see the 'break' below */ )
sal_Int32 nStrIdx = 0;
while (nStrIdx < nStrLen)
{
const sal_UCS4 uChar = rMissingChars.iterateCodePoints( &nStrIdx );
nMatchCount += xFontCharMap->HasChar( uChar ) ? 1 : 0;
break; // for now
if (xFontCharMap->HasChar(uChar))
nMatchCount++;
else
rRemainingCodes.push_back(uChar);
}
xFontCharMap = nullptr;
const bool bHasMatches = (nMatchCount > 0);
return bHasMatches;
if (nMatchCount > 0)
rMissingChars = OUString(rRemainingCodes.data(), rRemainingCodes.size());
return nMatchCount > 0;
}
namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment