public static CssValue Font_Weight_Computed(ICssProperty Property) {/* Docs: https://drafts.csswg.org/css-fonts-4/#valdef-font-weight-bolder */ if (Property == null) { throw new ArgumentNullException(nameof(Property)); } Contract.EndContractBlock(); // handle font-weight related keywords // This function wouldnt even be called if the value werent a keyword var keyword = (Property as CssProperty).Specified.AsEnum <EFontWeight>(); int Weight = 400; switch (keyword) { case EFontWeight.Normal: Weight = 400; break; case EFontWeight.Bold: Weight = 700; break; case EFontWeight.Bolder: { /* Docs: https://drafts.csswg.org/css-fonts-4/#relative-weights */ CssValue inherited = Property.Find_Inherited_Value(); int w = inherited.AsInteger(); if (w < 100) { Weight = 400; } else if (w >= 100 && w < 350) { Weight = 400; } else if (w >= 350 && w < 550) { Weight = 700; } else if (w >= 550 && w < 750) { Weight = 900; } else if (w >= 750 && w < 900) { Weight = 900; } else { Weight = 900; } } break; case EFontWeight.Lighter: { /* Docs: https://drafts.csswg.org/css-fonts-4/#relative-weights */ CssValue inherited = Property.Find_Inherited_Value(); int w = inherited.AsInteger(); if (w < 100) { Weight = 100; } else if (w >= 100 && w < 350) { Weight = 100; } else if (w >= 350 && w < 550) { Weight = 100; } else if (w >= 550 && w < 750) { Weight = 400; } else if (w >= 750 && w < 900) { Weight = 700; } else { Weight = 700; } } break; } return(CssValue.From(Weight)); }