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

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

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

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

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

6
function package:registerCommands ()
×
NEW
7
   self:registerCommand("scalebox", function (options, content)
×
NEW
8
      if SILE.outputter._name ~= "libtexpdf" then
×
NEW
9
         SU.warn("Output will not be scaled: \\scalebox only works with the libtexpdf backend")
×
NEW
10
         return SILE.process(content)
×
11
      end
NEW
12
      SILE.outputter:_ensureInit()
×
NEW
13
      local pdf = require("justenoughlibtexpdf")
×
14

NEW
15
      local hbox, hlist = SILE.typesetter:makeHbox(content)
×
NEW
16
      local xratio, yratio = SU.cast("number", options.xratio or 1), SU.cast("number", options.yratio or 1)
×
NEW
17
      if xratio == 0 or yratio == 0 then
×
NEW
18
         SU.error("Scaling ratio cannot be null")
×
19
      end
20

NEW
21
      local W = hbox.width * math.abs(xratio)
×
22
      local H, D
NEW
23
      if yratio > 0 then
×
NEW
24
         H = hbox.height * yratio
×
NEW
25
         D = hbox.depth * yratio
×
26
      else
NEW
27
         H = hbox.depth * -yratio
×
NEW
28
         D = hbox.height * -yratio
×
29
      end
30

NEW
31
      SILE.typesetter:pushHbox({
×
32
         width = W,
33
         height = H,
34
         depth = D,
35
         outputYourself = function (node, typesetter, line)
NEW
36
            local outputWidth = SU.rationWidth(node.width, node.width, line.ratio)
×
NEW
37
            local X = typesetter.frame.state.cursorX
×
NEW
38
            local Y = typesetter.frame.state.cursorY
×
NEW
39
            local x0 = X:tonumber()
×
NEW
40
            local y0 = -Y:tonumber()
×
41

NEW
42
            if xratio < 0 then
×
NEW
43
               typesetter.frame:advanceWritingDirection(-outputWidth)
×
44
            end
NEW
45
            pdf:gsave()
×
NEW
46
            pdf.setmatrix(1, 0, 0, 1, x0, y0)
×
NEW
47
            pdf.setmatrix(xratio, 0, 0, yratio, 0, 0)
×
NEW
48
            pdf.setmatrix(1, 0, 0, 1, -x0, -y0)
×
NEW
49
            hbox.outputYourself(hbox, typesetter, line)
×
NEW
50
            pdf:grestore()
×
NEW
51
            typesetter.frame.state.cursorX = X
×
NEW
52
            typesetter.frame.state.cursorY = Y
×
NEW
53
            typesetter.frame:advanceWritingDirection(outputWidth)
×
54
         end,
55
      })
NEW
56
      SILE.typesetter:pushHlist(hlist)
×
NEW
57
   end, "Scale content by some horizontal and vertical ratios")
×
58
end
59

60
package.documentation = [[
61
\begin{document}
62
The \autodoc:package{scalebox} package allows to scale any content by some horizontal
63
and vertical ratios, by issuing the command
64
\autodoc:command{\scalebox[xratio=<number>, yratio=<number>]{<content>}},
65
where the ratios are optional non-null numbers (defaulting to 1).
66
The content is placed in a box and scaled.
67

68
Here is an \scalebox[xratio=0.75, yratio=1.25]{example}.
69

70
The previous line was produced by the following code:
71

72
\begin[type=autodoc:codeblock]{raw}
73
Here is an \scalebox[xratio=0.75, yratio=1.25]{example}.
74
\end{raw}
75
\end{document}
76
]]
×
77

78
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