Τα δεσίματα (binding) που δημιουργεί η Lua με την C++ δίνουν τη δυνατότητα να μπορείς να φορτώνεις fonts ενώ η εφαρμογή τρέχει. Παράδειγμα - script σχετικό με την τυπογραφία είναι το ακόλουθο:

verdana = of.font()
franklinBookLarge = of.font()

counter = 0

----------------------------------------------------
function setup()
    print("script setup")
    -- now load another font, but with extended parameters:
    -- font name, size, anti-aliased, full character set
    verdana:loadFont("fonts/verdana.ttf", 8, false, true)
    verdana:setLineHeight(20)
end

----------------------------------------------------
function update()
    of.background(255, 255, 255)
    counter = counter + 1
end

----------------------------------------------------
function draw()

    of.setHexColor(0x000000)
    verdana:drawString("hello, I am aliased verdana -- full character set, see: � ! ", of.mouseX(), of.mouseY())


    of.setHexColor(0x000000)
    verdana:drawString("yeah, but I'm not exactly pretty\nthe problem is with freeType library...\napple has a patent on TTF font hints\nso our aliased type via freeType isn't super looking", 100, 380)

end

----------------------------------------------------
function exit()
    print("script finished")
end
Posted on .
blog comments powered by Disqus