-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathpecha.lua
81 lines (72 loc) · 2.11 KB
/
pecha.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--- tbook document class.
-- @use classes.tbook
local plain = require("classes.plain")
local class = pl.class(plain)
class._name = "pecha"
local tibetanNumber = function (n)
local out = ""
local a = 0x0f20
repeat
out = luautf8.char(n % 10 + a) .. out
n = (n - n % 10) / 10
until n < 1
return out
end
class.defaultFrameset = {
content = {
left = "5%pw",
right = "95%pw",
top = "5%ph",
bottom = "90%ph",
},
folio = {
left = "right(content)",
rotate = -90,
width = "2.5%pw",
top = "top(content)",
height = "height(content)",
},
runningHead = {
width = "2.5%pw",
rotate = -90,
right = "left(content)",
top = "top(content)",
height = "height(content)",
},
}
function class:_init (options)
plain._init(self, options)
self:loadPackage("rotate")
self:registerPostinit(function ()
SILE.call("language", { main = "bo" })
SILE.settings:set("document.lskip", SILE.types.node.hfillglue())
SILE.settings:set("typesetter.parfillskip", SILE.types.node.glue())
SILE.settings:set("document.parindent", SILE.types.node.glue())
end)
end
function class:endPage ()
local folioframe = SILE.getFrame("folio")
SILE.typesetNaturally(folioframe, function ()
SILE.settings:pushState()
-- Restore the settings to the top of the queue, which should be the document #986
SILE.settings:toplevelState()
SILE.settings:set("typesetter.breakwidth", folioframe:height())
SILE.typesetter:typeset(" ")
SILE.call("vfill")
SILE.call("pecha-folio-font")
SILE.call("center", {}, function ()
SILE.typesetter:typeset(tibetanNumber(SILE.scratch.counters.folio.value))
end)
SILE.call("vfill")
SILE.typesetter:leaveHmode()
SILE.settings:popState()
end)
return plain.endPage(self)
end
function class:newPage ()
SILE.outputter:newPage()
SILE.outputter:debugFrame(SILE.getFrame("content"))
return self:initialFrame()
end
return class
-- \right-running-head{\font[size=15pt]{\center{ཤེས་རབ་སྙིང་པོ་ }}}