IDWriteTextFormat::SetTextAlignment 用于在 DirectWrite 中对齐文本,它需要一个 DWRITE_TEXT_ALIGNMENT 类型的参数
enum DWRITE_TEXT_ALIGNMENT {
DWRITE_TEXT_ALIGNMENT_LEADING,
DWRITE_TEXT_ALIGNMENT_TRAILING,
DWRITE_TEXT_ALIGNMENT_CENTER,
DWRITE_TEXT_ALIGNMENT_JUSTIFIED
};
前 3 种都运行良好,但最后一种 DWRITE_TEXT_ALIGNMENT_JUSTIFIED 不起作用,当我尝试设置它时,我得到一个无效参数错误
HRESULT hr = g_pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_JUSTIFIED);
if(FAILED(hr))
{
MessageBox(NULL, L"Center text failed!", L"Error", 0);
return;
}
这似乎不是一个有效的论点,为什么?有人遇到同样的问题吗?