forked from beyond-all-reason/Beyond-All-Reason
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbg_test_fallbackfonts.lua
66 lines (61 loc) · 1.63 KB
/
dbg_test_fallbackfonts.lua
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function widget:GetInfo()
return {
name = "Test fallback fonts",
desc = "testing for the fallback fonts",
author = "Saurtron",
date = "2024",
version = 41,
license = "GNU GPL, v2 or later",
layer = -4,
enabled = true,
}
end
local fenabled = false
-- to test color use the second fontfile here
local fontfile = 'fonts2/NotoEmoji-VariableFont_wght.ttf'
--local fontfile = 'fonts2/NotoColorEmoji.ttf'
function widget:Initialize()
if not gl.ClearFallbackFonts then
Spring.SendCommands("say not the right engine version!!")
Spring.Echo("Not the right engine version!")
widgetHandler:RemoveWidget()
end
end
function widget:MousePress(x, y, button)
if button == 1 then
if gl.ClearFallbackFonts then
if not fenabled then
fenabled = true
local res = gl.AddFallbackFont(fontfile)
if not res then
Spring.Echo("No fallback font")
end
res = gl.AddFallbackFont('fonts2/badfont.ttf')
if not res then
Spring.Echo("Bad fallback ok")
end
Spring.Echo("Fallback fonts", fenabled)
else
fenabled = false
gl.ClearFallbackFonts()
Spring.Echo("Fallback fonts", fenabled)
end
end
end
end
function widget:GameFrame(gf)
if gf == 3 then
Spring.SendCommands("say test")
Spring.SendCommands("say hello 🔥")
elseif gf == 150 then
gl.AddFallbackFont(fontfile)
elseif gf == 152 then
Spring.SendCommands("say fallbacks enabled")
Spring.SendCommands("say fallback 🔥")
elseif gf == 450 then
gl.ClearFallbackFonts()
elseif gf == 452 then
Spring.SendCommands("say fallbacks disabled")
Spring.SendCommands("say system 🔥")
end
end