; LoadFontSheet Example ; --------------------- ; Requires Extended mode. Graphics 640,480,0,2 SetBuffer BackBuffer() ; The .fnt descriptor names the PNG atlas stored beside it sheet_file$="../../../samples/font-sheets/assets/glossy_cyan_techno_font_atlas_game.fnt" ; LoadFontSheet(datafile$[,height]) returns an ordinary font handle; ; height sets the output line height in pixels height=36 sheet=LoadFontSheet(sheet_file$,height) If sheet=0 Then RuntimeError FontSheetError() ; A small system font for the info overlay info_font=LoadFont("Arial",14) While Not KeyDown(1) ; Keys 1-3 reload the sheet at a different output line height new_height=0 If KeyHit(2) Then new_height=24 If KeyHit(3) Then new_height=36 If KeyHit(4) Then new_height=48 If new_height<>0 And new_height<>height Then FreeFont sheet height=new_height sheet=LoadFontSheet(sheet_file$,height) If sheet=0 Then RuntimeError FontSheetError() End If Cls ; The bitmap font works with the normal Text command SetFont sheet Color 255,255,255 Text 320,150,"LEVEL UP!",True ; The current Color tints the atlas image pulse=155+Sin(MilliSecs()/4.0)*100 Color pulse,255,255 Text 320,240,"abc xyz 09",True SetFont info_font Color 255,255,255 Text 0,0,"1-3: line height 24/36/48 Esc: exit" Text 0,20,"LoadFontSheet(sheet_file$,"+height+") handle: "+sheet Flip Wend FreeFont sheet End