BUG: Anti-aliased TTF fonts misalign gui texts

Started by GarageGothic, Tue 24/05/2005 11:40:42

Previous topic - Next topic

GarageGothic

I'm having a problem with antialiased ttf fonts. Whenever antialiasing is turned on, antialiased label or button texts will move down a couple of pixels (I'm not sure whether this is the case for RawDrawing of antialiased fonts as well). The height of the shift seems to vary depending on the size of the font, but I've experienced texts that jump 4 or 5 pixels whenever antialasing is turned on/off. This makes it impossible to  align certain texts precisely.

Also, the shift isn't an exact number of screen units, so it isn't possible to take precautions such as just moving the text 1 or 2 units upwards if the text is antialiased.

(The problem is very obvious in my game, as it has an option to toggle anitaliasing in-game, and the whole options menu jumps down whenever it's activated. But unless you force antialiasing always on or off at game start, anybody could experience it by using the setup program)

Gilbert

In addition to this, I'll add (i'd noticed this long ago, but it's not really that important to me, so I didn't report):
- position of SCI text on buttons (maybe label and other things, too) can be off by one pixel vertically if you test a game in low res. and high res.
For example, if you have a 320x240 game, running the game in 640x480 can make the button texts higher by one pixel (compared to running it in 320x240).

Pumaman

This seems to be related to the TTF rendering library that AGS uses. I presume it positions the text slightly lower so that it can anti-alias the pixels just above the top of the text.

Without me knowing how the library decides how much to move the text, it's difficult to be able to fix it. I'll look into it.

The "anti-alias" option in the Setup program only affects sprites, not fonts. Font antialiasing is only controlled by your script.

GarageGothic

Shows how much I know ;) I could have sworn that AA'd fonts were also in the setup program.
If there's no fix for it, perhaps I should just force it on by default, even though it's slower (it looks terrible without it anyway).

I was curious about another thing in the ttf rendering library as well: Times New Roman shows up really crisp at 12pt in Internet Explorer and Word, without any kind of anitaliasing. But if I import it into AGS at 12pt and doesn't AA it, it's drawn very crudely. Especially the 'W's look bad. Is there any other way to improve on this than dumping a screenshot of the full character set as it looks in IE and then creating a SCI font of it?

Pumaman

Are you sure this isn't just due to the resolution difference? If you run Word at 1024x768 and your game is 640x480, the fonts will obviously not look as good.

InCreator

I think that's a resoluion problem.
There's no way to get good-looking TTF font in AGS at 320x240 res, since letters become somewhat weirdly aligned and won't scale down very well... Same for outlines.

Yet, same fonts look quite well in - for example - MSPaint - at same size and resolution.

For example, Arial, very much used and supposedly, very "compatible" font - won't look well if it's imported size is below 12pts.

Gilbert

Actually, for displaying crispy texts, some of the TTF font files contain embedded bitmap fontsets to some low and commonly used resolutions (eg. 8pt, 12pt, etc.), this can be verified by opening up a TTF file using a font editor.
So it's highly probable that such a standard font file like Times will do the same, when you display it in say, 12pt under Windows, that bitmap fontset is used instead (since the vector font can look terrible under such a low resolution).
As far as I know, even if a TTF file has multiple embeded fontsets (some font files are actually collections of many fonts, for say, bold texts, italic texts, etc.), the AGS engine can only use one vector fontset in it (correct me if I'm wrong), the other sets are ignored (but seems to be still kept in the game files, so they can waste space).

GarageGothic

Gilbot, I think you're right - that makes sense (I'm pretty sure it is bitmap since it really is pixel perfect - I've zoomed in on a screenshot in PhotoShop. If it was just resolution, there wouldn't be any difference except the drawn size, would there?).

I suspect there's no other way to extract the bitmap font other than copy-pasting it char by char into an SCI font then?

Gilbert

#8
You can actually use those Font editor (the only free one I can find is FontForge) to open up a font file, edit it, you can even extract embeded sets in a TTF file (so that's why I can confirm the existence of Bitmap fonts inside these files).
I don't know if there're easy way to convert them directly to a SCI font though.

Edit: Just checked, though it's not trivial to convert a bitmap .FON set to a SCI font, you CAN actually rename a .FON file to .TTF file and import it in AGSedit, you only need o make sure that the point size you select is an available size in the file, or else AGS will only use the smallest size contained in it (I think), that mean you can actually use a bitmap font and even use all the 256 characters if you're suing a translation.

GarageGothic

Thanks Gilbot, I'll check it out. I wonder if Font Creator, which I'm using, can do this as well.

SMF spam blocked by CleanTalk