--------------------------------------------------- 
-- FBA Tutorials
--
-- Tutorial / 10 / TrueType Fonts
--
--------------------------------------------------- 
--
-- Show how to load and display truetype fonts
--
--------------------------------------------------- 



-- drawing a truetype font is very simple: 
-- You have to add your .ttf file to your resources
-- and then load it
local font = loadfont("knight2.ttf")
local font2 = loadfont("abduction.ttf")

function onmainloop()	
         clear(0,0,0)
 
         -- then draw our font!
         -- please remember that ttf rendering is slower than rendering graphical fonts
         -- so if you have lot of chars to draw, you should consider to use a graphical font
         
         -- choose style
         setfont(font, 36, 255, 0, 0)
         
         -- and then draw it
         drawtext(font, 10,30,"TrueType fonts")
         drawtext(font, 10,70,"are cool")
         
         setfont(font2, 18, 0, 255, 0)
         drawtext(font2, math.random(15,20),math.random(130,140),"(but FBA is cooler! :D)")

         
         -- get string width and use it to right align the text
         setfont(font2, 10, 0, 0, 255)

         mytext = "Right Aligned Text"
         mywidth = textwidth(font2, mytext)
         
         drawtext(font2, screenwidth()-mywidth, 210, mytext)


         if (mousedown() > 0) then
            quit()
         end
end
