-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLibIconFonts-1.0.lua
More file actions
29 lines (24 loc) · 1019 Bytes
/
LibIconFonts-1.0.lua
File metadata and controls
29 lines (24 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- Lua Globals --
-- luacheck: globals assert type
local MAJOR, MINOR = "LibIconFonts-1.0", 1 -- Should be manually increased
assert(_G.LibStub, MAJOR .. " requires LibStub")
local lib, oldminor = _G.LibStub:NewLibrary(MAJOR, MINOR) --luacheck: ignore
if not lib then return end -- No upgrade needed
local fonts = {}
-- Retrieve a specific icon font
-- @param fontName The name of the font
function lib:GetIconFont(fontName)
assert(fonts[fontName], fontName.."has not been registered.")
if type(fonts[fontName]) ~= "table" then
fonts[fontName] = fonts[fontName]()
end
return fonts[fontName]
end
-- Register an icon font
-- @param fontName The name of the font
-- @param fontFunc A function that returns a table containing the font icons
function lib:RegisterIconFont(fontName, fontFunc)
assert(not fonts[fontName], fontName.."has already been registered.")
assert(type(fontFunc) == "function", "fontFunc must be a function, got "..type(fontFunc))
fonts[fontName] = fontFunc
end