Przeglądaj źródła

Added example: forcing text direction

MarcinZiabek 3 lat temu
rodzic
commit
ee3d87010e
1 zmienionych plików z 40 dodań i 0 usunięć
  1. 40 0
      QuestPDF.Examples/TextExamples.cs

+ 40 - 0
QuestPDF.Examples/TextExamples.cs

@@ -725,5 +725,45 @@ namespace QuestPDF.Examples
                         });
                 });
         }
+        
+        [Test]
+        public void ForcingTextDirection()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(new PageSize(1000, 500))
+                .ProduceImages()
+                .ShowResults()
+                .Render(container =>
+                {
+                    container
+                        .Padding(10)
+                        .DefaultTextStyle(x => x.FontSize(24).FontFamily("Calibri"))
+                        .Column(column =>
+                        {
+                            column.Spacing(10);
+                            
+                            var word = "الجوريتم";
+                            var definition = "algorithm in Arabic";
+
+                            var text = $"{word} - {definition}";
+                            
+                            // text direction is automatically detected using the first word
+                            column.Item().Text(text);
+                            
+                            // it is possible to force specific content direction
+                            column.Item().Text(text).DirectionFromLeftToRight();
+                            column.Item().Text(text).DirectionFromRightToLeft();
+
+                            // to combine text in various content directions, split it into segments
+                            column.Item().Text(text =>
+                            {
+                                text.Span(word);
+                                text.Span(" - ");
+                                text.Span(definition);
+                            });
+                        });
+                });
+        }
     }
 }