Browse Source

Text: added support for take bold

Marcin Ziąbek 2 years ago
parent
commit
5dbd0fa71e
1 changed files with 7 additions and 0 deletions
  1. 7 0
      Source/QuestPDF/Drawing/FontManager.cs

+ 7 - 0
Source/QuestPDF/Drawing/FontManager.cs

@@ -149,6 +149,7 @@ namespace QuestPDF.Drawing
                     TextSize = (style.Size ?? 12) * GetTextScale(style),
                     IsAntialias = true,
                     TextSkewX = GetTextSkew(style, targetTypeface),
+                    FakeBoldText = UseFakeBoldText(style, targetTypeface)
                 };
             }
 
@@ -205,6 +206,12 @@ namespace QuestPDF.Drawing
                 
                 return useObliqueText ? -0.25f : 0;
             }
+            
+            static bool UseFakeBoldText(TextStyle originalTextStyle, SKTypeface targetTypeface)
+            {
+                // requested bold text but got typeface that is not bold
+                return originalTextStyle.FontWeight > FontWeight.Medium && !targetTypeface.IsBold;
+            }
         }
 
         internal static SKFontMetrics ToFontMetrics(this TextStyle style)