From 22926dc2ae53b059f251c6585ef8650e13ae9c53 Mon Sep 17 00:00:00 2001 From: "pavlov@pavlov.net" Date: Sat, 22 Mar 2008 22:41:52 -0700 Subject: [PATCH] trial run for bug 424018. trying to fix Ts regression --- gfx/thebes/public/gfxWindowsFonts.h | 3 ++- gfx/thebes/src/gfxWindowsPlatform.cpp | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gfx/thebes/public/gfxWindowsFonts.h b/gfx/thebes/public/gfxWindowsFonts.h index 14f4516d6712..550f4f7430fa 100644 --- a/gfx/thebes/public/gfxWindowsFonts.h +++ b/gfx/thebes/public/gfxWindowsFonts.h @@ -64,12 +64,13 @@ public: THEBES_INLINE_DECL_REFCOUNTING(FontFamily) FontFamily(const nsAString& aName) : - mName(aName) + mName(aName), mHasStyles(PR_FALSE) { } nsTArray > mVariations; nsString mName; + PRBool mHasStyles; }; class FontEntry diff --git a/gfx/thebes/src/gfxWindowsPlatform.cpp b/gfx/thebes/src/gfxWindowsPlatform.cpp index 88109cc6b121..4aea9cd638b9 100644 --- a/gfx/thebes/src/gfxWindowsPlatform.cpp +++ b/gfx/thebes/src/gfxWindowsPlatform.cpp @@ -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 fe; @@ -252,8 +253,12 @@ gfxWindowsPlatform::FontGetStylesProc(nsStringHashKey::KeyType aKey, nsRefPtr& aFontFamily, void* userArg) { + /* NS_ASSERTION(aFontFamily->mVariations.Length() == 1, "We should only have 1 variation here"); nsRefPtr 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 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 ff = aFontFamily; + gfxWindowsPlatform::FontGetStylesProc(aKey, ff, &mFonts); + } + PRUint8 bestMatch = 0; PRBool italic = (aFontStyle->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0;