2D font rendering?

Started by
3 comments, last by Jason Z 11 years, 1 month ago

So from what I understand, there are two ways to go about rendering fonts in DirectX 11. A) you can load a texture with all of a font's characters as well as a text file mapping sections of the texture to actual ASCII values. B) you can use the GDI to load and render fonts.


Which would be more suited towards rendering text at a relatively fast rate in my game?

J.W.
Advertisement

B is usually just a way to automatically generate the texture and the mapping for A in code, so they are equivalent.

Using B might be better if you use many different font-sizes and not the same letters all the time, to avoid saving massive textures and charactermaps, but otherwise using A directly is probably better so you don't have to have the GDI code in your game and can avoid generating the textures every time.

If you want a library that draws text for you, I made one a couple of years ago that uses B, but with DirectWrite instead of GDI: http://fw1.codeplex.com/

Why not just use Direct2D / DirectWrite ? Isn't that the best way to do fonts in DX11 ?

I would never consider GDI (is that even supported anymore ?). You could roll your own font-sheets as well, but for straight forward font rendering, D2D/DW is much easier and better quality.

I would never consider GDI (is that even supported anymore ?).

Hell will probably freeze over before GDI disappears proper. However it's advisable that you use GDI+ for this type of stuff if you're even considering GDI.

Why not just use Direct2D / DirectWrite ? Isn't that the best way to do fonts in DX11 ?

I would never consider GDI (is that even supported anymore ?). You could roll your own font-sheets as well, but for straight forward font rendering, D2D/DW is much easier and better quality.

Yes it is supported - even when technologies get deprecated they are still available on Windows for millenia... That is one benefit that Windows developers often overlook. The same complaints are going on right now about XNA - which is not in active development anymore, but will still be available for a long time to come...

I would never consider GDI (is that even supported anymore ?).

Hell will probably freeze over before GDI disappears proper. However it's advisable that you use GDI+ for this type of stuff if you're even considering GDI.

This is right on - GDI+ is the way to go. In fact, MJP has provided an implementation of this for Hieroglyph 3 that you can take a look at (see SpriteFontDX11 class).

This topic is closed to new replies.

Advertisement