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

sile-typesetter / sile / 9324025270

31 May 2024 08:35PM UTC coverage: 66.168% (-8.0%) from 74.124%
9324025270

push

github

web-flow
Merge 235329972 into 70ff5c335

1753 of 2583 new or added lines in 108 files covered. (67.87%)

1498 existing lines in 74 files now uncovered.

11404 of 17235 relevant lines covered (66.17%)

2956.13 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 ()
×
7
   self:registerCommand("scalebox", function (options, content)
×
NEW
8
      if not SILE.outputter.scaleFn then
×
NEW
9
         SU.warn("Output will not be scaled: backend '" .. SILE.outputter._name .. "' does not support scaling")
×
UNCOV
10
         return SILE.process(content)
×
11
      end
12

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

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

29
      SILE.typesetter:pushHbox({
×
30
         width = W,
31
         height = H,
32
         depth = D,
33
         outputYourself = function (node, typesetter, line)
34
            local outputWidth = SU.rationWidth(node.width, node.width, line.ratio)
×
35
            local X = typesetter.frame.state.cursorX
×
36
            local Y = typesetter.frame.state.cursorY
×
37

38
            if xratio < 0 then
×
39
               typesetter.frame:advanceWritingDirection(-outputWidth)
×
40
            end
NEW
41
            SILE.outputter:scaleFn(X, Y, xratio, yratio, function ()
×
NEW
42
               hbox:outputYourself(typesetter, line)
×
43
            end)
44
            typesetter.frame.state.cursorX = X
×
45
            typesetter.frame.state.cursorY = Y
×
46
            typesetter.frame:advanceWritingDirection(outputWidth)
×
47
         end,
48
      })
49
      SILE.typesetter:pushHlist(hlist)
×
50
   end, "Scale content by some horizontal and vertical ratios")
×
51
end
52

53
package.documentation = [[
54
\begin{document}
55
The \autodoc:package{scalebox} package allows to scale any content by some horizontal
56
and vertical ratios, by issuing the command
57
\autodoc:command{\scalebox[xratio=<number>, yratio=<number>]{<content>}},
58
where the ratios are optional non-null numbers (defaulting to 1).
59
The content is placed in a box and scaled.
60

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

63
The previous line was produced by the following code:
64

65
\begin[type=autodoc:codeblock]{raw}
66
Here is an \scalebox[xratio=0.75, yratio=1.25]{example}.
67
\end{raw}
68
\end{document}
69
]]
×
70

71
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