diff --git a/QuestPDF.Examples/TextBenchmark.cs b/QuestPDF.Examples/TextBenchmark.cs
index a5d1fb9..053fbaf 100644
--- a/QuestPDF.Examples/TextBenchmark.cs
+++ b/QuestPDF.Examples/TextBenchmark.cs
@@ -111,7 +111,7 @@ namespace QuestPDF.Examples
{
page.Margin(50);
- page.Content().Column(column =>
+ page.Content().PaddingVertical(10).Column(column =>
{
column.Item().Element(Title);
column.Item().PageBreak();
diff --git a/QuestPDF.Examples/TextExamples.cs b/QuestPDF.Examples/TextExamples.cs
index c68252a..905bcb8 100644
--- a/QuestPDF.Examples/TextExamples.cs
+++ b/QuestPDF.Examples/TextExamples.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Text;
using NUnit.Framework;
+using QuestPDF.Elements.Text;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
@@ -618,5 +619,43 @@ namespace QuestPDF.Examples
.FontSize(20);
});
}
+
+ [Test]
+ public void FontFallback()
+ {
+ RenderingTest
+ .Create()
+ .ProduceImages()
+ .ShowResults()
+ .RenderDocument(container =>
+ {
+ container.Page(page =>
+ {
+ page.Margin(50);
+ page.PageColor(Colors.White);
+ page.DefaultTextStyle(x => x
+ .Fallback(y => y.FontFamily("Segoe UI Emoji")
+ .Fallback(y => y.FontFamily("Microsoft YaHei"))));
+
+ page.Size(PageSizes.A4);
+
+ page.Content().Text(t =>
+ {
+ t.Line("This is normal text.");
+ t.EmptyLine();
+
+ t.Line("Following line should use font fallback:");
+ t.Line("中文文本");
+ t.EmptyLine();
+
+ t.Line("The following line contains a mix of known and unknown characters.");
+ t.Line("Mixed line: This 中文 is 文文 a mixed 本 本 line 本 中文文本!");
+ t.EmptyLine();
+
+ t.Line("Emojis work out of the box because of font fallback: 😊😅🥳👍❤😍👌");
+ });
+ });
+ });
+ }
}
}
\ No newline at end of file
diff --git a/QuestPDF.Previewer/QuestPDF.Previewer.csproj b/QuestPDF.Previewer/QuestPDF.Previewer.csproj
index 64b7719..196a94f 100644
--- a/QuestPDF.Previewer/QuestPDF.Previewer.csproj
+++ b/QuestPDF.Previewer/QuestPDF.Previewer.csproj
@@ -4,7 +4,7 @@
MarcinZiabek
CodeFlint
QuestPDF.Previewer
- 2022.8.0
+ 2022.9.0
true
questpdf-previewer
QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.
diff --git a/QuestPDF/Drawing/DocumentGenerator.cs b/QuestPDF/Drawing/DocumentGenerator.cs
index c24e285..b64baac 100644
--- a/QuestPDF/Drawing/DocumentGenerator.cs
+++ b/QuestPDF/Drawing/DocumentGenerator.cs
@@ -172,7 +172,7 @@ namespace QuestPDF.Drawing
{
if (textBlockItem is TextBlockSpan textSpan)
{
- textSpan.Style.ApplyGlobalStyle(documentDefaultTextStyle);
+ textSpan.Style = textSpan.Style.ApplyGlobalStyle(documentDefaultTextStyle);
}
else if (textBlockItem is TextBlockElement textElement)
{
@@ -184,18 +184,13 @@ namespace QuestPDF.Drawing
}
if (content is DynamicHost dynamicHost)
- dynamicHost.TextStyle.ApplyGlobalStyle(documentDefaultTextStyle);
-
- var targetTextStyle = documentDefaultTextStyle;
+ dynamicHost.TextStyle = dynamicHost.TextStyle.ApplyGlobalStyle(documentDefaultTextStyle);
if (content is DefaultTextStyle defaultTextStyleElement)
- {
- defaultTextStyleElement.TextStyle.ApplyParentStyle(documentDefaultTextStyle);
- targetTextStyle = defaultTextStyleElement.TextStyle;
- }
-
+ documentDefaultTextStyle = defaultTextStyleElement.TextStyle.ApplyGlobalStyle(documentDefaultTextStyle);
+
foreach (var child in content.GetChildren())
- ApplyDefaultTextStyle(child, targetTextStyle);
+ ApplyDefaultTextStyle(child, documentDefaultTextStyle);
}
}
}
\ No newline at end of file
diff --git a/QuestPDF/Drawing/Exceptions/DocumentDrawingException.cs b/QuestPDF/Drawing/Exceptions/DocumentDrawingException.cs
index a650d90..01a63bc 100644
--- a/QuestPDF/Drawing/Exceptions/DocumentDrawingException.cs
+++ b/QuestPDF/Drawing/Exceptions/DocumentDrawingException.cs
@@ -4,6 +4,11 @@ namespace QuestPDF.Drawing.Exceptions
{
public class DocumentDrawingException : Exception
{
+ internal DocumentDrawingException(string message) : base(message)
+ {
+
+ }
+
internal DocumentDrawingException(string message, Exception inner) : base(message, inner)
{
diff --git a/QuestPDF/Drawing/FontManager.cs b/QuestPDF/Drawing/FontManager.cs
index 280cca8..0f90b7f 100644
--- a/QuestPDF/Drawing/FontManager.cs
+++ b/QuestPDF/Drawing/FontManager.cs
@@ -14,13 +14,13 @@ namespace QuestPDF.Drawing
{
public static class FontManager
{
- private static ConcurrentDictionary StyleSets = new();
- private static ConcurrentDictionary