text scaling basics

This commit is contained in:
Michael Freno
2025-10-09 15:42:56 -04:00
parent 198114431b
commit a1530c2376
4 changed files with 243 additions and 21 deletions

View File

@@ -17,20 +17,22 @@ function love_helper.graphics.getDimensions()
end
function love_helper.graphics.newFont(size)
-- Ensure size is a number
local fontSize = tonumber(size) or 12
-- Return a mock font object with basic methods
return {
getWidth = function(self, text)
-- Handle both colon and dot syntax
if type(self) == "string" then
-- Called with dot syntax: font.getWidth(text)
return #self * size / 2
return #self * fontSize / 2
else
-- Called with colon syntax: font:getWidth(text)
return #text * size / 2
return #text * fontSize / 2
end
end,
getHeight = function()
return size
return fontSize
end,
}
end