-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathfontmanager_spec.lua
59 lines (52 loc) · 2.1 KB
/
fontmanager_spec.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
SILE = require("core.sile")
SILE.input.backend = "debug"
SILE.init()
-- These tests depend on loading specific fonts from our test fixtures. Running
-- plain `busted` is sometimes useful (e.g. for IDEs) but will not support this
-- test because fontconfig hasn't been preloaded with the font paths it would
-- need. If that's the case, just skip even defining these tests and call it
-- good. To test a complete set of tests use `make busted`.
local fcf = os.getenv("FONTCONFIG_FILE")
if not fcf then
return
end
describe("The fontconfig manager", function ()
SILE.input.fontmanager = "fontconfig"
it("should load a font", function ()
local family = "Libertinus Serif"
local face = SILE.shaper.getFace({ family = family })
assert.is.equal(family, face.family)
end)
-- Disable running this test unless we have font variation support. The test itself does not need the feature, but we
-- have *fonts* in the test data set that do and fontconfig is not deterministic about which fallback we might get
-- for an unknown font. In this case a font that needs variation support is being returned in some CI environments
-- when we request this unknown one.
if SILE.features.font_variations then
it("should fallback when it can't find a face", function ()
local family = "Yesteryear Imagination"
local face
assert.has_no.errors(function ()
face = SILE.shaper.getFace({ family = family })
end)
assert.is_not.equal(family, face.family)
end)
end
end)
describe("The macfonts manager", function ()
if not SILE.fontManager.macfonts then
return
end
it("should load a font", function ()
local family = "Libertinus Serif"
local face = SILE.shaper.getFace({ family = family })
assert.is.equal(family, face.family)
end)
it("should fallback to fontconfig when it fails", function ()
local family = "Yesteryear Imagination"
local face
assert.has_no.errors(function ()
face = SILE.shaper.getFace({ family = family })
end)
assert.is_not.equal(family, face.family)
end)
end)