diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index 487efac812b..9d4eb99cc84 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -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); diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 446e236ee88..2424ef219f2 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -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 diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index fa7e479bdfe..3e94cfce56a 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -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 {