| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using FluentAssertions;
- using NUnit.Framework;
- using QuestPDF.Drawing;
- using SkiaSharp;
- using static SkiaSharp.SKFontStyleSlant;
- namespace QuestPDF.UnitTests
- {
- [TestFixture]
- public class FontStyleSetTests
- {
- private static void ExpectComparisonOrder(SKFontStyle target, SKFontStyle[] styles)
- {
- for (var i = 0; i < styles.Length - 1; i++)
- {
- var currentStyle = styles[i];
- var nextStyle = styles[i + 1];
-
- FontStyleSet.IsBetterMatch(target, currentStyle, nextStyle).Should().BeTrue();
- FontStyleSet.IsBetterMatch(target, nextStyle, currentStyle).Should().BeFalse();
- }
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_CondensedWidth()
- {
- var styles = new[]
- {
- new SKFontStyle(500, 5, Upright),
- new SKFontStyle(500, 4, Upright),
- new SKFontStyle(500, 3, Upright),
- new SKFontStyle(500, 6, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(500, 5, Upright), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_ExpandedWidth()
- {
- var styles = new[]
- {
- new SKFontStyle(500, 6, Upright),
- new SKFontStyle(500, 7, Upright),
- new SKFontStyle(500, 8, Upright),
- new SKFontStyle(500, 5, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(500, 6, Upright), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_ItalicSlant()
- {
- var styles = new[]
- {
- new SKFontStyle(500, 5, Italic),
- new SKFontStyle(500, 5, Oblique),
- new SKFontStyle(500, 5, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(500, 5, Italic), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_ObliqueSlant()
- {
- var styles = new[]
- {
- new SKFontStyle(500, 5, Oblique),
- new SKFontStyle(500, 5, Italic),
- new SKFontStyle(500, 5, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(500, 5, Oblique), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_UprightSlant()
- {
- var styles = new[]
- {
- new SKFontStyle(500, 5, Upright),
- new SKFontStyle(500, 5, Oblique),
- new SKFontStyle(500, 5, Italic)
- };
-
- ExpectComparisonOrder(new SKFontStyle(500, 5, Upright), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_ThinWeight()
- {
- var styles = new[]
- {
- new SKFontStyle(300, 5, Upright),
- new SKFontStyle(200, 5, Upright),
- new SKFontStyle(100, 5, Upright),
- new SKFontStyle(400, 5, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(300, 5, Upright), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_RegularWeight()
- {
- var styles = new[]
- {
- new SKFontStyle(500, 5, Upright),
- new SKFontStyle(300, 5, Upright),
- new SKFontStyle(100, 5, Upright),
- new SKFontStyle(600, 5, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(400, 5, Upright), styles);
- }
- [Test]
- public void FontStyleSet_IsBetterMatch_BoldWeight()
- {
- var styles = new[]
- {
- new SKFontStyle(600, 5, Upright),
- new SKFontStyle(700, 5, Upright),
- new SKFontStyle(800, 5, Upright),
- new SKFontStyle(500, 5, Upright)
- };
-
- ExpectComparisonOrder(new SKFontStyle(600, 5, Upright), styles);
- }
- [Test]
- public void FontStyleSet_RespectsPriority()
- {
- var styles = new[]
- {
- new SKFontStyle(600, 5, Italic),
- new SKFontStyle(600, 6, Upright),
- new SKFontStyle(500, 6, Italic)
- };
-
- ExpectComparisonOrder(new SKFontStyle(500, 5, Upright), styles);
- }
- }
- }
|