使用SharpDX / Direct2D右对齐文本 [英] Right justify text using SharpDX/Direct2D
本文介绍了使用SharpDX / Direct2D右对齐文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些代码可以绘制一些文本:
I have some code to draw some text:
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);
从目标矩形的左上角开始绘制文本。有什么方法可以使文本右对齐?
The text is drawn starting at the top-left of the target rectangle. Is there any way to right-justify the text?
推荐答案
google搜索的第四项右对齐文本Sharpdx Direct2d向我显示了 TextFormat 的文档。 code>类,其属性为
TextAlignment
。有时候稍微搜索一下会比使用Stackoverflow更快;)
The fourth entry for the google search "right justify text sharpdx direct2d" shows me the documentation of the TextFormat
class, which has the property TextAlignment
. Sometimes a little search is faster then to use Stackoverflow ;)
这篇关于使用SharpDX / Direct2D右对齐文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文