• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 9409557472

07 Jun 2024 12:09AM UTC coverage: 69.448% (-4.5%) from 73.988%
9409557472

push

github

alerque
fix(build): Distribute vendored compat-5.3.c source file

12025 of 17315 relevant lines covered (69.45%)

6023.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/packages/hanmenkyoshi/init.lua
1
local base = require("packages.base")
2✔
2

3
local package = pl.class(base)
2✔
4
package._name = "hanmenkyoshi"
2✔
5

6
local showHanmenYoko = function (frame)
7
   local g = frame:top()
×
8
   while g < frame:bottom() do
×
9
      SILE.outputter:drawRule(frame:left(), g - 0.25, frame:width(), 0.5)
×
10
      local l = frame:left()
×
11
      while l <= frame:right() do
×
12
         SILE.outputter:drawRule(l - 0.25, g + frame.hanmen.gridsize - 0.25, 0.5, -frame.hanmen.gridsize)
×
13
         l = l + frame.hanmen.gridsize
×
14
      end
15
      g = g + frame.hanmen.gridsize
×
16
      SILE.outputter:drawRule(frame:left(), g - 0.25, frame:width(), 0.5)
×
17
      g = g + frame.hanmen.linegap
×
18
   end
19
end
20

21
local showHanmenTate = function (frame)
22
   local g = frame:right()
×
23
   while g > frame:left() do
×
24
      SILE.outputter:drawRule(g - 0.25, frame:top(), 0.5, -frame:height())
×
25
      local l = frame:top()
×
26
      while l < frame:bottom() do
×
27
         SILE.outputter:drawRule(g - frame.hanmen.gridsize - 0.25, l - 0.25, frame.hanmen.gridsize, 0.5)
×
28
         l = l + frame.hanmen.gridsize
×
29
      end
30
      g = g - frame.hanmen.gridsize
×
31
      SILE.outputter:drawRule(g - 0.25, frame:top(), 0.5, -frame:height())
×
32
      g = g - frame.hanmen.linegap
×
33
   end
34
end
35

36
-- Warning: this function has side affects and if a real frame is
37
-- passed as a spec it will be modified in addition to a frame
38
-- being instantiated in the class page template.
39
local declareHanmenFrame = function (class, id, spec)
40
   if spec then
2✔
41
      spec.id = id
2✔
42
   else
43
      spec = id
×
44
   end
45
   spec.hanmen = {
2✔
46
      gridsize = SU.required(spec, "gridsize", "declaring the kihonhanmen", "measurement"),
4✔
47
      linegap = SU.required(spec, "linegap", "declaring the kihonhanmen", "measurement"),
4✔
48
      linelength = SU.required(spec, "linelength", "declaring the kihonhanmen", "measurement"),
4✔
49
      linecount = SU.required(spec, "linecount", "declaring the kihonhanmen"),
4✔
50
   }
2✔
51
   if spec.tate then
2✔
52
      spec.height = spec.hanmen.gridsize * spec.hanmen.linelength
2✔
53
      spec.width = spec.hanmen.gridsize * spec.hanmen.linecount + spec.hanmen.linegap * (spec.hanmen.linecount - 1)
4✔
54
   else
55
      spec.width = spec.hanmen.gridsize * spec.hanmen.linelength
2✔
56
      spec.height = spec.hanmen.gridsize * spec.hanmen.linecount + spec.hanmen.linegap * (spec.hanmen.linecount - 1)
4✔
57
   end
58
   local skip = spec.hanmen.linegap + spec.hanmen.gridsize
2✔
59
   SILE.settings:set("document.baselineskip", SILE.types.node.vglue(skip))
4✔
60
   SILE.settings:set("document.parskip", SILE.types.node.vglue())
4✔
61
   local frame = SILE.newFrame(spec, spec.tate and SILE.tateFramePrototype or SILE.framePrototype)
2✔
62
   if spec.id then
2✔
63
      class.pageTemplate.frames[spec.id] = frame
2✔
64
   end
65
end
66

67
function package:_init ()
2✔
68
   base._init(self)
2✔
69
   self:loadPackage("tate")
2✔
70
   self:export("declareHanmenFrame", declareHanmenFrame)
2✔
71
end
72

73
function package:registerCommands ()
2✔
74
   self:registerCommand("show-hanmen", function (_, _)
4✔
75
      local frame = SILE.typesetter.frame
×
76
      if not frame.hanmen then
×
77
         SU.error("show-hanmen called on a frame with no hanmen")
×
78
      end
79
      local color = SILE.types.color({ r = 1, g = 0.9, b = 0.9 })
×
80
      SILE.outputter:pushColor(color)
×
81
      if frame:writingDirection() == "TTB" then
×
82
         showHanmenTate(frame)
×
83
      else
84
         showHanmenYoko(frame)
×
85
      end
86
      SILE.outputter:popColor()
×
87
   end)
88
end
89

90
package.documentation = [[
91
\begin{document}
92
Japanese documents are traditionally typeset on a grid layout called a \em{hanmen}, with each character essentially monospaced inside the grid (like writing on graph paper).
93
The \autodoc:package{hanmenkyoshi} package provides tools to Japanese class designers for creating \em{hanmen} frames with correctly spaced grids.
94
It also provides the \autodoc:command{\show-hanmen} command for debugging the grid.
95

96
The name \em{hanmenkyoshi} is a terrible pun.
97
\end{document}
98
]]
2✔
99

100
return package
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc