我正在使用
我正在绘制文本的部分:
DrawText
在可视层上绘制FormattedText
。现在我正在使用以下代码来定义格式化文本,并且我能够将TextAlignment
设置为Center
。但是VerticalAlignment
怎么样呢?如下图所示,文字的中心不在这里显示的中心点上,该点用红点标出。
我定义FormattedText
的部分:
var ft = new FormattedText("A",
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Verdana"),
36, Brushes.Yellow);
ft.TextAlignment = TextAlignment.Center;
我正在绘制文本的部分:
var centerpoint = new Point(0,0);
dc.DrawText(ft, centerpoint);
这是最终结果:
我希望文本的中心位于圆的中心。