gui/GuiManager/Text/fitFont.int
Ryan Ward 277cd5c553 I finally updated this thing
I need to keep a consistant record. I have small updates that exist everywhere sigh.
2019-02-10 10:09:01 -05:00

28 lines
629 B
Plaintext

function gui:fitFont()
local font
if self.FontFile then
if self.FontFile:match("ttf") then
font = function(n)
return love.graphics.newFont(self.FontFile, n,"normal")
end
else
font = function(n)
return love.graphics.newFont(self.FontFile, n)
end
end
else
font = function(n)
return love.graphics.newFont(n)
end
end
local Font,width,height,text=self.Font,self.width,self.height,self.text
local s = 3
Font = font(s)
while Font:getHeight()<height and Font:getWidth(text)<width do
s = s + 1
Font = font(s)
end
Font = font(s - 2)
Font:setFilter("linear","nearest",4)
self.Font = Font
end