AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.2" />

.NET API 1,168,384 bytes

 CssFontWeightProperty

Information: https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
using AngleSharp.Css; using AngleSharp.Extensions; using System; using System.Collections.Generic; namespace AngleSharp.Dom.Css { internal sealed class CssFontWeightProperty : CssProperty { internal struct FontWeight { public bool IsRelative; public int Value; } internal static readonly IValueConverter<FontWeight> Converter; internal CssFontWeightProperty(CssStyleDeclaration rule) : base(PropertyNames.FontWeight, rule, PropertyFlags.Inherited | PropertyFlags.Animatable) { } protected override object GetDefault(IElement element) { FontWeight fontWeight = default(FontWeight); fontWeight.IsRelative = false; fontWeight.Value = 400; return fontWeight; } protected override object Compute(IElement element) { return Converter.Convert(base.Value); } protected override bool IsValid(ICssValue value) { return Converter.Validate(value); } static CssFontWeightProperty() { Dictionary<string, FontWeight> dictionary = new Dictionary<string, FontWeight>(StringComparer.OrdinalIgnoreCase); string normal = Keywords.Normal; FontWeight value = new FontWeight { IsRelative = false, Value = 400 }; dictionary.Add(normal, value); string bold = Keywords.Bold; value = new FontWeight { IsRelative = false, Value = 700 }; dictionary.Add(bold, value); string bolder = Keywords.Bolder; value = new FontWeight { IsRelative = true, Value = 100 }; dictionary.Add(bolder, value); string lighter = Keywords.Lighter; value = new FontWeight { IsRelative = true, Value = -100 }; dictionary.Add(lighter, value); Converter = dictionary.ToConverter().Or(Converters.IntegerConverter.Constraint(delegate(int m) { if (m >= 100) return m <= 900; return false; }).To(delegate(int m) { FontWeight result = default(FontWeight); result.IsRelative = false; result.Value = m; return result; })); } } }