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.
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 ?
Sorry if the answer is really stupid and trivial, I am very new to DirectX and learn everything on the go.
See MSDN DirectWrite help topic on Custom Font Collections for the necessary high level view of how to load your own custom fonts at runtime. Your guess about how to do this was wrong.
It appears that the best sample on how to do this ships directly with the Win7SDK directWrite samples. See the DirectWrite\CustomFont C++ sample.
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
.
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.
A sample of correct use of the interface type IDWritefontFace to get glyph information is found here on codeproject.
You can not create IDWriteTextFormat with IDWriteFontFace, you can create a IDWriteTextFormat instance with function IDWriteFactory::CreateTextFormat.
IDWriteFontFace was used to describe the properties of font, while IDWriteTextFormat used to describe the properties of text.