Solution: Please add ,VisualTreeHelper.GetDpi(this).PixelsPerDip
after your text.Foreground
.
Explanation: You use the Obsolete FormattedText(String, CultureInfo, FlowDirection, Typeface, Double, Brush)
, which need to use PixelsPerDip
to override , you could refer to official document: FormattedText(String, CultureInfo, FlowDirection, Typeface, Double, Brush) for more details. Its corresponding new method is FormattedText(String, CultureInfo, FlowDirection, Typeface, Double, Brush, Double)
Updated code:
var fromatted = new FormattedText(
text.Text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight,
new Typeface(text.FontFamily, text.FontStyle, text.FontWeight, text.FontStretch),
text.FontSize, text.Foreground, VisualTreeHelper.GetDpi(this).PixelsPerDip);
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.