summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-11-01 23:15:44 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2016-11-01 23:46:32 +0200
commit03bff1b6b953e4b7a54d2fb7bbf366bea7e959d9 (patch)
tree21fb4db16709a5e4cc17915d35def06c043db47e
parentd66ec48fe879a26ec542661c04e5c2b8271b7d64 (diff)
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
-rw-r--r--vcl/win/gdi/salfont.cxx21
1 files changed, 13 insertions, 8 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index c8c9893385de..8d6f0656b1fa 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -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