------------------------------------------------------------------------------ -- Imports ------------------------------------------------------------------------------ local love = require 'love' local make_class = require 'src.utils.classes' local Asset = require 'src.utils.asset' ------------------------------------------------------------------------------ -- Class definitions ------------------------------------------------------------------------------ -- Font is a simple wrapper around Löve's own Font class to allow for -- easy loading/unloading and automatically checking if it's is valid -- before using it. local Font = make_class(Asset) ------------------------------------------------------------------------------ -- Class methods ------------------------------------------------------------------------------ function Font:_init(file_name, size) self.file_name = string.format('assets/%s', file_name) self.size = (size ~= nil and size) or 20 end function Font:load() self.f = love.graphics.newFont(self.file_name, self.size) end function Font:unload() self.f = nil end function Font:set() if self.f ~= nil then love.graphics.setFont(self.f) end end function Font:unset() love.graphics.setFont() end ------------------------------------------------------------------------------ -- Module return ------------------------------------------------------------------------------ return Font