Right justify text using SharpDX/Direct2D

夙愿已清 提交于 2020-06-01 07:17:58

问题


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?


回答1:


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 ;)



来源:https://stackoverflow.com/questions/17253201/right-justify-text-using-sharpdx-direct2d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!