Page 1 of 1

Small fonts: Bad alignment, poor clarity

Posted: Fri Feb 10, 2006 16:59
by synergy
Hey guys,

I've been wrestling with this problem for quite some time, and I need some expert help.

Although I thought I once read a forum post regarding this issue, I am sure there was no definite resolution to the problem.

My application is intended to run at a full-screen (and static) resolution of 800x600. In an attempt to design a slick-looking UI, I stumbled into an issue with small fonts: poor alignment (i.e., they get muddled together in a somewhat random-looking manner) and poor clarity. Small fonts are necesary for a UI that contains a bunch of character data (stats, item descriptions, etc.), and I can't get them to perform the way I want.

I took a screenshot in 800x600 windowed mode to demonstrate this issue. When viewed at higher resolutions, the text naturally looks clearer simply as a result of more pixels (an obvious fact that I am aware of, and is also likely why CE fonts look much clearer at higher resolutions). In this shot there are two text sections: one with CE a font and one using D3DFont as a basline comparison. Font def file code:

Code: Select all

<Font Name="Tahoma-9" Filename="../datafiles/fonts/Tahoma.ttf" Type="Dynamic" Size="7" NativeHorzRes="800" NativeVertRes="600" AutoScaled="false"/>

Also note that I have antialiasing turned off for this font (in my code).

When looking at this image, I would like you to note the following things:
1. The individual characters are jumbled together and inconsistently aligned (i.e., the spacing between characters is sometimes too large and other times nonexistent).

2. The accuracy of the font portrayal is off: the dot on the "i" in "quick" is not separated, etc.

http://www.student.cs.uwaterloo.ca/~rcameron/example.bmp

Any help would be great. Perhaps this is merely a usage error.

Cheers,

Ryan

Posted: Sat Feb 11, 2006 11:02
by CrazyEddie
Hi,

Yeah, it looks pretty lame indeed. Unfortunately there's no "quick fix" solution that I can come up with off the top of my head.

The uneven sapcing issue could well be a result of our rounding screen locations to absolute pixel positions before final rendering- this was done to solve blurry rendering issues. This may be affecting the positioning of the glyphs.

As for any poor glyph rendering (in this case meaning the way it was rendered by FreeType) may be an issue with the way FreeType is configured (though I don't know for certain) - one possibility is at small sizes the hinting used is breaking down, because it's not using the 100% correct method for this due to patent issues (which would require a license from Apple to use).

The only things I can presently suggest are:
  • You could try disabling the rounding of rendering positions. This can be done in the CEGUIConfig.h file by commenting the define for CEGUI_ALIGN_ELEMENTS_TO_PIXELS, and requires a recompile of the system. It is extremely doubtful that the overall output from CEGUI in this mode will be acceptable.
  • You could try a recompile of the FreeType library and enable the patented hinting; while you may not be able to use the resulting binary without a license from Apple, you would be able to see if this has any affect on the output.
  • You could also try changing some of the values we pass into FreeType when we generate the font, it's possible alternative inputs would improve the rendering of these small fonts.
  • You might like to create a "bitmapped" / static font. Using these you can control the inter-glyph spacing more precisely. Though it's a painstaking process to create these fonts, since there is no tool to assist in this area at the present time.

Sorry I could not give you a simple fix, though we are aware there are such issues, and will be working to improve in these areas.

CE.

Thanks :)

Posted: Mon Feb 13, 2006 19:18
by synergy
Hello again,

Just wanted to let you know how things turned out. I tried commenting CEGUI_ALIGN_ELEMENTS_TO_PIXELS out and you prediction was correct: the quality of everything was unacceptable.

I decided to try a bitmapped font (noting that there were some previous posts about these). It *worked*. Aside from the extra work to tweak the glyph spacing, the font remains clear enough and will definitely do the job.

Thanks (as always) for your killer support, Ed.

CEGUI rocks.

Take care,

Ryan

Posted: Mon Feb 13, 2006 20:33
by CrazyEddie
Glad you managed to get a solution that works for you :)