// font-descriptor: descriptor ':' value ';' // caller has advanced mToken to point at the descriptor internal bool ParseFontDescriptorValue(nsCSSFontDesc aDescID, ref nsCSSValue aValue) { switch (aDescID) { // These four are similar to the properties of the same name, // possibly with more restrictions on the values they can take. case nsCSSFontDesc.Family: { if (!ParseFamily(ref aValue) || aValue.GetUnit() != nsCSSUnit.Families) return false; // the style parameters to the nsFont constructor are ignored, // because it's only being used to call EnumerateFamilies string valueStr = ""; aValue.GetStringValue(ref valueStr); var font = new nsFont(valueStr, 0, 0, 0, 0, 0, 0); var dat = new ExtractFirstFamilyData(); font.EnumerateFamilies(ExtractFirstFamily, (object) dat); if (!dat.mGood) return false; aValue.SetStringValue(dat.mFamilyName, nsCSSUnit.String); return true; } goto case nsCSSFontDesc.Style; case nsCSSFontDesc.Style: // property is VARIANT_HMK|VARIANT_SYSFONT return ParseVariant(ref aValue, VARIANT_KEYWORD | VARIANT_NORMAL, nsCSSProps.kFontStyleKTable); case nsCSSFontDesc.Weight: return (ParseFontWeight(ref aValue) && aValue.GetUnit() != nsCSSUnit.Inherit && aValue.GetUnit() != nsCSSUnit.Initial && (aValue.GetUnit() != nsCSSUnit.Enumerated || (aValue.GetIntValue() != nsStyle.FONT_WEIGHT_BOLDER && aValue.GetIntValue() != nsStyle.FONT_WEIGHT_LIGHTER))); case nsCSSFontDesc.Stretch: // property is VARIANT_HK|VARIANT_SYSFONT return ParseVariant(ref aValue, VARIANT_KEYWORD, nsCSSProps.kFontStretchKTable); // These two are unique to @font-face and have their own special grammar. goto case nsCSSFontDesc.Src; case nsCSSFontDesc.Src: return ParseFontSrc(ref aValue); case nsCSSFontDesc.UnicodeRange: return ParseFontRanges(ref aValue); case nsCSSFontDesc.FontFeatureSettings: return ParseFontFeatureSettings(ref aValue); case nsCSSFontDesc.FontLanguageOverride: return ParseVariant(ref aValue, VARIANT_NORMAL | VARIANT_STRING, null); case nsCSSFontDesc.UNKNOWN: case nsCSSFontDesc.COUNT: Debug.Fail("bad nsCSSFontDesc code"); break; } // explicitly do NOT have a default case to let the compiler // help find missing descriptors return false; }