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

Started by
3 comments, last by kubera 6 years, 7 months ago

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"?

Advertisement

I just use this wrapper, works like a charm :D

http://fw1.codeplex.com/

.:vinterberg:.

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.

Maybe the BMFont: http://www.angelcode.com/products/bmfont/
I render texts using this free tool. It creates textures.

This topic is closed to new replies.

Advertisement