MainFonts = {}
for i=1, 100, 1 do
MainFonts[i] = love.graphics.newFont("res/fonts/earthorbiter.ttf", i)
end
I feel like there should be a better way to do this, but a search on this forum and google later I've not found any better options yet, I tried a reddit post but the only idea there was to make a really big font and scale it down every time I needed a smaller one, but that too does not really sound like a solution as meant by the devs.
It would be helpful if you described what problem you're trying to solve. What exactly are you doing that requires all font sizes from 1 to 100? A font size of 1 is illegible, and 100 is unusually large.
I don't need all fontsizes from one to 100, I just thought it was kinda weird to have to need to create a font for every size I might need, and thought hoped that there was a more *polished?* way of doing that. But from my searches here, your answer, and my internet searches it seems that there is not.
I guess I'll just add fonts to that array as needed then.
Yeah, that's the way to go. Love converts fonts to textures and draws textured quads instead of vectors. So you have to explicitly load each size. I recommend to implement a simple cache if you potentially load lots of different fonts/sizes in different places.
-- untested impromptu code
local cache = {}
function loadFont(font, size)
local key = font .. tostring(size)
if not cache[key] then
cache[key] = love.graphics.newFont(font, size)
end
font = cache[key]
return font
end
That being said, I'm working on a library that makes it possible to load fonts as meshes. I will post it here in the forum once it's in a usable state.