GLBasic Benutzerhandbuch

Main sections

GETFONTSIZE

GETFONTSIZE sx##, sy##



Ein Befehl, mit dem die Buchstaben-Größe des aktuell verwendeten Fonts ermittelt werden kann.

Sample:
 
DRAWRECT 300, 100, 200, 300, RGB(20,20,120)
BOXPRINT ("Dies ist ein langer Text, der umgebrochen wird", 300, 100, 200)
SHOWSCREEN
MOUSEWAIT


// ------------------------------------------------------------- //
// -=# BOXPRINT #=-
// ------------------------------------------------------------- //
FUNCTION BOXPRINT: str$, x, y, wx
// Diese Variablen sind als LOCAL definiert:
// str$, x, y, wx, void

LOCAL tx, ty // Width of one character
LOCAL cx, cy, word$, c$, cpos

GETFONTSIZE tx, ty

cy=y
str$=str$+" "
cx=x
WHILE cpos < LEN(str$)
c$=MID$(str$, cpos, 1)

word$=word$+c$

IF c$=" "
IF cx-x+(LEN(word$)-1)*tx > wx
cx=x; cy=cy+ty
ENDIF
PRINT word$, cx, cy
cx=cx+ LEN(word$)*tx
word$=""
ENDIF
cpos=cpos+1
WEND
ENDFUNCTION void // BOXPRINT

See also...