我们创建一个IDWriteFactory7 CComPtr接口:
CComPtr<IDWriteFactory7> _writeFactory;
_hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(_writeFactory), reinterpret_cast<IUnknown**>(&_writeFactory));
创建工厂工作。但如果我们尝试创建IDWriteTextLayout4,则使用以下工厂:
CComPtr<IDWriteTextLayout4> _textLayout;
_writeFactory->CreateTextLayout(
wtext.c_str(), // The string to be laid out and formatted.
wcslen(wtext.c_str()), // The length of the string.
_textFormat, // The text format to apply to the string (contains font information, etc).
size.width, // The width of the layout box.
size.height, // The height of the layout box.
&_textLayout // The IDWriteTextLayout interface pointer.
);
CreateTextLayout(..)方法不能使用IDWriteTextLayout4,而是需要IdWriteTextLayout。
有人能举个例子吗?
systemcpro和Simon Mourier的评论解决了这个问题。