Sign in to follow this  
jdub

2D font rendering?

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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/

Edited by Erik Rufelt

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this