使用SharpDX / Direct2D右对齐文本

时间:2013-06-22 17:02:56

标签: c# drawing directx direct2d sharpdx

我有一些代码来绘制一些文字:

 var textFormat = new SharpDX.DirectWrite.TextFormat(fontFactory, "Arial", SharpDX.DirectWrite.FontWeight.Bold, 
        SharpDX.DirectWrite.FontStyle.Normal, SharpDX.DirectWrite.FontStretch.Condensed, 16.0f);
    renderTarget.DrawText("AC", textFormat, textRect, textBrush, DrawTextOptions.NoSnap);

从目标矩形的左上角开始绘制文本。有没有办法对文本进行右对齐?

1 个答案:

答案 0 :(得分:1)

谷歌搜索的第四个条目“右对齐文本sharpdx direct2d”向我显示TextFormat类的documentation,其中包含属性TextAlignment。有时一点点搜索比使用Stackoverflow更快;)