; StringHeight Example ; -------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; A small font for the info overlay info_font=LoadFont("Arial",14) size=32 font=LoadFont("Arial",size) msg$="LEVEL COMPLETE" While Not KeyDown(1) ; [ / ] shrink or grow the font (reloaded at the new size) If KeyHit(27) And size<64 Then FreeFont font size=size+8 font=LoadFont("Arial",size) End If If KeyHit(26) And size>16 Then FreeFont font size=size-8 font=LoadFont("Arial",size) End If Cls SetFont font ; StringHeight returns the string's pixel height in the current font - ; the classic use is centring text vertically h=StringHeight(msg$) w=StringWidth(msg$) y=(480-h)/2 Color 255,255,255 Text (640-w)/2,y,msg$ ; Guide lines exactly at the top and bottom of the string Color 80,200,255 Line 40,y,600,y Line 40,y+h,600,y+h SetFont info_font Color 255,255,255 Text 0,0,"[ / ] change font size Esc: exit" Text 0,20,"Arial "+size+"pt: StringHeight(msg$) = "+h+", so y = (480-"+h+")/2 = "+y Flip Wend End