• 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/image/init.lua
UNCOV
1
local base = require("packages.base")
×
2

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

UNCOV
6
function package:registerCommands ()
×
UNCOV
7
   self:registerCommand("img", function (options, _)
×
UNCOV
8
      SU.required(options, "src", "including image file")
×
UNCOV
9
      local width = SU.cast("measurement", options.width or 0):tonumber()
×
UNCOV
10
      local height = SU.cast("measurement", options.height or 0):tonumber()
×
UNCOV
11
      local pageno = SU.cast("integer", options.page or 1)
×
UNCOV
12
      local src = SILE.resolveFile(options.src) or SU.error("Couldn't find file " .. options.src)
×
UNCOV
13
      local box_width, box_height, _, _ = SILE.outputter:getImageSize(src, pageno)
×
UNCOV
14
      local sx, sy = 1, 1
×
UNCOV
15
      if width > 0 and height > 0 then
×
16
         sx, sy = box_width / width, box_height / height
×
UNCOV
17
      elseif width > 0 then
×
UNCOV
18
         sx = box_width / width
×
UNCOV
19
         sy = sx
×
UNCOV
20
      elseif height > 0 then
×
UNCOV
21
         sy = box_height / height
×
UNCOV
22
         sx = sy
×
23
      end
24

UNCOV
25
      SILE.typesetter:pushHbox({
×
26
         width = box_width / sx,
27
         height = box_height / sy,
28
         depth = 0,
29
         value = src,
30
         outputYourself = function (node, typesetter, _)
UNCOV
31
            SILE.outputter:drawImage(
×
UNCOV
32
               node.value,
×
UNCOV
33
               typesetter.frame.state.cursorX,
×
UNCOV
34
               typesetter.frame.state.cursorY - node.height,
×
UNCOV
35
               node.width,
×
UNCOV
36
               node.height,
×
37
               pageno
38
            )
UNCOV
39
            typesetter.frame:advanceWritingDirection(node.width)
×
40
         end,
41
      })
UNCOV
42
   end, "Inserts the image specified with the <src> option in a box of size <width> by <height>")
×
43
end
44

45
package.documentation = [[
46
\begin{document}
47
Loading the \autodoc:package{image} package gives you the \autodoc:command{\img} command, fashioned after the HTML equivalent.
48
It takes the following parameters: \autodoc:parameter{src=<file>} must be the path to an image file; you may also give \autodoc:parameter{height} and/or \autodoc:parameter{width} parameters to specify the output size of the image on the paper.
49
If the size parameters are not given, then the image will be output at its “natural” size, honoring its resolution if available.
50
The command also supports a \autodoc:parameter{page=<number>} option, to specify the selected page in formats supporting
51
several pages (such as PDF).
52

53
\begin{autodoc:note}
54
With the libtexpdf backend (the default), the images can be in JPEG, PNG, EPS, or PDF formats.
55
\end{autodoc:note}
56

57
Here is a 200x243 pixel image output with \autodoc:command{\img[src=documentation/gutenberg.png]}.
58
The image has a claimed resolution of 100 pixels per inch, so ends up being two inches (144pt) wide on the page:\par
59
\img[src=documentation/gutenberg.png]
60

61
\raggedright{
62
Here it is with (respectively)
63
\autodoc:command{\img[src=documentation/gutenberg.png,width=120pt]},
64
\autodoc:command{\img[src=documentation/gutenberg.png,height=200pt]}, and
65
\autodoc:command{\img[src=documentation/gutenberg.png,width=120pt,height=200pt]}:}
66

67
\img[src=documentation/gutenberg.png,width=120pt]
68
\img[src=documentation/gutenberg.png,height=200pt]
69
\img[src=documentation/gutenberg.png,width=120pt,height=200pt]
70

71
Notice that images are typeset on the baseline of a line of text, rather like a very big letter.
72
\end{document}
UNCOV
73
]]
×
74

UNCOV
75
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