diff --git a/QuestPDF.Examples/BarcodeExamples.cs b/QuestPDF.Examples/BarcodeExamples.cs index 762ad20..ad43734 100644 --- a/QuestPDF.Examples/BarcodeExamples.cs +++ b/QuestPDF.Examples/BarcodeExamples.cs @@ -13,7 +13,7 @@ namespace QuestPDF.Examples [Test] public void Example() { - FontManager.RegisterFontType(File.OpenRead("LibreBarcode39-Regular.ttf")); + FontManager.RegisterFont(File.OpenRead("LibreBarcode39-Regular.ttf")); RenderingTest .Create() @@ -26,8 +26,8 @@ namespace QuestPDF.Examples .AlignCenter() .AlignMiddle() .Text("*QuestPDF*") - .FontType("Libre Barcode 39") - .Size(64); + .FontFamily("Libre Barcode 39") + .FontSize(64); }); } } diff --git a/QuestPDF.Examples/CanvasExamples.cs b/QuestPDF.Examples/CanvasExamples.cs index aff03cf..cb9bd2e 100644 --- a/QuestPDF.Examples/CanvasExamples.cs +++ b/QuestPDF.Examples/CanvasExamples.cs @@ -50,8 +50,8 @@ namespace QuestPDF.Examples .PaddingVertical(10) .PaddingHorizontal(20) .Text("Sample text") - .Size(16) - .Color(Colors.Blue.Darken2) + .FontSize(16) + .FontColor(Colors.Blue.Darken2) .SemiBold(); }); }); diff --git a/QuestPDF.Examples/ChartExamples.cs b/QuestPDF.Examples/ChartExamples.cs index 6cb8abe..beae613 100644 --- a/QuestPDF.Examples/ChartExamples.cs +++ b/QuestPDF.Examples/ChartExamples.cs @@ -58,9 +58,9 @@ namespace QuestPDF.Examples .Item() .PaddingBottom(10) .Text("Chart example") - .Size(20) + .FontSize(20) .SemiBold() - .Color(Colors.Blue.Medium); + .FontColor(Colors.Blue.Medium); column .Item() diff --git a/QuestPDF.Examples/ContinousPage.cs b/QuestPDF.Examples/ContinousPage.cs index 37e3e47..eb73ed9 100644 --- a/QuestPDF.Examples/ContinousPage.cs +++ b/QuestPDF.Examples/ContinousPage.cs @@ -25,7 +25,7 @@ namespace QuestPDF.Examples page.Content().PaddingVertical(10).Border(1).Padding(10).Column(column => { foreach (var index in Enumerable.Range(1, 100)) - column.Item().Text($"Line {index}").Color(Placeholders.Color()); + column.Item().Text($"Line {index}").FontColor(Placeholders.Color()); }); page.Footer().Text("Footer"); diff --git a/QuestPDF.Examples/DefaultTextStyleExample.cs b/QuestPDF.Examples/DefaultTextStyleExample.cs index acf176e..9efce3f 100644 --- a/QuestPDF.Examples/DefaultTextStyleExample.cs +++ b/QuestPDF.Examples/DefaultTextStyleExample.cs @@ -38,7 +38,7 @@ namespace QuestPDF.Examples text.Line(Placeholders.Sentence()); // this text has size 20 but also semibold and red - text.Span(Placeholders.Sentence()).Color(Colors.Red.Medium); + text.Span(Placeholders.Sentence()).FontColor(Colors.Red.Medium); }); }); }); diff --git a/QuestPDF.Examples/DefaultTextStyleExamples.cs b/QuestPDF.Examples/DefaultTextStyleExamples.cs index 9db6bc7..c02536b 100644 --- a/QuestPDF.Examples/DefaultTextStyleExamples.cs +++ b/QuestPDF.Examples/DefaultTextStyleExamples.cs @@ -27,7 +27,7 @@ namespace QuestPDF.Examples .Column(column => { column.Item().Text("Default style applies to all children"); - column.Item().Text("You can override certain styles").Underline(false).Color(Colors.Green.Darken2); + column.Item().Text("You can override certain styles").Underline(false).FontColor(Colors.Green.Darken2); column.Item().PaddingTop(10).Border(1).Grid(grid => { @@ -44,7 +44,7 @@ namespace QuestPDF.Examples .AlignCenter() .AlignMiddle() .Text(i) - .Size(16 + i / 4); + .FontSize(16 + i / 4); } }); }); diff --git a/QuestPDF.Examples/ElementExamples.cs b/QuestPDF.Examples/ElementExamples.cs index 3874f78..45d67ea 100644 --- a/QuestPDF.Examples/ElementExamples.cs +++ b/QuestPDF.Examples/ElementExamples.cs @@ -44,8 +44,8 @@ namespace QuestPDF.Examples .Background(Colors.Grey.Medium) .Padding(10) .Text("Notes") - .Size(16) - .Color("#FFF"); + .FontSize(16) + .FontColor("#FFF"); decoration .Content() @@ -283,14 +283,14 @@ namespace QuestPDF.Examples .AlignCenter() .AlignMiddle() .Text("Watermark") - .Size(48) + .FontSize(48) .Bold() - .Color(Colors.Green.Lighten3); + .FontColor(Colors.Green.Lighten3); layers .Layer() .AlignBottom() - .Text(text => text.CurrentPageNumber().Size(16).Color(Colors.Green.Medium)); + .Text(text => text.CurrentPageNumber().FontSize(16).FontColor(Colors.Green.Medium)); }); }); } @@ -422,8 +422,8 @@ namespace QuestPDF.Examples .BorderColor(Colors.Grey.Medium) .Padding(10) .Text(font) - .FontType(font) - .Size(16); + .FontFamily(font) + .FontSize(16); } }); }); @@ -463,7 +463,7 @@ namespace QuestPDF.Examples }); layers.Layer().Background("#8F00").Extend(); - layers.Layer().PaddingTop(40).Text("It works!").Size(24); + layers.Layer().PaddingTop(40).Text("It works!").FontSize(24); }); }); } @@ -484,7 +484,7 @@ namespace QuestPDF.Examples //.MinimalBox() .Background(Colors.Grey.Lighten2) .Padding(15) - .Text("Test of the \n box element").Size(20); + .Text("Test of the \n box element").FontSize(20); }); } @@ -565,7 +565,7 @@ namespace QuestPDF.Examples .Padding(50) .Text("Moved text") - .Size(25); + .FontSize(25); }); } @@ -602,7 +602,7 @@ namespace QuestPDF.Examples .Background(Colors.White) .Padding(10) .Text($"Rotated {turns * 90}°") - .Size(16); + .FontSize(16); } }); }); @@ -701,7 +701,7 @@ namespace QuestPDF.Examples .Background(Colors.White) .Padding(10) .Text($"Flipped {turns}") - .Size(16); + .FontSize(16); } }); }); diff --git a/QuestPDF.Examples/InlinedExamples.cs b/QuestPDF.Examples/InlinedExamples.cs index cef4d1e..8f4adda 100644 --- a/QuestPDF.Examples/InlinedExamples.cs +++ b/QuestPDF.Examples/InlinedExamples.cs @@ -75,7 +75,7 @@ namespace QuestPDF.Examples .AlignCenter() .AlignMiddle() .Text(sizeText) - .Size(15); + .FontSize(15); }); } }); diff --git a/QuestPDF.Examples/MinimalApiExamples.cs b/QuestPDF.Examples/MinimalApiExamples.cs index 0a4112e..4d7e3ba 100644 --- a/QuestPDF.Examples/MinimalApiExamples.cs +++ b/QuestPDF.Examples/MinimalApiExamples.cs @@ -23,7 +23,7 @@ namespace QuestPDF.Examples page.DefaultTextStyle(TextStyle.Default.Size(20)); page.Header() - .Text("Hello PDF!").SemiBold().Size(36).Color(Colors.Blue.Medium); + .Text("Hello PDF!").SemiBold().FontSize(36).FontColor(Colors.Blue.Medium); page.Content() .PaddingVertical(1, Unit.Centimetre) @@ -68,8 +68,8 @@ namespace QuestPDF.Examples page.Header() .Text("Hello PDF!") .SemiBold() - .Size(36) - .Color(Colors.Blue.Medium); + .FontSize(36) + .FontColor(Colors.Blue.Medium); page.Content() .PaddingVertical(1, Unit.Centimetre) diff --git a/QuestPDF.Examples/Padding.cs b/QuestPDF.Examples/Padding.cs index 68f5576..d8dddcd 100644 --- a/QuestPDF.Examples/Padding.cs +++ b/QuestPDF.Examples/Padding.cs @@ -51,7 +51,7 @@ namespace QuestPDF.Examples .Padding(5) .AlignCenter() .Text("Sample text") - .FontType("Segoe UI emoji"); + .FontFamily("Segoe UI emoji"); }); } diff --git a/QuestPDF.Examples/SkipOnceExample.cs b/QuestPDF.Examples/SkipOnceExample.cs index 1c3323e..182a65e 100644 --- a/QuestPDF.Examples/SkipOnceExample.cs +++ b/QuestPDF.Examples/SkipOnceExample.cs @@ -32,7 +32,7 @@ namespace QuestPDF.Examples page.Content() .PaddingVertical(10) .Text(Placeholders.Paragraphs()) - .Color(Colors.Grey.Medium); + .FontColor(Colors.Grey.Medium); page.Footer().Text(text => { diff --git a/QuestPDF.Examples/TextBenchmark.cs b/QuestPDF.Examples/TextBenchmark.cs index 5470664..33246ec 100644 --- a/QuestPDF.Examples/TextBenchmark.cs +++ b/QuestPDF.Examples/TextBenchmark.cs @@ -141,8 +141,8 @@ namespace QuestPDF.Examples .AlignBottom() .Column(column => { - column.Item().Text("Quo Vadis").Size(72).Bold().Color(Colors.Blue.Darken2); - column.Item().Text("Henryk Sienkiewicz").Size(24).Color(Colors.Grey.Darken2); + column.Item().Text("Quo Vadis").FontSize(72).Bold().FontColor(Colors.Blue.Darken2); + column.Item().Text("Henryk Sienkiewicz").FontSize(24).FontColor(Colors.Grey.Darken2); }); } @@ -198,7 +198,7 @@ namespace QuestPDF.Examples text.DefaultTextStyle(normalStyle); text.Span("Ten dokument został wygenerowany na podstawie książki w formacie TXT opublikowanej w serwisie "); - text.Hyperlink("wolnelektury.pl", "https://wolnelektury.pl/").Color(Colors.Blue.Medium).Underline(); + text.Hyperlink("wolnelektury.pl", "https://wolnelektury.pl/").FontColor(Colors.Blue.Medium).Underline(); text.Span(". Dziękuję za wspieranie polskiego czytelnictwa!"); }); }); diff --git a/QuestPDF.Examples/TextExamples.cs b/QuestPDF.Examples/TextExamples.cs index 347996f..4b938bb 100644 --- a/QuestPDF.Examples/TextExamples.cs +++ b/QuestPDF.Examples/TextExamples.cs @@ -31,7 +31,7 @@ namespace QuestPDF.Examples { text.DefaultTextStyle(TextStyle.Default.Size(20)); text.Span("This is a normal text, followed by an "); - text.Span("underlined red text.").Size(20).Color(Colors.Red.Medium).Underline(); + text.Span("underlined red text.").FontSize(20).FontColor(Colors.Red.Medium).Underline(); }); }); } @@ -185,8 +185,8 @@ namespace QuestPDF.Examples text.Span("This text is a normal text, "); text.Span("this is a bold text, ").Bold(); - text.Span("this is a red and underlined text, ").Color(Colors.Red.Medium).Underline(); - text.Span("and this is slightly bigger text.").Size(16); + text.Span("this is a red and underlined text, ").FontColor(Colors.Red.Medium).Underline(); + text.Span("and this is slightly bigger text.").FontSize(16); text.EmptyLine(); @@ -244,8 +244,8 @@ namespace QuestPDF.Examples text.Span("This text is a normal text, "); text.Span("this is a bold text, ").Bold(); - text.Span("this is a red and underlined text, ").Color(Colors.Red.Medium).Underline(); - text.Span("and this is slightly bigger text.").Size(16); + text.Span("this is a red and underlined text, ").FontColor(Colors.Red.Medium).Underline(); + text.Span("and this is slightly bigger text.").FontSize(16); text.Span("The new text element also supports injecting custom content between words: "); text.Element().PaddingBottom(-10).Height(16).Width(32).Image(Placeholders.Image); diff --git a/QuestPDF.ReportSample/Layouts/DifferentHeadersTemplate.cs b/QuestPDF.ReportSample/Layouts/DifferentHeadersTemplate.cs index a70c3bb..9b72d86 100644 --- a/QuestPDF.ReportSample/Layouts/DifferentHeadersTemplate.cs +++ b/QuestPDF.ReportSample/Layouts/DifferentHeadersTemplate.cs @@ -30,12 +30,12 @@ namespace QuestPDF.ReportSample.Layouts { column.Item().ShowOnce().Padding(5).AlignMiddle().Row(row => { - row.RelativeItem(2).AlignMiddle().Text("PRIMARY HEADER").Color(Colors.Grey.Darken3).Size(30).Bold(); + row.RelativeItem(2).AlignMiddle().Text("PRIMARY HEADER").FontColor(Colors.Grey.Darken3).FontSize(30).Bold(); row.RelativeItem(1).AlignRight().MinimalBox().AlignMiddle().Background(Colors.Blue.Darken2).Padding(30); }); column.Item().SkipOnce().Padding(5).Row(row => { - row.RelativeItem(2).Text("SECONDARY HEADER").Color(Colors.Grey.Darken3).Size(30).Bold(); + row.RelativeItem(2).Text("SECONDARY HEADER").FontColor(Colors.Grey.Darken3).FontSize(30).Bold(); row.RelativeItem(1).AlignRight().MinimalBox().Background(Colors.Blue.Lighten4).Padding(15); }); }); diff --git a/QuestPDF.UnitTests/TestEngine/TestPlan.cs b/QuestPDF.UnitTests/TestEngine/TestPlan.cs index 00136fc..1ec5fe9 100644 --- a/QuestPDF.UnitTests/TestEngine/TestPlan.cs +++ b/QuestPDF.UnitTests/TestEngine/TestPlan.cs @@ -92,7 +92,7 @@ namespace QuestPDF.UnitTests.TestEngine Assert.AreEqual(expected.Position.Y, position.Y, "Draw text: Y"); Assert.AreEqual(expected.Style.Color, style.Color, "Draw text: color"); - Assert.AreEqual(expected.Style.FontType, style.FontType, "Draw text: font"); + Assert.AreEqual(expected.Style.FontFamily, style.FontFamily, "Draw text: font"); Assert.AreEqual(expected.Style.Size, style.Size, "Draw text: size"); }, DrawImageFunc = (image, position, size) => diff --git a/QuestPDF/Drawing/FontManager.cs b/QuestPDF/Drawing/FontManager.cs index 1a51bcf..e4d2fca 100644 --- a/QuestPDF/Drawing/FontManager.cs +++ b/QuestPDF/Drawing/FontManager.cs @@ -30,7 +30,7 @@ namespace QuestPDF.Drawing } } - [Obsolete("Since version 2022.3, the FontManager class offers better font type matching support. Please use the RegisterFontType(Stream stream) overload.")] + [Obsolete("Since version 2022.3, the FontManager class offers better font type matching support. Please use the RegisterFont(Stream stream) method.")] public static void RegisterFontType(string fontName, Stream stream) { using var fontData = SKData.Create(stream); @@ -38,7 +38,7 @@ namespace QuestPDF.Drawing RegisterFontType(fontData, customName: fontName); } - public static void RegisterFontType(Stream stream) + public static void RegisterFont(Stream stream) { using var fontData = SKData.Create(stream); RegisterFontType(fontData); @@ -78,16 +78,16 @@ namespace QuestPDF.Drawing var fontStyle = new SKFontStyle(weight, SKFontStyleWidth.Normal, slant); - if (StyleSets.TryGetValue(style.FontType, out var fontStyleSet)) + if (StyleSets.TryGetValue(style.FontFamily, out var fontStyleSet)) return fontStyleSet.Match(fontStyle); - var fontFromDefaultSource = SKFontManager.Default.MatchFamily(style.FontType, fontStyle); + var fontFromDefaultSource = SKFontManager.Default.MatchFamily(style.FontFamily, fontStyle); if (fontFromDefaultSource != null) return fontFromDefaultSource; throw new ArgumentException( - $"The typeface '{style.FontType}' could not be found. " + + $"The typeface '{style.FontFamily}' could not be found. " + $"Please consider the following options: " + $"1) install the font on your operating system or execution environment. " + $"2) load a font file specifically for QuestPDF usage via the QuestPDF.Drawing.FontManager.RegisterFontType(Stream fileContentStream) static method."); diff --git a/QuestPDF/Elements/DebugArea.cs b/QuestPDF/Elements/DebugArea.cs index be9b2a5..7b20236 100644 --- a/QuestPDF/Elements/DebugArea.cs +++ b/QuestPDF/Elements/DebugArea.cs @@ -31,9 +31,9 @@ namespace QuestPDF.Elements .Background(Colors.White) .Padding(2) .Text(Text) - .Color(Color) - .FontType(Fonts.Consolas) - .Size(8); + .FontColor(Color) + .FontFamily(Fonts.Consolas) + .FontSize(8); }); } } diff --git a/QuestPDF/Elements/Placeholder.cs b/QuestPDF/Elements/Placeholder.cs index 943ecc0..b1020d0 100644 --- a/QuestPDF/Elements/Placeholder.cs +++ b/QuestPDF/Elements/Placeholder.cs @@ -26,7 +26,7 @@ namespace QuestPDF.Elements if (string.IsNullOrWhiteSpace(Text)) x.MaxHeight(32).Image(ImageData, ImageScaling.FitArea); else - x.Text(Text).Size(14); + x.Text(Text).FontSize(14); }); } } diff --git a/QuestPDF/Fluent/TextSpanDescriptorExtensions.cs b/QuestPDF/Fluent/TextSpanDescriptorExtensions.cs index f04e207..9af8e9a 100644 --- a/QuestPDF/Fluent/TextSpanDescriptorExtensions.cs +++ b/QuestPDF/Fluent/TextSpanDescriptorExtensions.cs @@ -15,7 +15,7 @@ namespace QuestPDF.Fluent return descriptor; } - public static T Color(this T descriptor, string value) where T : TextSpanDescriptor + public static T FontColor(this T descriptor, string value) where T : TextSpanDescriptor { descriptor.TextStyle.Color = value; return descriptor; @@ -27,13 +27,13 @@ namespace QuestPDF.Fluent return descriptor; } - public static T FontType(this T descriptor, string value) where T : TextSpanDescriptor + public static T FontFamily(this T descriptor, string value) where T : TextSpanDescriptor { - descriptor.TextStyle.FontType = value; + descriptor.TextStyle.FontFamily = value; return descriptor; } - public static T Size(this T descriptor, float value) where T : TextSpanDescriptor + public static T FontSize(this T descriptor, float value) where T : TextSpanDescriptor { descriptor.TextStyle.Size = value; return descriptor; diff --git a/QuestPDF/Fluent/TextStyleExtensions.cs b/QuestPDF/Fluent/TextStyleExtensions.cs index 64cae02..a748225 100644 --- a/QuestPDF/Fluent/TextStyleExtensions.cs +++ b/QuestPDF/Fluent/TextStyleExtensions.cs @@ -13,7 +13,13 @@ namespace QuestPDF.Fluent return style; } + [Obsolete("This element has been renamed since version 2022.3. Please use the FontColor method.")] public static TextStyle Color(this TextStyle style, string value) + { + return style.FontColor(value); + } + + public static TextStyle FontColor(this TextStyle style, string value) { return style.Mutate(x => x.Color = value); } @@ -23,12 +29,24 @@ namespace QuestPDF.Fluent return style.Mutate(x => x.BackgroundColor = value); } + [Obsolete("This element has been renamed since version 2022.3. Please use the FontFamily method.")] public static TextStyle FontType(this TextStyle style, string value) { - return style.Mutate(x => x.FontType = value); + return style.FontFamily(value); } + public static TextStyle FontFamily(this TextStyle style, string value) + { + return style.Mutate(x => x.FontFamily = value); + } + + [Obsolete("This element has been renamed since version 2022.3. Please use the FontSize method.")] public static TextStyle Size(this TextStyle style, float value) + { + return style.FontSize(value); + } + + public static TextStyle FontSize(this TextStyle style, float value) { return style.Mutate(x => x.Size = value); } diff --git a/QuestPDF/Infrastructure/TextStyle.cs b/QuestPDF/Infrastructure/TextStyle.cs index 13dde4e..4556648 100644 --- a/QuestPDF/Infrastructure/TextStyle.cs +++ b/QuestPDF/Infrastructure/TextStyle.cs @@ -9,7 +9,7 @@ namespace QuestPDF.Infrastructure internal string? Color { get; set; } internal string? BackgroundColor { get; set; } - internal string? FontType { get; set; } + internal string? FontFamily { get; set; } internal float? Size { get; set; } internal float? LineHeight { get; set; } internal FontWeight? FontWeight { get; set; } @@ -24,7 +24,7 @@ namespace QuestPDF.Infrastructure { Color = Colors.Black, BackgroundColor = Colors.Transparent, - FontType = Fonts.Calibri, + FontFamily = Fonts.Calibri, Size = 12, LineHeight = 1.2f, FontWeight = Infrastructure.FontWeight.Normal, @@ -43,15 +43,15 @@ namespace QuestPDF.Infrastructure HasGlobalStyleApplied = true; ApplyParentStyle(globalStyle); - PaintKey ??= (FontType, Size, FontWeight, IsItalic, Color); - FontMetricsKey ??= (FontType, Size, FontWeight, IsItalic); + PaintKey ??= (FontFamily, Size, FontWeight, IsItalic, Color); + FontMetricsKey ??= (FontFamily, Size, FontWeight, IsItalic); } internal void ApplyParentStyle(TextStyle parentStyle) { Color ??= parentStyle.Color; BackgroundColor ??= parentStyle.BackgroundColor; - FontType ??= parentStyle.FontType; + FontFamily ??= parentStyle.FontFamily; Size ??= parentStyle.Size; LineHeight ??= parentStyle.LineHeight; FontWeight ??= parentStyle.FontWeight; @@ -64,7 +64,7 @@ namespace QuestPDF.Infrastructure { Color = parentStyle.Color ?? Color; BackgroundColor = parentStyle.BackgroundColor ?? BackgroundColor; - FontType = parentStyle.FontType ?? FontType; + FontFamily = parentStyle.FontFamily ?? FontFamily; Size = parentStyle.Size ?? Size; LineHeight = parentStyle.LineHeight ?? LineHeight; FontWeight = parentStyle.FontWeight ?? FontWeight; diff --git a/QuestPDF/QuestPDF.csproj b/QuestPDF/QuestPDF.csproj index 932b8b3..0801a9b 100644 --- a/QuestPDF/QuestPDF.csproj +++ b/QuestPDF/QuestPDF.csproj @@ -4,7 +4,7 @@ MarcinZiabek CodeFlint QuestPDF - 2022.2.3 + 2022.3.0 QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API. $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt")) 9