Browse Source

Improvement: To enhance compatibility with existing codebases, we've removed the breaking change associated with the deprecation of the TextStyle.Fallback method. Although this method remains obsolete, we've reintroduced it with a compatibility layer to prevent disruptions.

Marcin Ziąbek 1 year ago
parent
commit
985d99dc4a

+ 11 - 1
Source/QuestPDF/Fluent/TextStyleExtensions.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Linq;
 using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 using QuestPDF.Skia.Text;
@@ -273,7 +274,16 @@ namespace QuestPDF.Fluent
         [Obsolete("This setting is not supported since the 2024.3 version. Please use the FontFamilyFallback method or rely on the new automated fallback mechanism.")]
         public static TextStyle Fallback(this TextStyle style, TextStyle? value = null)
         {
-            return style;
+            var currentFontFamilies = style.FontFamilies ?? Array.Empty<string>();
+            var fallbackFontFamilies = value?.FontFamilies ?? Array.Empty<string>();
+            
+            var targetFontFamilies = currentFontFamilies
+                .Concat(fallbackFontFamilies)
+                .Where(x => !string.IsNullOrWhiteSpace(x))
+                .Distinct()
+                .ToArray();
+            
+            return style.FontFamily(targetFontFamilies);
         }
         
         [Obsolete("This setting is not supported since the 2024.3 version. Please use the FontFamilyFallback method or rely on the new automated fallback mechanism.")]

+ 1 - 0
Source/QuestPDF/Resources/ReleaseNotes.txt

@@ -28,3 +28,4 @@ We would like to thank the SkiaSharp project, its maintainers, and contributors,
 Version 2024.3.1
 - Enhanced discoverability of text alignment options (AlignLeft, AlignCenter, AlignRight, AlignStart, AlignEnd and Justify) when using the shorthand Text method (common use case).
 - Fix: on the Windows platform, the "Could not find an appropriate font fallback for the following glyphs: $U-000D" exception is thrown when the "QuestPDF.Settings.CheckIfAllTextGlyphsAreAvailable" is set true, and the "TextDescriptor.Line" method is used (that inserts the '\r' character).
+- Improvement: To enhance compatibility with existing codebases, we've removed the breaking change associated with the deprecation of the TextStyle.Fallback method. Although this method remains obsolete, we've reintroduced it with a compatibility layer to prevent disruptions.