mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 396732. Cache codepoints with no fonts to avoid repeated system-wide font lookup. r+sr=vlad
This commit is contained in:
parent
61383653db
commit
d47e718e08
@ -143,7 +143,13 @@ public:
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// clear out all blocks in the array
|
||||
void reset() {
|
||||
PRUint32 i;
|
||||
for (i = 0; i < mBlocks.Length(); i++)
|
||||
mBlocks[i] = nsnull;
|
||||
}
|
||||
|
||||
nsTArray< nsAutoPtr<Block> > mBlocks;
|
||||
};
|
||||
|
||||
|
@ -215,6 +215,9 @@ private:
|
||||
// maps list of family names ==> array of family entries, one per lang group
|
||||
nsDataHashtable<nsUint32HashKey, nsTArray<nsRefPtr<MacOSFamilyEntry> > > mPrefFonts;
|
||||
|
||||
// when system-wide font lookup fails for a character, cache it to skip future searches
|
||||
gfxSparseBitSet mCodepointsWithNoFonts;
|
||||
|
||||
};
|
||||
|
||||
#endif /* GFXQUARTZFONTCACHE_H_ */
|
||||
|
@ -532,6 +532,7 @@ gfxQuartzFontCache::InitFontList()
|
||||
mFontFamilies.Clear();
|
||||
mLocalizedFamilies.Clear();
|
||||
mPrefFonts.Clear();
|
||||
mCodepointsWithNoFonts.reset();
|
||||
|
||||
// iterate over available families
|
||||
NSFontManager *fontManager = [NSFontManager sharedFontManager];
|
||||
@ -618,6 +619,11 @@ gfxQuartzFontCache::InitFontList()
|
||||
|
||||
// xxx - need to remove bogus Helvetica/Courier italic faces (Cocoa inanity!)
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be skipped
|
||||
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
|
||||
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
|
||||
mCodepointsWithNoFonts.set(0xfffd); // unknown
|
||||
|
||||
[localizedNames release];
|
||||
}
|
||||
|
||||
@ -701,11 +707,21 @@ gfxQuartzFontCache::GetFontList (const nsACString& aLangGroup,
|
||||
MacOSFontEntry*
|
||||
gfxQuartzFontCache::FindFontForChar(const PRUint32 aCh, gfxAtsuiFont *aPrevFont)
|
||||
{
|
||||
// is codepoint with no matching font? return null immediately
|
||||
if (mCodepointsWithNoFonts.test(aCh)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
FontSearch data(aCh, aPrevFont);
|
||||
|
||||
// iterate over all font families to find a font that support the character
|
||||
mFontFamilies.Enumerate(gfxQuartzFontCache::FindFontForCharProc, &data);
|
||||
|
||||
// no match? add to set of non-matching codepoints
|
||||
if (!data.bestMatch) {
|
||||
mCodepointsWithNoFonts.set(aCh);
|
||||
}
|
||||
|
||||
return data.bestMatch;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user