-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathshaper_spec.lua
45 lines (40 loc) · 1.94 KB
/
shaper_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
SILE = require("core.sile")
SILE.input.backend = "debug"
SILE.init()
describe("SILE.shapers.base", function ()
it("should always have positive stretch and shrink", function ()
SILE.settings:set("shaper.variablespaces", true)
SILE.settings:set("shaper.spacestretchfactor", 2)
SILE.settings:set("shaper.spaceshrinkfactor", 2)
local negative_glue = SILE.types.node.glue("-4pt")
local space = SILE.shaper:makeSpaceNode({}, negative_glue)
assert.is.truthy(space.width.stretch > SILE.types.measurement(0))
assert.is.truthy(space.width.shrink > SILE.types.measurement(0))
end)
describe("measureChar", function ()
SILE.settings:set("font.family", "Libertinus Serif", true)
it("should measure simple characters", function ()
local measurements, found = SILE.shaper:measureChar("a")
assert.is.truthy(found)
assert.is.truthy(measurements.width > 0)
assert.is.truthy(measurements.height > 0)
end)
it("should measure multiple characters", function ()
local measurements, found = SILE.shaper:measureChar("ab")
assert.is.truthy(found)
assert.is.truthy(measurements.width > 0)
assert.is.truthy(measurements.height > 0)
-- Composite character should be taller than base character
assert.is.truthy(measurements.width > SILE.shaper:measureChar("a").width)
end)
-- TODO, we also need a test for composite characters, but I couldn't find one in our test fonts
-- it("should measure composite characters", function ()
-- local measurements, found = SILE.shaper:measureChar("â")
-- assert.is.truthy(found)
-- assert.is.truthy(measurements.width > 0)
-- assert.is.truthy(measurements.height > 0)
-- -- Composite character should be taller than base character
-- assert.is.truthy(measurements.height > SILE.shaper:measureChar("a").height)
-- end)
end)
end)