Font width?

Previous topic - Next topic

bigtunacan

Is there a command that will return the width & height of the currently set font?

matchy

 :zzz:

GETFONTSIZE sx##, sy##

Crivens

And also use LEN (remember kern flag) to see how wide a line of text will be for the currently set font.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

bigtunacan

Crivens,

What do you mean by "remember kern flag" how does this impact me?

MrTAToad

There are three possible combinations with the LEN command :

length%=LEN(text$) - Returns number of characters in text$
length%=LEN(text$,FALSE) - Returns the non-proportional text width of text$ using the current font
length%=LEN(text$,TRUE) - Returns the proportional text width of text$ using the current font

Kitty Hello

No - the LEN(text$, FALSE) will also return the number of characters.

MrTAToad

#6
Quote from: Kitty Hello on 2012-Jan-12
No - the LEN(text$, FALSE) will also return the number of characters.
Apparently not :

Code (glbasic) Select
DEBUG LEN("Test",FALSE)

Returns a value of 32

With a proper font, the following :

Code (glbasic) Select
DEBUG LEN("Test",FALSE)+"\n"
DEBUG LEN("Test",TRUE)+"\n"
DEBUG LEN("Test")+"\n"


returns :

76
28
4

Kitty Hello

cool. So the manual needs better specifications. So cool.

You want the box?
vertical information is GETFONTSIZE fx, fy // use fy.
Or did I misunderstand the question?

Crivens

I was going to say. That's what I do. GETFONTSIZE for height, and LEN (with appropriate kern flag) for width. Full stop nothing more to say.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

hardyx

Quote from: Kitty Hello on 2012-Jan-12
cool. So the manual needs better specifications. So cool.
That's the reason that I proposed another function for get text size, like TEXTLEN(). Not mixing string functions with graphic functions. But don't change this now. :)