Skip to content

Commit

Permalink
Merge pull request #175 from BoricuaEnLaLuna/fixFontDefaultValues
Browse files Browse the repository at this point in the history
Expose font default values
  • Loading branch information
TylerBrinks authored Feb 12, 2024
2 parents fb8266d + 8e5ab83 commit 35fb718
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
42 changes: 42 additions & 0 deletions src/ExCSS.Tests/FontProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,48 @@ public void CssFontSystemFamilyLegal()
Assert.Equal("status-bar", concrete.Value);
}

[Fact]
public void CssFontInitialAll()
{
var snippet = "font: initial ";
var property = ParseDeclaration(snippet);
Assert.Equal("font", property.Name);
Assert.False(property.IsImportant);
Assert.IsType<FontProperty>(property);
var concrete = (FontProperty)property;
Assert.True(concrete.IsInherited);
Assert.True(concrete.HasValue);
Assert.Equal("initial", concrete.Value);
}

[Fact]
public void CssFontInheritAll()
{
var snippet = "font: inherit ";
var property = ParseDeclaration(snippet);
Assert.Equal("font", property.Name);
Assert.False(property.IsImportant);
Assert.IsType<FontProperty>(property);
var concrete = (FontProperty)property;
Assert.True(concrete.IsInherited);
Assert.True(concrete.HasValue);
Assert.Equal("inherit", concrete.Value);
}

[Fact]
public void CssFontUnsetAll()
{
var snippet = "font: unset ";
var property = ParseDeclaration(snippet);
Assert.Equal("font", property.Name);
Assert.False(property.IsImportant);
Assert.IsType<FontProperty>(property);
var concrete = (FontProperty)property;
Assert.False(concrete.IsInherited);
Assert.True(concrete.HasValue);
Assert.Equal("unset", concrete.Value);
}

[Fact]
public void CssFontFaceWithThreeRulesShouldSerializeCorrectly()
{
Expand Down
5 changes: 3 additions & 2 deletions src/ExCSS/StyleProperties/Font/FontProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ internal sealed class FontProperty : ShorthandProperty
WithOrder(
FontSizeConverter.Required().For(PropertyNames.FontSize),
LineHeightConverter.StartsWithDelimiter().Option().For(PropertyNames.LineHeight),
FontFamiliesConverter.Required().For(PropertyNames.FontFamily))).Or(
SystemFontConverter);
FontFamiliesConverter.Required().For(PropertyNames.FontFamily)))
.Or(SystemFontConverter)
.OrGlobalValue();

internal FontProperty()
: base(PropertyNames.Font, PropertyFlags.Inherited | PropertyFlags.Animatable)
Expand Down

0 comments on commit 35fb718

Please sign in to comment.