From af22ce56da1232a596ace75614f916b8cf416e8a Mon Sep 17 00:00:00 2001 From: "pavlov%pavlov.net" Date: Thu, 15 Jun 2006 07:20:19 +0000 Subject: [PATCH] disable weight table code for now... --- gfx/thebes/public/gfxWindowsFonts.h | 17 +++++++++++------ gfx/thebes/src/gfxWindowsFonts.cpp | 16 ++++++++++++---- gfx/thebes/src/gfxWindowsPlatform.cpp | 18 ++++++++++++------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/gfx/thebes/public/gfxWindowsFonts.h b/gfx/thebes/public/gfxWindowsFonts.h index f340f110708..db94c7ad698 100644 --- a/gfx/thebes/public/gfxWindowsFonts.h +++ b/gfx/thebes/public/gfxWindowsFonts.h @@ -64,20 +64,24 @@ * Only nine steps of bolder or lighter are allowed by the CSS XPCODE. */ // XXX change this from using a bitset to something cleaner eventually -class WeightTable { +class WeightTable +{ public: THEBES_DECL_REFCOUNTING WeightTable() : mWeights(0) {} + ~WeightTable() { + + } PRBool TriedWeight(PRUint8 aWeight) { - return mWeights[aWeight + 10]; + return mWeights[aWeight - 1 + 10]; } PRBool HasWeight(PRUint8 aWeight) { - return mWeights[aWeight]; + return mWeights[aWeight - 1]; } void SetWeight(PRUint8 aWeight, PRBool aValue) { - mWeights[aWeight] = aValue; - mWeights[aWeight + 10] = PR_TRUE; + mWeights[aWeight - 1] = aValue; + mWeights[aWeight - 1 + 10] = PR_TRUE; } private: @@ -88,7 +92,8 @@ private: /* Unicode subrange table * from: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_63ub.asp */ -struct UnicodeRangeTableEntry { +struct UnicodeRangeTableEntry +{ PRUint8 bit; PRUint32 start; PRUint32 end; diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp index 252f6c9a101..801decf2009 100644 --- a/gfx/thebes/src/gfxWindowsFonts.cpp +++ b/gfx/thebes/src/gfxWindowsFonts.cpp @@ -162,6 +162,7 @@ gfxWindowsFont::MakeCairoFontFace() if (mFont) return cairo_win32_font_face_create_for_hfont(mFont); +#if 0 if (!mWeightTable) { nsString name(mName); ToLowerCase(name); @@ -174,6 +175,7 @@ gfxWindowsFont::MakeCairoFontFace() platform->PutFontWeightTable(name, mWeightTable); } } +#endif /* XXX split this code out some, make it a bit more CSS2 15.5.1 compliant */ PRInt16 baseWeight, weightDistance; @@ -186,11 +188,14 @@ gfxWindowsFont::MakeCairoFontFace() if (weightDistance >= 0) { for (PRUint16 i = baseWeight, k = 0; i < 10; i++) { +#if 0 if (mWeightTable->HasWeight(i)) { k++; + chosenWeight = i * 100; } else if (mWeightTable->TriedWeight(i)) { continue; } else { +#endif const PRUint32 tryWeight = i * 100; if (!dc) @@ -203,19 +208,22 @@ gfxWindowsFont::MakeCairoFontFace() GetTextMetrics(dc, &metrics); PRBool hasWeight = (metrics.tmWeight == tryWeight); - mWeightTable->SetWeight(i, hasWeight); - if (hasWeight) + // mWeightTable->SetWeight(i, hasWeight); + if (hasWeight) { + chosenWeight = i * 100; k++; + } SelectObject(dc, oldFont); if (k <= weightDistance) { DeleteObject(mFont); mFont = nsnull; } +#if 0 } - +#endif if (k > weightDistance) { - chosenWeight = i * 100;; + chosenWeight = i * 100; break; } } diff --git a/gfx/thebes/src/gfxWindowsPlatform.cpp b/gfx/thebes/src/gfxWindowsPlatform.cpp index 5154d6d9797..0e950904372 100644 --- a/gfx/thebes/src/gfxWindowsPlatform.cpp +++ b/gfx/thebes/src/gfxWindowsPlatform.cpp @@ -88,7 +88,7 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe, ToLowerCase(name); nsRefPtr fe; - if (!thisp->mFonts.Get(nsDependentString(name), &fe)) { + if (!thisp->mFonts.Get(name, &fe)) { fe = new FontEntry(nsDependentString(logFont.lfFaceName), (PRUint16)fontType); thisp->mFonts.Put(name, fe); } @@ -96,11 +96,14 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe, // mark the charset bit fe->mCharset[metrics.tmCharSet] = 1; - - // XXX Populate weight table here - WeightTable *wt = new WeightTable(); - wt->SetWeight(PR_MAX(1, PR_MIN(9, metrics.tmWeight / 100)), PR_TRUE); - thisp->PutFontWeightTable(name, wt); +#if 0 + nsRefPtr wt; + if (!thisp->mFontWeights.Get(name, &wt)) { + wt = new WeightTable(); + wt->SetWeight(PR_MAX(1, PR_MIN(9, metrics.tmWeight / 100)), PR_TRUE); + thisp->mFontWeights.Put(name, wt); + } +#endif fe->mFamily = logFont.lfPitchAndFamily & 0xF0; fe->mPitch = logFont.lfPitchAndFamily & 0x0F; @@ -373,6 +376,9 @@ gfxWindowsPlatform::GetFontWeightTable(const nsAString& aName) return nsnull; } return wt; + WeightTable *ret = wt; + NS_IF_ADDREF(ret); + return ret; } void