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

sile-typesetter / sile / 11770252752

11 Nov 2024 01:09AM UTC coverage: 32.853% (-27.5%) from 60.402%
11770252752

Pull #2164

github

web-flow
chore(deps): Bump DeterminateSystems/nix-installer-action from 14 to 15

Bumps [DeterminateSystems/nix-installer-action](https://github.com/determinatesystems/nix-installer-action) from 14 to 15.
- [Release notes](https://github.com/determinatesystems/nix-installer-action/releases)
- [Commits](https://github.com/determinatesystems/nix-installer-action/compare/v14...v15)

---
updated-dependencies:
- dependency-name: DeterminateSystems/nix-installer-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #2164: chore(deps): Bump DeterminateSystems/nix-installer-action from 14 to 15

5855 of 17822 relevant lines covered (32.85%)

2493.73 hits per line

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

83.33
/shapers/base.lua
1
--- SILE shaper class.
2
-- @interfaces shapers
3

4
-- local smallTokenSize = 20 -- Small words will be cached
5
-- local shapeCache = {}
6
-- local _key = function (options)
7
--   return table.concat({ options.family;options.language;options.script;options.size;("%d"):format(options.weight);options.style;options.variant;options.features;options.variations;options.direction;options.filename }, ";")
8
-- end
9

10
SILE.settings:declare({ parameter = "shaper.variablespaces", type = "boolean", default = true })
4✔
11
SILE.settings:declare({ parameter = "shaper.spaceenlargementfactor", type = "number or integer", default = 1 })
4✔
12
SILE.settings:declare({ parameter = "shaper.spacestretchfactor", type = "number or integer", default = 1 / 2 })
4✔
13
SILE.settings:declare({ parameter = "shaper.spaceshrinkfactor", type = "number or integer", default = 1 / 3 })
4✔
14

15
SILE.settings:declare({
4✔
16
   parameter = "shaper.tracking",
17
   type = "number or nil",
18
   default = nil,
19
})
20

21
-- Function for testing shaping in the repl
22
-- luacheck: ignore makenodes
23
-- TODO, figure out a way to explicitly register things in the repl env
24
makenodes = function (token, options)
25
   return SILE.shaper:createNnodes(token, SILE.font.loadDefaults(options or {}))
×
26
end
27

28
local function shapespace (spacewidth)
29
   spacewidth = SU.cast("measurement", spacewidth)
648✔
30
   -- In some scripts with word-level kerning, glue can be negative.
31
   -- Use absolute value to ensure stretch and shrink work as expected.
32
   local absoluteSpaceWidth = math.abs(spacewidth:tonumber())
648✔
33
   local length = spacewidth * SILE.settings:get("shaper.spaceenlargementfactor")
648✔
34
   local stretch = absoluteSpaceWidth * SILE.settings:get("shaper.spacestretchfactor")
648✔
35
   local shrink = absoluteSpaceWidth * SILE.settings:get("shaper.spaceshrinkfactor")
648✔
36
   return SILE.types.length(length, stretch, shrink)
324✔
37
end
38

39
local shaper = pl.class()
4✔
40
shaper.type = "shaper"
4✔
41
shaper._name = "base"
4✔
42

43
-- Return the length of a space character
44
-- with a particular set of font options,
45
-- giving preference to document.spaceskip
46
-- Caching this has no significant speedup
47
function shaper:measureSpace (options)
4✔
48
   local ss = SILE.settings:get("document.spaceskip")
8✔
49
   if ss then
8✔
50
      SILE.settings:temporarily(function ()
16✔
51
         SILE.settings:set("font.size", options.size)
8✔
52
         SILE.settings:set("font.family", options.family)
8✔
53
         SILE.settings:set("font.filename", options.filename)
8✔
54
         ss = ss:absolute()
16✔
55
      end)
56
      return ss
8✔
57
   end
58
   local items, width = self:shapeToken(" ", options)
×
59
   if not width and not items[1] then
×
60
      SU.warn("Could not measure the width of a space")
×
61
      return SILE.types.length()
×
62
   end
63
   return shapespace(width and width.length or items[1].width)
×
64
end
65

66
function shaper:measureChar (char)
4✔
67
   local options = SILE.font.loadDefaults({})
15✔
68
   options.tracking = SILE.settings:get("shaper.tracking")
30✔
69
   local items = self:shapeToken(char, options)
15✔
70
   if #items > 0 then
15✔
71
      return { height = items[1].height, width = items[1].width, depth = items[1].depth }
15✔
72
   else
73
      SU.error("Unable to measure character", char)
×
74
   end
75
end
76

77
-- Given a text and some font options, return a bunch of boxes
78
function shaper.shapeToken (_, _, _)
4✔
79
   SU.error("Abstract function shapeToken called", true)
×
80
end
81

82
-- Given font options, select a font. We will handle
83
-- caching here. Returns an arbitrary, implementation-specific
84
-- object (ie a PAL for Pango, font number for libtexpdf, ...)
85
function shaper.getFace (_)
4✔
86
   SU.error("Abstract function getFace called", true)
×
87
end
88

89
function shaper.addShapedGlyphToNnodeValue (_, _, _)
4✔
90
   SU.error("Abstract function addShapedGlyphToNnodeValue called", true)
×
91
end
92

93
function shaper.preAddNodes (_, _, _) end
4✔
94

95
function shaper:createNnodes (token, options)
4✔
96
   options.tracking = SILE.settings:get("shaper.tracking")
1,588✔
97
   local items, _ = self:shapeToken(token, options)
794✔
98
   if #items < 1 then
794✔
99
      return {}
×
100
   end
101
   local lang = options.language
794✔
102
   SILE.languageSupport.loadLanguage(lang)
794✔
103
   local nodeMaker = SILE.nodeMakers[lang] or SILE.nodeMakers.unicode
794✔
104
   local nodes = {}
794✔
105
   for node in nodeMaker(options):iterator(items, token) do
3,874✔
106
      table.insert(nodes, node)
1,492✔
107
   end
108
   return nodes
794✔
109
end
110

111
function shaper:formNnode (contents, token, options)
4✔
112
   local nnodeContents = {}
1,150✔
113
   -- local glyphs = {}
114
   local totalWidth = 0
1,150✔
115
   local totalDepth = 0
1,150✔
116
   local totalHeight = 0
1,150✔
117
   -- local glyphNames = {}
118
   local nnodeValue = { text = token, options = options, glyphString = {} }
1,150✔
119
   SILE.shaper:preAddNodes(contents, nnodeValue)
1,150✔
120
   local misfit = false
1,150✔
121
   if SILE.typesetter.frame and SILE.typesetter.frame:writingDirection() == "TTB" then
2,300✔
122
      if options.direction == "LTR" then
×
123
         misfit = true
×
124
      end
125
   else
126
      if options.direction == "TTB" then
1,150✔
127
         misfit = true
×
128
      end
129
   end
130
   for i = 1, #contents do
4,397✔
131
      local glyph = contents[i]
3,247✔
132
      if (options.direction == "TTB") ~= misfit then
3,247✔
133
         if glyph.width > totalHeight then
×
134
            totalHeight = glyph.width
×
135
         end
136
         totalWidth = totalWidth + glyph.height
×
137
      else
138
         if glyph.depth > totalDepth then
3,247✔
139
            totalDepth = glyph.depth
836✔
140
         end
141
         if glyph.height > totalHeight then
3,247✔
142
            totalHeight = glyph.height
1,474✔
143
         end
144
         totalWidth = totalWidth + glyph.width
3,247✔
145
      end
146
      self:addShapedGlyphToNnodeValue(nnodeValue, glyph)
3,247✔
147
   end
148
   table.insert(
2,300✔
149
      nnodeContents,
1,150✔
150
      SILE.types.node.hbox({
2,300✔
151
         depth = totalDepth,
1,150✔
152
         height = totalHeight,
1,150✔
153
         misfit = misfit,
1,150✔
154
         width = SILE.types.length(totalWidth),
2,300✔
155
         value = nnodeValue,
1,150✔
156
      })
157
   )
158
   return SILE.types.node.nnode({
1,150✔
159
      nodes = nnodeContents,
1,150✔
160
      text = token,
1,150✔
161
      misfit = misfit,
1,150✔
162
      options = options,
1,150✔
163
      language = options.language,
1,150✔
164
   })
1,150✔
165
end
166

167
function shaper.makeSpaceNode (_, options, item)
4✔
168
   local width
169
   if SILE.settings:get("shaper.variablespaces") then
664✔
170
      width = shapespace(item.width)
648✔
171
   else
172
      width = SILE.shaper:measureSpace(options)
16✔
173
   end
174
   return SILE.types.node.glue(width)
332✔
175
end
176

177
function shaper.debugVersions (_) end
4✔
178

179
return shaper
4✔
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