using System; using System.Runtime.CompilerServices; using QuestPDF.Infrastructure; namespace QuestPDF.Fluent { public static class TextSpanDescriptorExtensions { public static T Style(this T descriptor, TextStyle style) where T : TextSpanDescriptor { if (style == null) return descriptor; descriptor.TextStyle.OverrideStyle(style); return descriptor; } public static T FontColor(this T descriptor, string value) where T : TextSpanDescriptor { descriptor.TextStyle.Color = value; return descriptor; } public static T BackgroundColor(this T descriptor, string value) where T : TextSpanDescriptor { descriptor.TextStyle.BackgroundColor = value; return descriptor; } public static T FontFamily(this T descriptor, string value) where T : TextSpanDescriptor { descriptor.TextStyle.FontFamily = value; return descriptor; } public static T FontSize(this T descriptor, float value) where T : TextSpanDescriptor { descriptor.TextStyle.Size = value; return descriptor; } public static T LineHeight(this T descriptor, float value) where T : TextSpanDescriptor { descriptor.TextStyle.LineHeight = value; return descriptor; } public static T Italic(this T descriptor, bool value = true) where T : TextSpanDescriptor { descriptor.TextStyle.IsItalic = value; return descriptor; } public static T Strikethrough(this T descriptor, bool value = true) where T : TextSpanDescriptor { descriptor.TextStyle.HasStrikethrough = value; return descriptor; } public static T Underline(this T descriptor, bool value = true) where T : TextSpanDescriptor { descriptor.TextStyle.HasUnderline = value; return descriptor; } public static T WrapAnywhere(this T descriptor, bool value = true) where T : TextSpanDescriptor { descriptor.TextStyle.WrapAnywhere = value; return descriptor; } #region Weight public static T Weight(this T descriptor, FontWeight weight) where T : TextSpanDescriptor { descriptor.TextStyle.FontWeight = weight; return descriptor; } public static T Thin(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.Thin); } public static T ExtraLight(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.ExtraLight); } public static T Light(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.Light); } public static T NormalWeight(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.Normal); } public static T Medium(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.Medium); } public static T SemiBold(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.SemiBold); } public static T Bold(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.Bold); } public static T ExtraBold(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.ExtraBold); } public static T Black(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.Black); } public static T ExtraBlack(this T descriptor) where T : TextSpanDescriptor { return descriptor.Weight(FontWeight.ExtraBlack); } #endregion #region Position public static T NormalPosition(this T descriptor) where T : TextSpanDescriptor { return descriptor.Position(FontPosition.Normal); } public static T Subscript(this T descriptor) where T : TextSpanDescriptor { return descriptor.Position(FontPosition.Subscript); } public static T Superscript(this T descriptor) where T : TextSpanDescriptor { return descriptor.Position(FontPosition.Superscript); } private static T Position(this T descriptor, FontPosition fontPosition) where T : TextSpanDescriptor { descriptor.TextStyle.FontPosition = fontPosition; return descriptor; } #endregion } }