Skip to content

Commit

Permalink
refactor Font into utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasszem committed May 9, 2020
1 parent 17806c8 commit 2f0b08c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
18 changes: 0 additions & 18 deletions Font.lua

This file was deleted.

1 change: 0 additions & 1 deletion GUI.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local VDiv = require("VDiv")
local Font = require("Font")
local GUI = VDiv:extend()

function GUI:new(...)
Expand Down
17 changes: 17 additions & 0 deletions utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,21 @@ function centerBox(bX, bY, bW, bH, w, h)
local x = bX + (bW-w)/2
local y = bY + (bH-h)/2
return x, y
end

local cache = {}

function Font(size, file)
local fileN = file or "DEFAULT"
if cache[size] then
if cache[size][fileN] then
return cache[size][fileN]
end
end
local f = love.graphics.newFont(size, file)
if not cache[size] then
cache[size] = {}
end
cache[size][fileN] = f
return f
end
1 change: 0 additions & 1 deletion yalg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ VDiv = require("VDiv")
HDiv = require("HDiv")
Button = require("Button")
Label = require("Label")
Font = require("Font")
Switcher = require("Switcher")

0 comments on commit 2f0b08c

Please sign in to comment.