Bug 1031199 - Disallow aWeight = 0 when calling gfxUserFontSet::AddFontFace. r=jdaggett

This commit is contained in:
Cameron McCormack 2014-06-30 14:25:11 +10:00
Родитель 969488c5d0
Коммит 364e126c76
3 изменённых файлов: 7 добавлений и 4 удалений

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

@ -129,14 +129,14 @@ gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
const nsString& aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges)
{
MOZ_ASSERT(aWeight != 0,
"aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead");
nsAutoString key(aFamilyName);
ToLowerCase(key);
bool found;
if (aWeight == 0)
aWeight = NS_FONT_WEIGHT_NORMAL;
// stretch, italic/oblique ==> zero implies normal
gfxMixedFontFamily *family = mFontFamilies.GetWeak(key, &found);

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

@ -167,7 +167,7 @@ public:
// add in a font face
// weight - 0 == unknown, [100, 900] otherwise (multiples of 100)
// weight - [100, 900] (multiples of 100)
// stretch = [NS_FONT_STRETCH_ULTRA_CONDENSED, NS_FONT_STRETCH_ULTRA_EXPANDED]
// italic style = constants in gfxFontConstants.h, e.g. NS_FONT_STYLE_NORMAL
// TODO: support for unicode ranges not yet implemented

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

@ -578,6 +578,9 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule* aRule, uint8_t aSheetType,
unit = val.GetUnit();
if (unit == eCSSUnit_Integer || unit == eCSSUnit_Enumerated) {
weight = val.GetIntValue();
if (weight == 0) {
weight = NS_STYLE_FONT_STYLE_NORMAL;
}
} else if (unit == eCSSUnit_Normal) {
weight = NS_STYLE_FONT_WEIGHT_NORMAL;
} else {