FontWidth?
Displaying 1-8 of 8 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
jrhee

Is it me, or does FontWidth not work? I get the error message "Could not resolve identifier FontWidth" when I use it as follows:

log(str(FontWidth(menuFont)));

However,
log(str(FontHeight(menuFont)));
works just fine.

Am I losing my mind here?

Posted on 2006-06-07 15:24:18

mcgrue

weird. I never knew there was a Fontwidth. Did you add that, ovk?

Anyways, it might not actually exist! We'll get back to you on that.

What does, however, is TextWidth. Which is what you want anyways.

http://www.verge-rpg.com/docs/view.php?libid=1&function=53

See, since fonts can be variable-width, textwidth returns the x-size of an entire string as it would be when rendered in any given font.

Hope that helps.

Posted on 2006-06-07 15:56:11

Overkill

Quote:Originally posted by mcgrue

weird. I never knew there was a Fontwidth. Did you add that, ovk?
No... well... That'd be kind of pointless seeing as the width of the font can already be retreived.

Here's how I know it hasn't been added:
Could not resolve identifier FontWidth


However! TextWidth() works just fine. It works on both variable width and fixed width fonts. Alternatively store the width of your font in a variable if you want a speedier and less ugly way for fixed-width text.

Hm, as an aside, seems the size of a space is 60% of the font's actual width in variable width mode. Interesting.

Posted on 2006-06-07 16:20:10 (last edited on 2006-06-07 16:22:17)

mcgrue

So how'd it get in the docs??!?

Posted on 2006-06-07 20:23:16

Overkill

Quote:Originally posted by mcgrue

So how'd it get in the docs??!?


Verge2 docs! It's a bug. Try search for any verge2/code vault function, it'll say it's under the v3 manual. It's so awesome.

Posted on 2006-06-07 20:25:50 (last edited on 2006-06-07 20:26:31)

mcgrue

Is this your doing or mine?

Posted on 2006-06-08 07:29:24

jrhee

FontWidth would be very useful for me because I'm working a lot with fixed width, and I want to multiply a var * FontWidth() to figure some spacing things out. TextWidth wouldn't work in quite the same way. No biggie though, there are plenty of other easy workarounds. Thanks for the quick replies either way.

Posted on 2006-06-08 08:07:44

mcgrue

here's a quick workaround:


/// returns the width of a fixed-width font,
/// or the most likely maximum width of a
/// variable width font.
int FontWidth( int f ) {
return TextWidth( f, "W" );
}

Posted on 2006-06-08 08:29:51


Displaying 1-8 of 8 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.