Fixed-width ttf font not fixed width in AGS?

Started by GarageGothic, Mon 28/02/2005 15:30:52

Previous topic - Next topic

GarageGothic

I have a function where I need to align the last part of a save game name exactly no matter the length of the first part. I thought it could be done by adding spaces (checking for string length, then adding " " until it's correct). Of couse you need a font where all the letters/symbol/space are the same width, and I've found one that behaves like that in Word as well as in Photoshop.

BUT, when I import the ttf font in AGS, all of a sudden the space DOESN'T take up the same width as the other characters!

Is this an AGS thing, or should I keep on trying some other fonts? (I also tried with the SCI fonts, without any success). Is there anyway I could modify the font to get it to work?

SSH

If you are displaying the savegame names with a GUI label, then you might do better to use two labels to allow the alignment to work. If using a listbox, then you're up copper wine creek without a postman.
12

GarageGothic

#2
Yeah, I'm using the listbox. :(

But even if I was using the labels, how could that work? Perhaps displaying the same savename in both of them but with sizes/alignments to block out the unwanted part?

Edit: I'm curious, what is the technical reason that it doesn't work? How does AGS handle width/spaching of characters? Will fixed-width fonts never work properly? If it's just the spaces, I'm wondering if you could make some other character transparent and use that instead of a space?

RickJ

Garage,

I have been able to use fixed width TTF fonts without any problems... errrr..ahhh.. except one of the ones I tried crashed AGS but that's been passed on to CJ.   Perhaps the font you are trying to use isn't mon-spaced or has some other characteristic the causes such a problem in AGS. 

You could also try using GetTextWidth() to return the pixel width of the string for a given font and then adjust your spacing accordingly. 

GarageGothic

RickJ,

I'll try some other fixed width fonts then (I'd actually downloaded a bunch yesterday at work, but my CD-RW was defect. ARGH!). It may be a problem in that specific font. But I find it strange that it works in other programs.

Thanks.

RickJ

Quote
But I find it strange that it works in other programs.
Yeah, I thought that too when I found the one that cauysed AGS to crash.  Let me know if you're still having problems.  If so I could upload the fonts I'm using. 

Pumaman

AGS uses a third-party TTF renderer and I don't really understand how it works, so there's not a lot I can do about how it draws fonts I'm afraid.

Similarly, the font RickJ posted crashes inside the TTF renderer, so there's not much I can do to fix it unfortunately.

RickJ

Quote
AGS uses a third-party TTF renderer and I don't really understand how it works, so there's not a lot I can do about how it draws fonts I'm afraid.
That's cool.  Since there are plenty of TTF fonts to choose from I don't really see this as a problem.  Now that we know the situation we can stop complaining :D and get on with our lives.  Presummably in the long term the renderer you are using will be improved or a better alternative will become available etc, etc.   

edmundito

I thought AGS sized TTF fonts by pixels instead of by points because a lot of people were bitching about it when it was first introduced. Is this still true?

GarageGothic

Problem solved. Thanks for all your help.

It turns out that a lot of freeware so-called "fixed width" fonts don't live up to their name (even if they just gets misaligned by a character or two on a whole line). I ended up using good old courier instead, and that works like a charm. But I'll be on the lookout for a replacement as I'm not sure of the legality of using Windows fonts. I also experienced one font that crashed the game when displayed, but strangely enough only at certain font sizes.

SMF spam blocked by CleanTalk