Game Design, Programming and running a one-man games business…

Democracy 3 and rendering crisp text in directx

Democracy 3 is a text heavy game. Text and stats, and graphs. So it’s pretty important it is all legible. I’ve spent the best part of two days monkeying around with my text rendering code, which is part of my library (all written by yours truly), trying to get better results. My aim is obviously easy readability. here is some text from the current (Democracy 2) game: (excuse the bitmap format but obviously I don’t want to add artifacts here…)

oldtext

And here is the current implementation in Democracy 3 (different color scheme too).

newtext

I think the second example is marginally better, but frankly that’s just a better color scheme and bigger text. the actual *quality* of the text is certainly nothing special. What I want, clearly is something as good as the text I see windows drawing in webpages and text documents outside of games. Unfortunately, that isn’t as easy as it sounds.

Most LCD monitors are set up to use cleartype, information on wikipedia. This is a cunning system that effectively increases the screen resolution by using colored ‘sub-pixels’, You can see the effect by taking a screen grab of this page (for example) and then zooming in really close. You will notice this text isn’t really black, or indeed one color. Some sort of cool display/monitor-driver cleverness handles this when it displays text. The trouble is, you can’t just ‘enable’ that for a game drawn the way I do things, where each character is effectively a tiny sprite. It just can’t be done.

Now there ARE some clever solutions to get amazing text, I know valve have some clever system, but this all involves implementation of a bunch of third party code and shaders. That isn’t a big deal *as such*, but it means that I have to cannibalize my extensive current GUI library and font loading and text-wrapping/aligning/processing stuff to work with all new systems. This would be a ton of work, and increase the spaghettiness of my library, something I am keen not to do.

I have tried just doubling my bitmap font size and using mip-maps to scale it down, but if anything that looks worse, so I’m trying to keep to my current system, which uses a 1:1 pixel to texel mapping with point filters engaged to get exactly what I see in my font bitmap file.I have a horrible feeling that swapping to black text on white screens is just going to look far worse than white text on black, at least from a  text-crispness POV.

There is of course, also the issue of opportunity cost. Is more time spent on this a good idea when I could spend that time elsewhere in the GUI, or for that matter, the simulation or game balance. Democracy 2 never earned me anyone bemoaning it’s crappy text, maybe the new text is good enough? Developers – What system do you use for text-rendering in games?

edit: maybe this black version looks better?

blacktext


14 thoughts on Democracy 3 and rendering crisp text in directx

  1. Is DirectWrite an option you could consider? AFAIK, it can target either GDI or Direct2D and should have all of the sub-pixel goodness you are seeking.

  2. I use Valve distance-mapped font technique in Arcane Worlds now. I can share Python modules for generating font texture if you want it. Shaders are quite easy too, and allow for effects such as shadow/glow and semi-blurred text.

  3. Re: Cleartype – if your font sprites are always being rendered at at actual size onscreen onto pixel boundaries, you should just be able to render your font textures with Cleartype and It Should Just Work; the coloured pixels will still find their appropriate sub-pixels to light.

    Also – a comment on your new font: I don’t know what you’re using to render the fonts with, but the text has a slightly blotchy look to it, I think because the contrast isn’t coming out well on the diagonal lines – they look lighter than the horizontal and vertical ones. Possibly a gamma thing – how do they look in-game?

  4. How about FreeType? The XNA importer for FreeType produces excellent text, and the original library is (I think) good with C++, and (unfortunately) a little effor

  5. Cliff, is it at all possible to make the font size variable? I usually go right to the options to see if I can scale the GUI.

    At our ripe ol’ age (I’m a bit older than you), I have a difficult time reading the font on my big screen in the living room and on my 17″ laptop. Text-heavy games drive me mad trying to get comfortable and be able to read the text as well.

  6. Not a day goes by when I do not thank providence that I am not a programmer. It’s like building your own car from scratch, isn’t it?

    I think a type designer would have fits about how your text looks at the moment. The kerning is peculiar – look at “ye” in the blue “employer” and “em” and “oy” in the grey “employer”, for instance, and “fraction” is wrong in entertainingly different ways in each sample, too. And different letters have subtly different weights, and vertical and horizontal lines usually but not always look heavier than diagonals and curves…

    I’m not having a go at you, you understand – in your position I’d probably just say “if it was good enough for AmigaDOS 1.3, it’s good enough for me”. It’d just never occurred to me that even THIS could be a problem. Godspeed, brave adventurer.

  7. Use a font that is made for screen reading, and forget about cleartype?

    Cleartype is an abomination, all it does is make text look horrible.

  8. I should point out those images might be scaled by the blog, so be sure to click on them. I also added one in pure black to see if it looks better (I think it does). I know there are some kerning tweaks needed, luckily my text renderer at least does allow me to adjust that sort of thing, when I pick final fonts and get around to finessing it.

  9. Black text is better, I hate grey text on white background, causes strain on my eyes. An advice; can you make font size an option (customizable)? An indie rpg, driftmoon lets you adjust fontsize of ingame text. I loved to be able to do that.

  10. First of all, let me say that Democracy 2 was excellent for what it was and after a week of pure suffering with Geopolitical Simulator 3, I was excited to get back results when I googled for Democracy 3. IMHO, don’t mess with the fonts at all. Never had any problems with them whatsoever. Also IMHO, the new samples look much worse.
    I’ll look for a more relevant thread to add a couple of suggestions for the new version.

Comments are currently closed.