Browse Source

Fixed: text width calculation was unnecessarily rounded, which could cause overflowing.

Marcin Ziąbek 1 year ago
parent
commit
bae5db5f54
1 changed files with 2 additions and 5 deletions
  1. 2 5
      Source/QuestPDF/Elements/Text/TextBlock.cs

+ 2 - 5
Source/QuestPDF/Elements/Text/TextBlock.cs

@@ -461,10 +461,7 @@ namespace QuestPDF.Elements.Text
 
 
         private void CalculateParagraphMetrics(Size availableSpace)
         private void CalculateParagraphMetrics(Size availableSpace)
         {
         {
-            // SkParagraph seems to require a bigger space buffer to calculate metrics correctly
-            const float epsilon = 1f;
-            
-            if (Math.Abs(WidthForLineMetricsCalculation - availableSpace.Width) > epsilon)
+            if (Math.Abs(WidthForLineMetricsCalculation - availableSpace.Width) > Size.Epsilon)
                 AreParagraphMetricsValid = false;
                 AreParagraphMetricsValid = false;
             
             
             if (AreParagraphMetricsValid) 
             if (AreParagraphMetricsValid) 
@@ -472,7 +469,7 @@ namespace QuestPDF.Elements.Text
             
             
             WidthForLineMetricsCalculation = availableSpace.Width;
             WidthForLineMetricsCalculation = availableSpace.Width;
                 
                 
-            Paragraph.PlanLayout(availableSpace.Width + epsilon);
+            Paragraph.PlanLayout(availableSpace.Width);
             CheckUnresolvedGlyphs();
             CheckUnresolvedGlyphs();
                 
                 
             LineMetrics = Paragraph.GetLineMetrics();
             LineMetrics = Paragraph.GetLineMetrics();