DirectWrite 对齐文本中心
DirectWrite align text center
我正在尝试将我必须绘制的文本居中对齐。我使用 ID2D1RenderTarget::DrawTextLayout method。问题是,如果我将文本水平对齐设置为 DWRITE_TEXT_ALIGNMENT_LEADING
(默认值),文本会被仔细绘制,但如果我将此值更改为 DWRITE_TEXT_ALIGNMENT_CENTER
,文本将向右移动。
示例字符串是
Internal Amazing
Scupper
结果如下(第一个是对齐前导):
我的评论作为答案(是的,猜对了:)):
Just a quick guess: Did you check that the maxwidth your layout box
isn't too broad, so the center would end there at the right?
ID2D1RenderTarget::DrawTextLayout
方法使用的IDWriteTextLayout
定义了布局框的最大宽度,它决定了文本居中的位置。它可以被 methods of the interface (GetMaxWidth and SetMaxWidth).
操纵
我正在尝试将我必须绘制的文本居中对齐。我使用 ID2D1RenderTarget::DrawTextLayout method。问题是,如果我将文本水平对齐设置为 DWRITE_TEXT_ALIGNMENT_LEADING
(默认值),文本会被仔细绘制,但如果我将此值更改为 DWRITE_TEXT_ALIGNMENT_CENTER
,文本将向右移动。
示例字符串是
Internal Amazing
Scupper
结果如下(第一个是对齐前导):
我的评论作为答案(是的,猜对了:)):
Just a quick guess: Did you check that the maxwidth your layout box isn't too broad, so the center would end there at the right?
ID2D1RenderTarget::DrawTextLayout
方法使用的IDWriteTextLayout
定义了布局框的最大宽度,它决定了文本居中的位置。它可以被 methods of the interface (GetMaxWidth and SetMaxWidth).