gpt4 book ai didi

c++ - DirectWrite 对齐文本中心

转载 作者:行者123 更新时间:2023-11-28 00:14:57 24 4
gpt4 key购买 nike

我正在尝试将我必须绘制的文本居中对齐。我用 ID2D1RenderTarget::DrawTextLayout method .问题是,如果我将文本水平对齐方式设置为 DWRITE_TEXT_ALIGNMENT_LEADING(默认值),则会仔细绘制文本,但如果我将此值更改为 DWRITE_TEXT_ALIGNMENT_CENTER,则文本会移动对。

示例字符串是

Internal Amazing 
Scupper

结果如下(第一个是alignment leading):

enter image description here enter image description here

最佳答案

我的评论作为答案(是的,猜对了:)):

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 操纵接口(interface)( GetMaxWidthSetMaxWidth )。

关于c++ - DirectWrite 对齐文本中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30916523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com