Pārlūkot izejas kodu

Text: added support for take bold

Marcin Ziąbek 2 gadi atpakaļ
vecāks
revīzija
5dbd0fa71e
1 mainītis faili ar 7 papildinājumiem un 0 dzēšanām
  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),
                     TextSize = (style.Size ?? 12) * GetTextScale(style),
                     IsAntialias = true,
                     IsAntialias = true,
                     TextSkewX = GetTextSkew(style, targetTypeface),
                     TextSkewX = GetTextSkew(style, targetTypeface),
+                    FakeBoldText = UseFakeBoldText(style, targetTypeface)
                 };
                 };
             }
             }
 
 
@@ -205,6 +206,12 @@ namespace QuestPDF.Drawing
                 
                 
                 return useObliqueText ? -0.25f : 0;
                 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)
         internal static SKFontMetrics ToFontMetrics(this TextStyle style)