Browse Source

Stability improvements for text wrapping

MarcinZiabek 3 years ago
parent
commit
04da32e0e7
2 changed files with 4 additions and 1 deletions
  1. 3 0
      QuestPDF/Drawing/TextShaper.cs
  2. 1 1
      QuestPDF/Elements/Text/Items/TextBlockSpan.cs

+ 3 - 0
QuestPDF/Drawing/TextShaper.cs

@@ -129,6 +129,9 @@ namespace QuestPDF.Drawing
         {
             if (Glyphs.Length == 0)
                 return null;
+
+            if (startIndex > endIndex)
+                return null;
             
             using var skTextBlobBuilder = new SKTextBlobBuilder();
             

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

@@ -66,7 +66,7 @@ namespace QuestPDF.Elements.Text.Items
             // start breaking text from requested position
             var endIndex = TextShapingResult.BreakText(startIndex, request.AvailableWidth);
 
-            if (endIndex < 0)
+            if (endIndex < startIndex)
                 return null;
   
             // break text only on spaces