Browse Source

2021.10-beta + Code rebase

Marcin Ziąbek 4 years ago
parent
commit
122f35d0a7

+ 1 - 0
QuestPDF.Examples/BarCode.cs

@@ -19,6 +19,7 @@ namespace QuestPDF.Examples
                 .Create()
                 .PageSize(400, 100)
                 .FileName()
+                .ShowResults()
                 .Render(container =>
                 {
                     container

+ 3 - 0
QuestPDF.Examples/QuestPDF.Examples.csproj

@@ -20,6 +20,9 @@
       <None Update="quo-vadis.txt">
         <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       </None>
+      <None Update="LibreBarcode39-Regular.ttf">
+        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      </None>
     </ItemGroup>
 
 </Project>

+ 3 - 8
QuestPDF/Drawing/FontManager.cs

@@ -10,6 +10,7 @@ namespace QuestPDF.Drawing
     public static class FontManager
     {
         private static ConcurrentDictionary<string, SKTypeface> Typefaces = new ConcurrentDictionary<string, SKTypeface>();
+        private static ConcurrentDictionary<string, SKFontMetrics> FontMetrics = new ConcurrentDictionary<string, SKFontMetrics>();
         private static ConcurrentDictionary<string, SKPaint> Paints = new ConcurrentDictionary<string, SKPaint>();
         private static ConcurrentDictionary<string, SKPaint> ColorPaint = new ConcurrentDictionary<string, SKPaint>();
 
@@ -58,15 +59,9 @@ namespace QuestPDF.Drawing
             }
         }
 
-        internal static TextMeasurement BreakText(this TextStyle style, string text, float availableWidth)
+        internal static SKFontMetrics ToFontMetrics(this TextStyle style)
         {
-            var index = (int)style.ToPaint().BreakText(text, availableWidth, out var width);
-            
-            return new TextMeasurement()
-            {
-                LineIndex = index,
-                FragmentWidth = width
-            };
+            return FontMetrics.GetOrAdd(style.ToString(), key => style.ToPaint().FontMetrics);
         }
     }
 }

+ 0 - 1
QuestPDF/Elements/Text/Items/TextBlockSpan.cs

@@ -39,7 +39,6 @@ namespace QuestPDF.Elements.Text.Items
                     startIndex++;
             }
 
-            
             if (Text.Length == 0)
             {
                 return new TextMeasurementResult

+ 4 - 4
QuestPDF/QuestPDF.csproj

@@ -4,9 +4,9 @@
         <Authors>MarcinZiabek</Authors>
         <Company>CodeFlint</Company>
         <PackageId>QuestPDF</PackageId>
-        <Version>2021.9.3</Version>
+        <Version>2021.10.0-beta</Version>
         <PackageDescription>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.</PackageDescription>
-        <PackageReleaseNotes>Added support for registering custom fonts from a stream. Fixed continuous page setting. Improved exception messages.</PackageReleaseNotes>
+        <PackageReleaseNotes>Enhanced text rendering capabilities.</PackageReleaseNotes>
         <LangVersion>8</LangVersion>
         <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
         <PackageIcon>Logo.png</PackageIcon>
@@ -14,8 +14,8 @@
         <PackageProjectUrl>https://www.questpdf.com/</PackageProjectUrl>
         <RepositoryUrl>https://github.com/QuestPDF/library.git</RepositoryUrl>
         <RepositoryType>git</RepositoryType>
-        <Copyright>Marcin Ziąbek, QuestPDF contributors</Copyright>
-        <PackageTags>pdf file export generate generation tool create creation render portable document format quest html library converter free</PackageTags>
+        <Copyright>QuestPDF contributors</Copyright>
+        <PackageTags>PDF file export generate create render portable document format quest free</PackageTags>
         <PackageLicenseExpression>MIT</PackageLicenseExpression>
         <Nullable>enable</Nullable>
         <TargetFrameworks>net462;netstandard2.0;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>