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

sile-typesetter / sile / 8288578143

14 Mar 2024 09:39PM UTC coverage: 64.155% (-10.6%) from 74.718%
8288578143

Pull #1904

github

alerque
chore(core): Fixup ec6ed657 which didn't shim old pack styles properly
Pull Request #1904: Merge develop into master (commit to next release being breaking)

1648 of 2421 new or added lines in 107 files covered. (68.07%)

1843 existing lines in 77 files now uncovered.

10515 of 16390 relevant lines covered (64.15%)

3306.56 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

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

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

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

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

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

53
end
54

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

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

65
The previous line was produced by the following code:
66

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

73
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