Add an example of the bitmap fonts
This commit is contained in:
parent
ee4762673a
commit
cf06bdce64
2 changed files with 20 additions and 4 deletions
|
|
@ -4,21 +4,37 @@ if love.system.getOS() ~= 'DOS' then
|
|||
end
|
||||
|
||||
local platform = require "platform.platform"
|
||||
|
||||
function love.load()
|
||||
platform.init()
|
||||
end
|
||||
local ttf
|
||||
local bf
|
||||
local bfi
|
||||
|
||||
local function drawText(str, x, y)
|
||||
local font = love.graphics.getFont()
|
||||
love.graphics.print(str, x - font:getWidth(str) / 2, y - font:getHeight() / 2)
|
||||
end
|
||||
|
||||
function love.load()
|
||||
platform.init()
|
||||
|
||||
ttf = love.graphics.newFont()
|
||||
bf = love.graphics.newImageFont("font.png",
|
||||
" abcdefghijklmnopqrstuvwxyz" ..
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
|
||||
"123456789.,!?-+/():;%&`'*#=[]\"")
|
||||
bfi = love.graphics.newImage("font.png")
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
platform.drawStart()
|
||||
|
||||
love.graphics.clear()
|
||||
love.graphics.setFont(ttf)
|
||||
drawText('Hellorld!', 160, 100)
|
||||
love.graphics.setFont(bf)
|
||||
love.graphics.print(" abcdefghijklmnopqrstuvwxyz", 0, 110)
|
||||
love.graphics.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ0", 0, 130)
|
||||
love.graphics.print("123456789.,!?-+/():;%&`'*#=[]\"", 0, 150)
|
||||
love.graphics.draw(bfi, 0, 170)
|
||||
|
||||
platform.drawEnd()
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue