• 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
/outputters/debug.lua
1
local base = require("outputters.base")
×
2

3
local cursorX = 0
×
4
local cursorY = 0
×
5

6
local started = false
×
7

8
local lastFont
9
local outfile
10

NEW
11
local _round = SU.debug_round
×
12

13
local outputter = pl.class(base)
×
14
outputter._name = "debug"
×
15
outputter.extension = "debug"
×
16

17
-- The outputter init can't actually initialize output (as logical as it might
18
-- have seemed) because that requires a page size which we don't know yet.
19
-- function outputter:_init () end
20

21
function outputter:_ensureInit ()
×
22
  if not started then
×
23
    started = true -- keep this before self:_writeline or it will be a race condition!
×
24
    local fname = self:getOutputFilename()
×
25
    outfile = fname == "-" and io.stdout or io.open(fname, "w+")
×
26
    if SILE.documentState.paperSize then
×
27
      self:_writeline("Set paper size ", SILE.documentState.paperSize[1], SILE.documentState.paperSize[2])
×
28
    end
29
    self:_writeline("Begin page")
×
30
  end
31
end
32

33
function outputter:_writeline (...)
×
34
  self:_ensureInit()
×
35
  local args = pl.utils.pack(...)
×
36
  for i = 1, #args do
×
37
    outfile:write(args[i])
×
38
    if i < #args then outfile:write("\t") end
×
39
  end
40
  outfile:write("\n")
×
41
end
42

43
function outputter:newPage ()
×
44
  self:_writeline("New page")
×
45
end
46

47
function outputter:finish ()
×
48
  if SILE.status.unsupported then self:_writeline("UNSUPPORTED") end
×
49
  self:_writeline("End page")
×
NEW
50
  self:runHooks("prefinish")
×
51
  self:_writeline("Finish")
×
52
  outfile:close()
×
53
end
54

55
function outputter.getCursor (_)
×
56
  return cursorX, cursorY
×
57
end
58

59
function outputter:setCursor (x, y, relative)
×
60
  x = SU.cast("number", x)
×
61
  y = SU.cast("number", y)
×
62
  local oldx, oldy = self:getCursor()
×
63
  local offset = relative and { x = cursorX, y = cursorY } or { x = 0, y = 0 }
×
64
  cursorX = offset.x + x
×
65
  cursorY = offset.y - y
×
66
  if _round(oldx) ~= _round(cursorX) then self:_writeline("Mx ", _round(x)) end
×
67
  if _round(oldy) ~= _round(cursorY) then self:_writeline("My ", _round(y)) end
×
68
end
69

70
function outputter:setColor (color)
×
71
  if color.r then
×
NEW
72
    self:_writeline("Set color", tostring(color))
×
73
  elseif color.c then
×
NEW
74
    self:_writeline("Set color", tostring(color))
×
75
  elseif color.l then
×
NEW
76
    self:_writeline("Set color", tostring(color))
×
77
  end
78
end
79

80
function outputter:pushColor (color)
×
81
  if color.r then
×
NEW
82
    self:_writeline("Push color", tostring(color))
×
83
  elseif color.c then
×
NEW
84
    self:_writeline("Push color (CMYK)", tostring(color))
×
85
  elseif color.l then
×
NEW
86
    self:_writeline("Push color (grayscale)", tostring(color))
×
87
  end
88
end
89

90
function outputter:popColor ()
×
91
  self:_writeline("Pop color")
×
92
end
93

94
function outputter:drawHbox (value, width)
×
95
  if not value.glyphString then return end
×
96
  width = SU.cast("number", width)
×
97
  local buf
98
  if value.complex then
×
99
    local cluster = {}
×
100
    for i = 1, #value.items do
×
101
      local item = value.items[i]
×
102
      cluster[#cluster+1] = item.gid
×
103
      -- For the sake of terseness we're only dumping non-zero values
104
      if item.glyphAdvance ~= 0 then cluster[#cluster+1] = "a=".._round(item.glyphAdvance) end
×
105
      if item.x_offset then cluster[#cluster+1] = "x=".._round(item.x_offset) end
×
106
      if item.y_offset then cluster[#cluster+1] = "y=".._round(item.y_offset) end
×
107
      self:setCursor(item.width, 0, true)
×
108
    end
109
    buf = table.concat(cluster, " ")
×
110
  else
111
    buf = table.concat(value.glyphString, " ") .. " w=" .. _round(width)
×
112
  end
113
  self:_writeline("T", buf, "(" .. tostring(value.text) .. ")")
×
114
end
115

116
function outputter:setFont (options)
×
117
  local font = SILE.font._key(options)
×
118
  if lastFont ~= font then
×
119
    self:_writeline("Set font ", font)
×
120
    lastFont = font
×
121
  end
122
end
123

124
function outputter:drawImage (src, x, y, width, height)
×
125
  x = SU.cast("number", x)
×
126
  y = SU.cast("number", y)
×
127
  width = SU.cast("number", width)
×
128
  height = SU.cast("number", height)
×
129
  self:_writeline("Draw image", src, _round(x), _round(y), _round(width), _round(height))
×
130
end
131

132
function outputter.getImageSize (_, src, pageno)
×
133
  local pdf = require("justenoughlibtexpdf")
×
134
  local llx, lly, urx, ury, xresol, yresol = pdf.imagebbox(src, pageno)
×
135
  return (urx-llx), (ury-lly), xresol, yresol
×
136
end
137

138
function outputter:drawSVG (figure, _, x, y, width, height, scalefactor)
×
139
  x = SU.cast("number", x)
×
140
  y = SU.cast("number", y)
×
141
  width = SU.cast("number", width)
×
142
  height = SU.cast("number", height)
×
143
  self:_writeline("Draw SVG", _round(x), _round(y), _round(width), _round(height), figure, scalefactor)
×
144
end
145

146
function outputter:drawRule (x, y, width, depth)
×
147
  x = SU.cast("number", x)
×
148
  y = SU.cast("number", y)
×
149
  width = SU.cast("number", width)
×
150
  depth = SU.cast("number", depth)
×
151
  self:_writeline("Draw line", _round(x), _round(y), _round(width), _round(depth))
×
152
end
153

NEW
154
function outputter:setLinkAnchor (name, x, y)
×
NEW
155
  self:_writeline("Setting link anchor", name, x, y)
×
156
end
157

NEW
158
function outputter:beginLink (dest, opts)
×
NEW
159
   self:_writeline("Begining a link", dest, opts)
×
160
end
161

NEW
162
function outputter:endLink(dest, opts, x0, y0, x1, y1)
×
NEW
163
   self:_writeline("Ending a link", dest, opts, x0, y0, x1, y1)
×
164
end
165

NEW
166
function outputter:setBookmark (dest, title, level)
×
NEW
167
   self:_writeline("Setting bookmark", dest, title, level)
×
168
end
169

NEW
170
function outputter:setMetadata (key, value)
×
NEW
171
   self:_writeline("Set metadata", key, value)
×
172
end
173

NEW
174
function outputter:drawRaw (literal)
×
NEW
175
   self:_writeline("Draw raw", literal)
×
176
end
177

UNCOV
178
return outputter
×
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