You have a couple options:
- Get the width and height of the text (Font:getWidth( 'Blah Blah' ), Font:getHeight( 'B' ) (note that for get height, if you test the largest letter, that's the only one that matters, so this will save some time))
- Then make those values the offset width and heights, and use your own values for rotation.
- Use the other values for love.graphics.print
Edit:
It would look a bit like this:
Code: Select all
local Fonts = {}
function NewFont( String, Font )
local Index = #Fonts + 1
local Width = Font:getWidth( String )
local Height = Font:getHeight( 'A' ) -- This should do the trick, unless you use all lower-case, etc.
local OffsetX = Width / 2
local OffsetY = Height / 2
Fonts[Index] = { String, x, y, 0, 1, 1, OffsetX, OffsetY }
return Index
end
function SetPosition( Index, x, y )
Fonts[Index][2] = x
Fonts[Index][3] = y
end
function SetRotation( Index, Radians )
Fonts[Index][4] = Radians
end
-- Make other functions for other things, like scale, etc.
function Draw( Index )
love.graphics.print( Fonts[Index] )
end
This should work, but I can't guarantee it since I haven't tested it.