turning weight table code back on with fix for crash. bug 341439. r=vlad

This commit is contained in:
pavlov%pavlov.net 2006-06-15 21:35:06 +00:00
Родитель 48969ba5fd
Коммит 8abe98d9d7
3 изменённых файлов: 5 добавлений и 31 удалений

Просмотреть файл

@ -67,8 +67,6 @@ public:
/* local methods */
FontEntry *FindFontEntry(const nsAString& aName) const;
void GetPrefFonts(const char *aLangGroup, nsString& array);
void FindOtherFonts(const PRUnichar *aString, PRUint32 aLength, const char *aGeneric, nsString& array);

Просмотреть файл

@ -162,7 +162,6 @@ gfxWindowsFont::MakeCairoFontFace()
if (mFont)
return cairo_win32_font_face_create_for_hfont(mFont);
#if 0
if (!mWeightTable) {
nsString name(mName);
ToLowerCase(name);
@ -175,9 +174,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;
mStyle->ComputeWeightAndOffset(&baseWeight, &weightDistance);
@ -188,14 +185,12 @@ 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)
@ -208,7 +203,7 @@ gfxWindowsFont::MakeCairoFontFace()
GetTextMetrics(dc, &metrics);
PRBool hasWeight = (metrics.tmWeight == tryWeight);
// mWeightTable->SetWeight(i, hasWeight);
mWeightTable->SetWeight(i, hasWeight);
if (hasWeight) {
chosenWeight = i * 100;
k++;
@ -219,9 +214,8 @@ gfxWindowsFont::MakeCairoFontFace()
DeleteObject(mFont);
mFont = nsnull;
}
#if 0
}
#endif
if (k > weightDistance) {
chosenWeight = i * 100;
break;
@ -375,8 +369,8 @@ gfxWindowsFont::FillLogFont(PRInt16 currentWeight)
mLogFont.lfItalic = (mStyle->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) ? TRUE : FALSE;
mLogFont.lfWeight = currentWeight;
int len = PR_MIN(mName.Length(), LF_FACESIZE);
memcpy(mLogFont.lfFaceName, mName.get(), len * 2);
int len = PR_MIN(mName.Length(), LF_FACESIZE - 1);
memcpy(mLogFont.lfFaceName, nsPromiseFlatString(mName).get(), len * 2);
mLogFont.lfFaceName[len] = '\0';
}

Просмотреть файл

@ -96,14 +96,13 @@ gfxWindowsPlatform::FontEnumProc(const ENUMLOGFONTEXW *lpelfe,
// mark the charset bit
fe->mCharset[metrics.tmCharSet] = 1;
#if 0
// put this in the weight table
nsRefPtr<WeightTable> 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;
@ -175,20 +174,6 @@ gfxWindowsPlatform::UpdateFontList()
return NS_OK;
}
FontEntry *
gfxWindowsPlatform::FindFontEntry(const nsAString& aName) const
{
nsRefPtr<FontEntry> fe;
nsString lc(aName);
ToLowerCase(lc);
mFonts.Get(lc, &fe);
FontEntry *ret = fe;
NS_IF_ADDREF(ret);
return ret;
}
struct FontMatch {
FontMatch() : rank(0) {}
PRBool operator <(const FontMatch& other) const { return (rank < other.rank); }
@ -376,9 +361,6 @@ gfxWindowsPlatform::GetFontWeightTable(const nsAString& aName)
return nsnull;
}
return wt;
WeightTable *ret = wt;
NS_IF_ADDREF(ret);
return ret;
}
void