GLBasic forum

Main forum => GLBasic - en => Topic started by: bigtunacan on 2012-Jan-11

Title: Font width?
Post by: bigtunacan on 2012-Jan-11
Is there a command that will return the width & height of the currently set font?
Title: Re: Font width?
Post by: matchy on 2012-Jan-11
 :zzz:

GETFONTSIZE sx##, sy##
Title: Re: Font width?
Post by: Crivens on 2012-Jan-11
And also use LEN (remember kern flag) to see how wide a line of text will be for the currently set font.

Cheers
Title: Re: Font width?
Post by: bigtunacan on 2012-Jan-12
Crivens,

What do you mean by "remember kern flag" how does this impact me?
Title: Re: Font width?
Post by: MrTAToad on 2012-Jan-12
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
Title: Re: Font width?
Post by: Kitty Hello on 2012-Jan-12
No - the LEN(text$, FALSE) will also return the number of characters.
Title: Re: Font width?
Post by: MrTAToad on 2012-Jan-12
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
Title: Re: Font width?
Post by: Kitty Hello on 2012-Jan-12
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?
Title: Re: Font width?
Post by: Crivens on 2012-Jan-12
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
Title: Re: Font width?
Post by: hardyx on 2012-Jan-13
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. :)