Browse Source

add letter spacing to TextStyle

Bennet Bo Fenner 3 years ago
parent
commit
bbf3d71e7e

+ 7 - 1
QuestPDF/Fluent/TextSpanDescriptorExtensions.cs

@@ -55,7 +55,13 @@ namespace QuestPDF.Fluent
             descriptor.MutateTextStyle(x => x.LineHeight(value));
             return descriptor;
         }
-        
+
+        public static T LetterSpacing<T>(this T descriptor, float value) where T : TextSpanDescriptor
+        {
+            descriptor.MutateTextStyle(x => x.LetterSpacing(value));
+            return descriptor;
+        }
+
         public static T Italic<T>(this T descriptor, bool value = true) where T : TextSpanDescriptor
         {
             descriptor.MutateTextStyle(x => x.Italic(value));

+ 6 - 1
QuestPDF/Fluent/TextStyleExtensions.cs

@@ -48,7 +48,12 @@ namespace QuestPDF.Fluent
         {
             return style.Mutate(TextStyleProperty.LineHeight, value);
         }
-        
+
+        public static TextStyle LetterSpacing(this TextStyle style, float value)
+        {
+            return style.Mutate(TextStyleProperty.LetterSpacing, value);
+        }
+
         public static TextStyle Italic(this TextStyle style, bool value = true)
         {
             return style.Mutate(TextStyleProperty.IsItalic, value);

+ 2 - 0
QuestPDF/Infrastructure/TextStyle.cs

@@ -10,6 +10,7 @@ namespace QuestPDF.Infrastructure
         internal string? FontFamily { get; set; }
         internal float? Size { get; set; }
         internal float? LineHeight { get; set; }
+        internal float? LetterSpacing { get; set; }
         internal FontWeight? FontWeight { get; set; }
         internal FontPosition? FontPosition { get; set; }
         internal bool? IsItalic { get; set; }
@@ -26,6 +27,7 @@ namespace QuestPDF.Infrastructure
             FontFamily = Fonts.Lato,
             Size = 12,
             LineHeight = 1.2f,
+            LetterSpacing = 0,
             FontWeight = Infrastructure.FontWeight.Normal,
             FontPosition = Infrastructure.FontPosition.Normal,
             IsItalic = false,