diff --git a/QuestPDF.Examples/TextExample.cs b/QuestPDF.Examples/TextExample.cs index c5e0e5a..1bb81fe 100644 --- a/QuestPDF.Examples/TextExample.cs +++ b/QuestPDF.Examples/TextExample.cs @@ -20,6 +20,31 @@ namespace QuestPDF.Examples { return new List { + new TextElement() + { + Style = TextStyle.Default.Size(32).BackgroundColor(Placeholders.BackgroundColor()), + Text = "Podstawowy łaciński Tabela znaków Unicode" + }, + new TextElement() + { + Style = TextStyle.Default.FontType("Segoe UI Emoji").Size(32).BackgroundColor(Placeholders.BackgroundColor()), + Text = "✔" + }, + new TextElement() + { + Style = TextStyle.Default.FontType("Segoe UI Emoji").Size(32).BackgroundColor(Placeholders.BackgroundColor()), + Text = "🥛" + }, + new TextElement() + { + Style = TextStyle.Default.FontType("Segoe UI Emoji").Size(32).BackgroundColor(Placeholders.BackgroundColor()), + Text = "🧀" + }, + new TextElement() + { + Style = TextStyle.Default.FontType("Segoe UI Emoji").Size(32).BackgroundColor(Placeholders.BackgroundColor()), + Text = "❤🚵‍♀️" + }, new TextElement() { Style = TextStyle.Default.Size(32).BackgroundColor(Placeholders.BackgroundColor()), @@ -55,7 +80,7 @@ namespace QuestPDF.Examples //.Background(Placeholders.BackgroundColor()) .Element(new TextRun() { - Elements = Source() + Elements = Lorem() }); stack diff --git a/QuestPDF/Elements/TextRun.cs b/QuestPDF/Elements/TextRun.cs index 3808000..6bba5dc 100644 --- a/QuestPDF/Elements/TextRun.cs +++ b/QuestPDF/Elements/TextRun.cs @@ -1,8 +1,11 @@ using System.Collections.Generic; using System.Linq; +using QuestPDF.Drawing; using QuestPDF.Drawing.SpacePlan; using QuestPDF.Helpers; using QuestPDF.Infrastructure; +using SkiaSharp; +using SkiaSharp.HarfBuzz; namespace QuestPDF.Elements { @@ -32,15 +35,18 @@ namespace QuestPDF.Elements var lineHeightOffset = (lineHeight - textHeight) / 2; var baselineOffset = measurements.Max(x => -x.Position.Top); var offset = lineHeightOffset + baselineOffset; - + + + using var typeface = SKTypeface.FromFamilyName("Helvetica"); + using var shaper = new SKShaper(typeface); + var shaped = shaper.Shape("Podstawowy łaciński — ✔️ ❤️ ☆ Tabela znaków Unicode", Elements.First().Style.ToPaint()); foreach (var textElement in Elements) { var size = textElement.Measure(); - //canvas.DrawRectangle(new Position(0, 0), new Size(size.Width, lineHeight), textElement.Style.BackgroundColor); - //canvas.DrawRectangle(new Position(size.Position.Left, size.Position.Top), new Size(size.Position.Width, size.Position.Height), textElement.Style.BackgroundColor); - + canvas.DrawRectangle(new Position(0, 0), new Size(size.Width, lineHeight), textElement.Style.BackgroundColor); + canvas.Translate(new Position(0, offset)); textElement.Draw(canvas); canvas.Translate(new Position(0, -offset)); diff --git a/QuestPDF/QuestPDF.csproj b/QuestPDF/QuestPDF.csproj index 19baa43..dec1b5a 100644 --- a/QuestPDF/QuestPDF.csproj +++ b/QuestPDF/QuestPDF.csproj @@ -23,6 +23,7 @@ +