-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont.lua
More file actions
40 lines (28 loc) · 747 Bytes
/
font.lua
File metadata and controls
40 lines (28 loc) · 747 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
30
31
32
33
34
35
36
37
--
-- Font management
--
local Font = Class:new()
Font._path = "assets/font/pixel.png"
Font._glyphs = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
Font._w = 16 -- Character width
Font._h = 20 -- Character height
Font._k = 2 -- Kerning
function Font:init(path, glyphs, w, h, k)
--
-- Initialize font
--
self.path = path or Font._path
self.glyphs = glyphs or Font._glyphs
self.w = w or Font._w
self.h = h or Font._h
self.k = k or Font._k
-- Configure font face
self.face = love.graphics.newImageFont(self.path, self.glyphs)
end
function Font:set()
--
-- Set the font
--
love.graphics.setFont(self.face)
end
return Font