I think you need to use newFont first, and then use setFont - like this:
Code: Select all
function love.load()
font = love.graphics.newFont("courbi.ttf", 15); --changed 'setFont' to 'newFont'
height = font:getHeight();
end
function love.draw()
love.graphics.setFont(font); -- invoked setFont here
width = font:getWidth("my project"); -- moved getWidth here and added the string
love.graphics.print("my project",100,100,0,1,1);
end
Notice that you are not really using 'height' and 'width' at all; the program will work exactly the same if you do this:
Code: Select all
function love.load()
font = love.graphics.newFont("courbi.ttf", 15);
end
function love.draw()
love.graphics.setFont(font);
love.graphics.print("my project",100,100); -- the 0,1,1 parameters have default values, you don't need to add them
end
(btw guys, I still think that love.graphics.setFont(filename, size) and love.graphics.setFont(size) are a bad idea - they lead to confusion, as seen here. Separating font loading / creation from font setting is The Right Thing To Do)
EDIT: getWith needs the string