|
|
@@ -122,6 +122,67 @@ namespace QuestPDF.UnitTests
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region Font Features
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FontFeatures_Default()
|
|
|
+ {
|
|
|
+ var textStyle = TextStyle.LibraryDefault;
|
|
|
+ Assert.That(textStyle.FontFeatures, Is.Empty);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void EnableFontFeature_SingleFeature()
|
|
|
+ {
|
|
|
+ var textStyle = TextStyle.Default
|
|
|
+ .EnableFontFeature(FontFeatures.StandardLigatures);
|
|
|
+
|
|
|
+ Assert.That(textStyle.FontFeatures, Has.Length.EqualTo(1));
|
|
|
+ Assert.That(textStyle.FontFeatures[0], Is.EqualTo((FontFeatures.StandardLigatures, true)));
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void DisableFontFeature_SingleFeature()
|
|
|
+ {
|
|
|
+ var textStyle = TextStyle.Default
|
|
|
+ .DisableFontFeature(FontFeatures.Kerning);
|
|
|
+
|
|
|
+ Assert.That(textStyle.FontFeatures, Has.Length.EqualTo(1));
|
|
|
+ Assert.That(textStyle.FontFeatures[0], Is.EqualTo((FontFeatures.Kerning, false)));
|
|
|
+ }
|
|
|
+
|
|
|
+ // NOTE: font features applied further down the chain override those applied earlier, and will appear first in the list
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FontFeatures_MixedEnableDisable()
|
|
|
+ {
|
|
|
+ var textStyle = TextStyle.Default
|
|
|
+ .EnableFontFeature(FontFeatures.StandardLigatures)
|
|
|
+ .DisableFontFeature(FontFeatures.Kerning)
|
|
|
+ .EnableFontFeature(FontFeatures.DiscretionaryLigatures);
|
|
|
+
|
|
|
+ Assert.That(textStyle.FontFeatures, Has.Length.EqualTo(3));
|
|
|
+ Assert.That(textStyle.FontFeatures[0], Is.EqualTo((FontFeatures.DiscretionaryLigatures, true)));
|
|
|
+ Assert.That(textStyle.FontFeatures[1], Is.EqualTo((FontFeatures.Kerning, false)));
|
|
|
+ Assert.That(textStyle.FontFeatures[2], Is.EqualTo((FontFeatures.StandardLigatures, true)));
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ public void FontFeatures_OverrideSameFeature()
|
|
|
+ {
|
|
|
+ var textStyle = TextStyle.Default
|
|
|
+ .EnableFontFeature(FontFeatures.StandardLigatures)
|
|
|
+ .DisableFontFeature(FontFeatures.Kerning)
|
|
|
+ .DisableFontFeature(FontFeatures.Kerning)
|
|
|
+ .DisableFontFeature(FontFeatures.StandardLigatures);
|
|
|
+
|
|
|
+ Assert.That(textStyle.FontFeatures, Has.Length.EqualTo(2));
|
|
|
+ Assert.That(textStyle.FontFeatures[0], Is.EqualTo((FontFeatures.StandardLigatures, false)));
|
|
|
+ Assert.That(textStyle.FontFeatures[1], Is.EqualTo((FontFeatures.Kerning, false)));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
[Test]
|
|
|
public void ApplyInheritedAndGlobalStyle()
|
|
|
{
|