trial run for bug 424018. trying to fix Ts regression

This commit is contained in:
pavlov@pavlov.net 2008-03-22 22:41:52 -07:00
parent 77c1f7673e
commit 22926dc2ae
2 changed files with 15 additions and 6 deletions

View File

@ -64,12 +64,13 @@ public:
THEBES_INLINE_DECL_REFCOUNTING(FontFamily)
FontFamily(const nsAString& aName) :
mName(aName)
mName(aName), mHasStyles(PR_FALSE)
{
}
nsTArray<nsRefPtr<FontEntry> > mVariations;
nsString mName;
PRBool mHasStyles;
};
class FontEntry

View File

@ -129,6 +129,7 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe,
if (!ht->Get(name, &ff)) {
ff = new FontFamily(nsDependentString(logFont.lfFaceName));
ht->Put(name, ff);
return 1;
}
nsRefPtr<FontEntry> fe;
@ -252,8 +253,12 @@ gfxWindowsPlatform::FontGetStylesProc(nsStringHashKey::KeyType aKey,
nsRefPtr<FontFamily>& aFontFamily,
void* userArg)
{
/*
NS_ASSERTION(aFontFamily->mVariations.Length() == 1, "We should only have 1 variation here");
nsRefPtr<FontEntry> aFontEntry = aFontFamily->mVariations[0];
*/
NS_ASSERTION(!aFontFamily->mHasStyles, "Already got styles for this family");
aFontFamily->mHasStyles = PR_TRUE;
HDC hdc = GetDC(nsnull);
@ -261,9 +266,9 @@ gfxWindowsPlatform::FontGetStylesProc(nsStringHashKey::KeyType aKey,
memset(&logFont, 0, sizeof(LOGFONTW));
logFont.lfCharSet = DEFAULT_CHARSET;
logFont.lfPitchAndFamily = 0;
PRUint32 l = PR_MIN(aFontEntry->GetName().Length(), LF_FACESIZE - 1);
PRUint32 l = PR_MIN(aFontFamily->mName.Length(), LF_FACESIZE - 1);
memcpy(logFont.lfFaceName,
nsPromiseFlatString(aFontEntry->GetName()).get(),
nsPromiseFlatString(aFontFamily->mName).get(),
l * sizeof(PRUnichar));
logFont.lfFaceName[l] = 0;
@ -386,9 +391,6 @@ gfxWindowsPlatform::UpdateFontList()
EnumFontFamiliesExW(dc, &logFont, (FONTENUMPROCW)gfxWindowsPlatform::FontEnumProc, (LPARAM)&mFonts, 0);
::ReleaseDC(nsnull, dc);
// Look for additional styles
mFonts.Enumerate(gfxWindowsPlatform::FontGetStylesProc, &mFonts);
// Create the list of FontSubstitutes
nsCOMPtr<nsIWindowsRegKey> regKey = do_CreateInstance("@mozilla.org/windows-registry-key;1");
if (!regKey)
@ -691,6 +693,12 @@ gfxWindowsPlatform::FindFontEntry(const nsAString& aName, const gfxFontStyle *aF
FontEntry *
gfxWindowsPlatform::FindFontEntry(FontFamily *aFontFamily, const gfxFontStyle *aFontStyle)
{
if (!aFontFamily->mHasStyles) {
nsStringHashKey::KeyType aKey = aFontFamily->mName;
nsRefPtr<FontFamily> ff = aFontFamily;
gfxWindowsPlatform::FontGetStylesProc(aKey, ff, &mFonts);
}
PRUint8 bestMatch = 0;
PRBool italic = (aFontStyle->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0;