FormattedText GetFormattedText(string text, Font font, TextAlignment alignment = TextAlignment.Left) { var formattedText = new FormattedText(text, CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, font.GetTypeface(), font.Size, null); return(formattedText); }
public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null) { var formattedText = new FormattedText(text, CultureInfo.InvariantCulture, System.Windows.FlowDirection.LeftToRight, font.GetTypeface(), font.Size, null); formattedText.SetForegroundBrush(brush?.GetBrush()); dc.DrawText(formattedText, frame.BottomLeft.GetPoint()); }