Advertisement Jump to content

DX11 How do i need to open a .tff to get a DirectX11 texture?

This topic is 493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to render true type fonts in DirectX11, right now in one program im using stb_truetype.h to get the position and texcoords from every character i want.
And in other one, i have DirectX11 with a texture that i can fill it with some information, in this case the .ttf info. 
But how do i need to open the .tff to tell the texture something like: "Hey, these are the coordinates you need, copy that pixels and fill yourself"?

Share this post

Link to post
Share on other sites

This two things are unrelated, TTF files are just a storage for vector graphic glyphe representations. They are no different than PNG to be a storage for bitmap images.


DirectX11 is a graphic API to draw stuff ( in a very broad way ). It is true that some draw operations are simpler than other, it has for example the concept of texture that map directly to the bitmap stored any image format of your preference. As you may have noticed, tho it does not have a native way to render vector graphics. It does not means it is impossible, there is techniques to render true type fonts directly from the original TTF data, it involves usually some pre-processing with weird triangulations and fancy shaders, but as it is complex, most of the time, it is enough to just rasterize the font into a bitmap, using stb_truetype, freetype or any alternative on the cpu, and fallback to the simpler native way to display stuff : textures.


The details of how you will pack the various glyph into your direct X texture is totally under your control and depends on your needs, would it be static allocation, a dynamic cache of glyphes, will you generate a distance field representation, etc.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!