/// <summary> /// Filters font family values /// </summary> /// <param name="Property"></param> /// <returns></returns> public static CssValueList Font_Family_Used(ICssProperty Property) { if (Property == null) { throw new ArgumentNullException(nameof(Property)); } Contract.EndContractBlock(); #if DISABLE_FONT_SYSTEM return(null); #else CssValueList curValues = (Property as CssMultiValueProperty).Computed; List <CssValue> retValues = new List <CssValue>(); foreach (CssValue val in curValues) { switch (val.Type) { case ECssValueType.KEYWORD: { // Replace generic font-family keywords with a list of our fallback font-familys for that family var familyKeyword = val.AsEnum <EGenericFontFamily>(); switch (familyKeyword) { case EGenericFontFamily.Serif: case EGenericFontFamily.SansSerif: case EGenericFontFamily.Monospace: case EGenericFontFamily.Cursive: case EGenericFontFamily.Fantasy: { if (FontManager.GenericFamilyMap.TryGetValue(outFamily, out List <CssValue> GenericFontFamilys)) { retValues.AddRange(GenericFontFamilys); } } break; default: throw new NotImplementedException($"Unknown font-family keyword '{val.Value.ToString()}'"); } } break; case ECssValueType.STRING: { // Remove any invalid font-familys foreach (FontFamily family in SystemFonts.Families) { if (0 == Unicode.CaselessCompare(val.AsString, family.Name)) { // Found it! retValues.Add(val); break; } } } break; default: { retValues.Add(val); } break; } } return((retValues.Count > 0) ? new CssValueList(retValues) : null); #endif }