AngleSharp by Florian Rappl

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

.NET API 1,229,312 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 = new Dictionary<string, FontWeight>(StringComparer.OrdinalIgnoreCase) { { Keywords.Normal, new FontWeight { IsRelative = false, Value = 400 } }, { Keywords.Bold, new FontWeight { IsRelative = false, Value = 700 } }, { Keywords.Bolder, new FontWeight { IsRelative = true, Value = 100 } }, { Keywords.Lighter, new FontWeight { IsRelative = true, Value = -100 } } }.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; })); 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(CssValue value) { return Converter.Validate(value); } } }