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

sile-typesetter / sile / 9507147410

13 Jun 2024 09:40PM UTC coverage: 50.521% (-18.7%) from 69.177%
9507147410

push

github

web-flow
Merge pull request #2062 from alerque/plug-fluent-leak

Link document.language setting more closely with Fluent locale

15 of 15 new or added lines in 3 files covered. (100.0%)

3244 existing lines in 65 files now uncovered.

8586 of 16995 relevant lines covered (50.52%)

4659.09 hits per line

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

0.0
/packages/tate/init.lua
UNCOV
1
local base = require("packages.base")
×
2

UNCOV
3
local package = pl.class(base)
×
UNCOV
4
package._name = "tate"
×
5

UNCOV
6
SILE.tateFramePrototype = pl.class(SILE.framePrototype)
×
UNCOV
7
SILE.tateFramePrototype.direction = "TTB-RTL"
×
8

UNCOV
9
SILE.tateFramePrototype.enterHooks = {
×
10
   function (_, typesetter)
UNCOV
11
      SILE.typesetters.tate:cast(typesetter)
×
12
   end,
13
}
14

UNCOV
15
SILE.tateFramePrototype.leaveHooks = {
×
16
   function (_, typesetter)
UNCOV
17
      SILE.typesetters.base:cast(typesetter)
×
18
   end,
19
}
20

21
SILE.newTateFrame = function (spec)
22
   return SILE.newFrame(spec, SILE.tateFramePrototype)
×
23
end
24

25
local outputLatinInTate = function (self, typesetter, line)
26
   -- My baseline moved
27
   typesetter.frame:advanceWritingDirection(SILE.types.measurement("-0.5zw"))
×
28
   typesetter.frame:advancePageDirection(SILE.types.measurement("0.25zw"))
×
29

30
   local vorigin = -typesetter.frame.state.cursorY
×
31
   self:oldOutputYourself(typesetter, line)
×
32
   typesetter.frame.state.cursorY = -vorigin
×
33
   typesetter.frame:advanceWritingDirection(self:lineContribution())
×
34
   -- My baseline moved
35
   typesetter.frame:advanceWritingDirection(SILE.types.measurement("0.5zw"))
×
36
   typesetter.frame:advancePageDirection(-SILE.types.measurement("0.25zw"))
×
37
end
38

39
local outputTateChuYoko = function (self, typesetter, line)
40
   -- My baseline moved
41
   local em = SILE.types.measurement("1zw")
×
42
   typesetter.frame:advanceWritingDirection(-em + em / 4 - self:lineContribution() / 2)
×
43
   typesetter.frame:advancePageDirection(2 * self.height - self.width / 2)
×
44
   self:oldOutputYourself(typesetter, line)
×
45
   typesetter.frame:advanceWritingDirection(-self:lineContribution() * 1.5 + self.height * 3 / 4)
×
46
end
47

UNCOV
48
function package:registerCommands ()
×
UNCOV
49
   self:registerCommand("tate-frame", function (options, _)
×
50
      SILE.documentState.thisPageTemplate.frames[options.id] = SILE.newTateFrame(options)
×
UNCOV
51
   end, "Declares (or re-declares) a frame on this page.")
×
52

53
   -- Eventually will be automatically called by script detection, but for now
54
   -- called manually
UNCOV
55
   self:registerCommand("latin-in-tate", function (_, content)
×
56
      if SILE.typesetter.frame:writingDirection() ~= "TTB" then
×
57
         return SILE.process(content)
×
58
      end
59
      local nodes
60
      local oldT = SILE.typesetter
×
61
      local prevDirection = oldT.frame.direction
×
62
      self:loadPackage("rotate")
×
63
      SILE.settings:temporarily(function ()
×
64
         local latinTypesetter = pl.class(SILE.typesetters.base)
×
65
         local dummyFrame = pl.class(SILE.framePrototype)
×
66
         dummyFrame.init = function (f)
67
            f.state = {}
×
68
         end
69
         latinTypesetter.initFrame = function (typesetter, frame)
70
            typesetter.frame = frame
×
71
         end
72
         local frame = dummyFrame({}, true)
×
73
         SILE.typesetter = latinTypesetter(frame)
×
74
         SILE.settings:set("document.language", "und")
×
75
         SILE.settings:set("font.direction", "LTR")
×
76
         SILE.process(content)
×
77
         nodes = SILE.typesetter.state.nodes
×
78
         SILE.typesetter:shapeAllNodes(nodes)
×
79
         SILE.typesetter.frame.direction = prevDirection
×
80
      end)
81
      SILE.typesetter = oldT
×
82
      SILE.typesetter:pushGlue({
×
83
         width = SILE.types.length("0.5zw", "0.25zw", "0.25zw"):absolute(),
84
      })
85
      for i = 1, #nodes do
×
86
         if SILE.typesetter.frame:writingDirection() ~= "TTB" or nodes[i].is_glue then
×
87
            SILE.typesetter:pushHorizontal(nodes[i])
×
88
         elseif nodes[i]:lineContribution():tonumber() > 0 then
×
89
            local hbox = SILE.call("hbox", {}, function ()
×
90
               SILE.typesetter:pushHorizontal(nodes[i])
×
91
            end)
92
            -- Turn off all complex flags.
93
            for j = 1, #hbox.value do
×
94
               for k = 1, #hbox.value[j].nodes do
×
95
                  hbox.value[j].nodes[k].value.complex = false
×
96
               end
97
            end
98
            hbox.oldOutputYourself = hbox.outputYourself
×
99
            hbox.outputYourself = outputLatinInTate
×
100
         end
101
      end
UNCOV
102
   end, "Typeset rotated Western text in vertical Japanese")
×
103

UNCOV
104
   self:registerCommand("tate-chu-yoko", function (_, content)
×
105
      if SILE.typesetter.frame:writingDirection() ~= "TTB" then
×
106
         return SILE.process(content)
×
107
      end
108
      -- SILE.typesetter:pushGlue({
109
      --   width = SILE.types.length.new({length = SILE.toPoints("0.5zw"),
110
      --                            stretch = SILE.toPoints("0.25zw"),
111
      --                             shrink = SILE.toPoints("0.25zw")
112
      --                           })
113
      -- })
114
      SILE.settings:temporarily(function ()
×
115
         SILE.settings:set("document.language", "und")
×
116
         SILE.settings:set("font.direction", "LTR")
×
117
         SILE.call("rotate", { angle = -90 }, function ()
×
118
            local hbox = SILE.call("hbox", {}, content)
×
119
            hbox.misfit = true
×
120
            hbox.oldOutputYourself = hbox.outputYourself
×
121
            hbox.outputYourself = outputTateChuYoko
×
122
         end)
123
      end)
124
      -- SILE.typesetter:pushGlue({
125
      --   width = SILE.types.length.new({length = SILE.toPoints("0.5zw"),
126
      --                            stretch = SILE.toPoints("0.25zw"),
127
      --                             shrink = SILE.toPoints("0.25zw")
128
      --                           })
129
      -- })
130
   end)
131
end
132

133
package.documentation = [[
134
\begin{document}
135
The \autodoc:package{tate} package provides support for Japanese vertical typesetting.
136
It allows for the definition of vertical-oriented frames, as well as for two specific typesetting techniques required in vertical documents: \autodoc:command{\latin-in-tate} typesets its content as Latin text rotated 90 degrees, and \autodoc:command{\tate-chu-yoko} places (Latin) text horizontally within a single grid-square of the vertical \em{hanmen}.
137
\end{document}
UNCOV
138
]]
×
139

UNCOV
140
return package
×
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

© 2026 Coveralls, Inc