What type of font system...

Started by
2 comments, last by jollyjeffers 19 years, 2 months ago
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
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
Advertisement
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?
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Spot on laddy, no wonder your rating is 1224 ^_^

Many thanks!
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
Quote:Original post by acid2
Spot on laddy, no wonder your rating is 1224 ^_^

As always, my pleasure and glad I could help out [smile]

Cheers,
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement