Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Different appearance of drawText and Gosu::Font
- By TheOm3ga Date 2010-06-09 20:21 Edited 2010-06-09 22:11
O HAI,

Looks like drawing a text using drawText renders it differently than using a Gosu::Font. I've been looking at the code and, I think, it's because Gosu::Font doubles the height and then scales down the text, messing it up big time. For big texts may work properly, but small texts like menu items, scaling it down blurs the text, hence drawText is sharper.

In Font.cpp, line 73, there's a "    pimpl->height = fontHeight * 2; // Auto-AA! " statement. I guess that Auto-AA is some kind of trick to get auto antialiasing, but given that the new SDL_ttf engine that Gosu uses automatically anti aliases text, there's no need to use it.

To get the same appearance with drawText and Gosu::Font, you have to change in Font.cpp:

line 73: remove "* 2"
line 88: remove "/ 2"
line 101: remove "/ 2"
remove or comment out lines 107 and 108

That will do the trick ;)
- By jlnr (dev) Date 2010-06-10 02:02 Edited 2010-06-10 02:26
Even anti-aliased text looked better for me when I did that, especially when I moved it to odd positions (like xx.5, which often happens when centering). Without the doubling, letters are restricted to have integer sizes, which is pretty rough for small fonts.

I realize that some operating systems, especially Linux, are extremely un-blurry when it comes to fonts. They effectively try to make every line a perfect one-pixel line that is aligned with the screen's pixel grid. I am not sure if that would work well with Gosu… the image would have to avoid being drawn at xx.5 positions by itself. :/ Also, what happens in cases when Gosu secretly scales the whole screen behind your back, like when it scales down the resolution because the screen is not big enough? I think the OS X'ish approach of just not caring about pixel boundaries would work much better. So I should actually apply the "custom anti-aliasing" to createText too. ;P

Also: Yay, finally a user cares about typography and has some standards even for a gamedev lib! ;)
Up Topic Gosu / Gosu Exchange / Different appearance of drawText and Gosu::Font

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill