本文介绍了如何从IDWriteFontFace创建IDWriteTextFormat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建W8 C ++ / CX DirectX应用程序,我试图使用自定义字体文件从应用程序自己的存储。我找出如何使用 IDWriteFactory :: CreateFontFileReference 从目录加载 IDWriteFontFile ,然后如何从中创建 IDWriteFontFace

I'm creating W8 C++/CX DirectX application and I'm trying to use custom font file from application own storage. I figure out how to use IDWriteFactory::CreateFontFileReference to load IDWriteFontFile from directory and then how to create IDWriteFontFace from it.

我现在不知道的是如何使用 IDWriteFontFace 加载 IDWriteTextFormat 所有。我应该这样做,虽然 IDWriteFontCollection

What I don't know now is how to use IDWriteFontFace for loading IDWriteTextFormat, if it is possible at all. Should I do this though IDWriteFontCollection ?

对不起,如果答案是真的愚蠢和微不足道,我是新的DirectX,

Sorry if the answer is really stupid and trivial, I am very new to DirectX and learn everything on the go.


推荐答案

看来,最好的示例如何做到这一点直接与Win7SDK directWrite示例。请参阅。

It appears that the best sample on how to do this ships directly with the Win7SDK directWrite samples. See the DirectWrite\CustomFont C++ sample.

此过程不涉及获取或使用任何 IDWriteFontFace 类型。事实上,我可以用 IDWriteFontFace 做的唯一的事情是确定 glyphindices

The process does not involve obtaining or using any IDWriteFontFace types. In fact, the only thing you can do with an IDWriteFontFace that I can see is determine glyphindices.

相反,你从一个工厂开始,如在所有directX API中,然后在工厂,你想要一个字体集合,和一个,并使用该字体集枚举字体。创建文本格式的界面要求您传递自定义字体集合,而不是您的字体。

Instead, you start with a factory, as in all directX APIs, then with the factory, you want to make a font collection, and a font file loader, and enumerate fonts using that font collection. The interfaces for creating a text format expect you to pass in your custom font collection, not your font face.

正确使用接口类型IDWritefontFace获取字形的示例可在代码项找到信息。

A sample of correct use of the interface type IDWritefontFace to get glyph information is found here on codeproject.

这篇关于如何从IDWriteFontFace创建IDWriteTextFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 09:19