Browse Source

Bug fixes + test

MarcinZiabek 2 years ago
parent
commit
fdc395f956

+ 6 - 5
Source/QuestPDF.Examples/TextExamples.cs

@@ -1018,11 +1018,12 @@ namespace QuestPDF.Examples
                     {
                     {
                         page.Margin(50);
                         page.Margin(50);
                         page.PageColor(Colors.White);
                         page.PageColor(Colors.White);
-                        page.Size(PageSizes.A6.Landscape());
+                        page.Size(PageSizes.A5.Landscape());
                         
                         
                         page.DefaultTextStyle(x => x
                         page.DefaultTextStyle(x => x
                             .FontSize(24)
                             .FontSize(24)
                             .Bold()
                             .Bold()
+                            .FontFamily("Times New Roman")
                             .Fallback(y => y
                             .Fallback(y => y
                                 .FontFamily("Microsoft YaHei")
                                 .FontFamily("Microsoft YaHei")
                                 .Underline()
                                 .Underline()
@@ -1030,10 +1031,10 @@ namespace QuestPDF.Examples
 
 
                         page.Content().Text(text =>
                         page.Content().Text(text =>
                         {
                         {
-                            text.Line("Normal 中文文本 text.");
-                            text.Line("Background 中文文本 text.").NormalWeight().BackgroundColor(Colors.Green.Lighten2);
-                            text.Line("Background 中文文本 text.").Strikethrough().Underline(false);
-                            text.Line("Background 中文文本 text.").Italic();
+                            text.Line("Default times new roman 中文文本 text.");
+                            text.Line("Normal weight and green 中文文本 text.").NormalWeight().BackgroundColor(Colors.Green.Lighten2);
+                            text.Line("Strikethrough without underline 中文文本 text.").Strikethrough().Underline(false);
+                            text.Line("Lato italic 中文文本 text.").FontFamily("Lato").Italic();
                         });
                         });
                     });
                     });
                 });
                 });

+ 3 - 2
Source/QuestPDF.UnitTests/TextStyleTests.cs

@@ -10,7 +10,7 @@ namespace QuestPDF.UnitTests
     public class TextStyleTests
     public class TextStyleTests
     {
     {
         [Test]
         [Test]
-        public void Font()
+        public void ApplyInheritedAndGlobalStyle()
         {
         {
             // arrange
             // arrange
             var defaultTextStyle = TextStyle
             var defaultTextStyle = TextStyle
@@ -26,6 +26,7 @@ namespace QuestPDF.UnitTests
 
 
             var spanTextStyle = TextStyle
             var spanTextStyle = TextStyle
                 .Default
                 .Default
+                .FontFamily("Times New Roman")
                 .Bold()
                 .Bold()
                 .Strikethrough()
                 .Strikethrough()
                 .BackgroundColor(Colors.Red.Lighten2);
                 .BackgroundColor(Colors.Red.Lighten2);
@@ -37,7 +38,7 @@ namespace QuestPDF.UnitTests
             var expectedStyle = TextStyle.LibraryDefault with
             var expectedStyle = TextStyle.LibraryDefault with
             {
             {
                 Size = 20, 
                 Size = 20, 
-                FontFamily = "Arial",
+                FontFamily = "Times New Roman",
                 FontWeight = FontWeight.Bold,
                 FontWeight = FontWeight.Bold,
                 BackgroundColor = Colors.Red.Lighten2,
                 BackgroundColor = Colors.Red.Lighten2,
                 HasStrikethrough = true,
                 HasStrikethrough = true,

+ 1 - 1
Source/QuestPDF/Infrastructure/TextStyleManager.cs

@@ -228,7 +228,7 @@ namespace QuestPDF.Infrastructure
         internal static TextStyle ApplyInheritedStyle(this TextStyle style, TextStyle parent)
         internal static TextStyle ApplyInheritedStyle(this TextStyle style, TextStyle parent)
         {
         {
             var cacheKey = (style, parent);
             var cacheKey = (style, parent);
-            return TextStyleApplyInheritedCache.GetOrAdd(cacheKey, key => key.origin.ApplyStyleProperties(key.parent, overrideStyle: false, overrideFontFamily: true, applyFallback: true).UpdateFontFallback(true));
+            return TextStyleApplyInheritedCache.GetOrAdd(cacheKey, key => key.origin.ApplyStyleProperties(key.parent, overrideStyle: false, overrideFontFamily: false, applyFallback: true).UpdateFontFallback(true));
         }
         }
         
         
         internal static TextStyle ApplyGlobalStyle(this TextStyle style)
         internal static TextStyle ApplyGlobalStyle(this TextStyle style)