Sign in to follow this  

What type of font system...

Recommended Posts

Should I go for in built API fonts or should I use a quad based system? What are the advantages of both? The font system would be used for pretty much all situations. I'm personally thinking the latter - quad based texture mapped fonts because of flexibility but I always get antialiasing (well, filtering problems) when I don't need it (Arial, 10PT for instance) Any advice apreciated! aCiD2

Share this post

Link to post
Share on other sites
If you're going to be doing a lot of text, rolling your own can be very very beneficial. But it can also be quite a lot of work.

The ID3DXFont methods are very powerful these days, particularly with their ability to cache the results until they have to (forget the exact term [embarrass]).

My engine generates quite a lot of runtime text that doesn't change very often (but does change). In rolling my own system, I set it up to cache generated text as vertex buffers - thus subsequent frame rendering was done with a single DrawPrimitive() call. Taking advantage of the temporal coherancy of my games interface is something that you can't really expect of a pre-built library because it relies on knowing quite a bit about your application.

Caching the output text is crucial to performance - even looping through a character array and looking it up every time you want to render some text is a bad idea. We got by far the biggest gains in rendering performance by reducing the overhead of text (look at these thumbnails to see how much text we have on some screens!).

My "roll your own" system generates the textures as fonts are loaded - it uses various Win32 functions to work out how much texture space is needed, creates the texture, then uses the text-to-hDC functions to draw all of the characters (and remember their bounding boxes). I then upload this hDC to a texture and store it in memory.

I found generating the fonts as-and-when to be better than loading them from disk - its more [disk] storage efficient and it doesn't require my artist to do a whole lotta work whenever someone wants a different font [wink].

Your problems with Antialiasing (or aliasing) can be solved using some trickery. If you know that you have a near 1:1 mapping (i.e. you're not stretching your 10pt font) then you might as well disable linear filtering and stick with point filtering. You only really want filtering when you try and make your 10pt font into a 16pt font (or 10pt->6pt). Also, using some tricks of alpha blending you can also anti-alias the edges of text so as not to get too many ugly filtering artifacts.

That the sort of thing you wanna know?

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