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

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

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

0.0
/packages/specimen/init.lua
1
local base = require("packages.base")
×
2

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

6
function package:registerCommands ()
×
NEW
7
   local metrics = require("fontmetrics")
×
8

NEW
9
   self:registerCommand("repertoire", function (_, _)
×
NEW
10
      local ot = require("core.opentype-parser")
×
NEW
11
      local fontoptions = SILE.font.loadDefaults({})
×
NEW
12
      local face = SILE.font.cache(fontoptions, SILE.shaper.getFace)
×
NEW
13
      local font = ot.parseFont(face)
×
NEW
14
      local maxg = font.maxp.numGlyphs
×
NEW
15
      for i = 1, maxg - 1 do
×
NEW
16
         local wd = metrics.glyphwidth(i, face)
×
NEW
17
         SILE.typesetter:pushHbox({
×
18
            height = SILE.length(1.2 * fontoptions.size),
19
            width = SILE.length(wd * fontoptions.size),
20
            depth = 0,
21
            value = { options = fontoptions, glyphString = { i } },
22
         })
NEW
23
         SILE.typesetter:pushGlue(((1 - wd) * fontoptions.size) .. "pt plus 1pt minus 1pt")
×
24
      end
25
   end)
26

NEW
27
   self:registerCommand("pangrams", function (_, _)
×
NEW
28
      local pg = {
×
29
         "Sphinx of black quartz, judge my vow!",
30
         "The five boxing wizards jump quickly.",
31
         "Five quacking zephyrs jolt my wax bed.",
32
         "Pack my box with five dozen liquor jugs.",
33
         "Grumpy wizards make toxic brew for the evil queen and jack.",
34
         "Voix ambiguë d’un cœur qui au zéphyr préfère les jattes de kiwi.",
35
      }
NEW
36
      for i = 1, #pg do
×
NEW
37
         SILE.typesetter:typeset(pg[i] .. " ")
×
38
      end
NEW
39
      SILE.call("bigskip")
×
40
   end)
41

NEW
42
   self:registerCommand("set-to-width", function (options, content)
×
NEW
43
      local width = SU.required(options, "width", "set to width", "length"):absolute()
×
NEW
44
      local fontOptions = SILE.font.loadDefaults({})
×
NEW
45
      for line in SU.gtoke(content[1], "\n+") do
×
NEW
46
         if line.string then
×
NEW
47
            local tokens = SILE.shaper:shapeToken(line.string, fontOptions)
×
NEW
48
            local w = 0
×
NEW
49
            for j = 1, #tokens do
×
NEW
50
               w = w + tokens[j].width
×
51
            end
NEW
52
            local ratio = width.length / w
×
NEW
53
            SILE.call("noindent")
×
NEW
54
            SILE.call("font", { size = fontOptions.size * ratio }, function ()
×
NEW
55
               SILE.process({ line.string })
×
NEW
56
               SILE.call("par")
×
57
            end)
58
         end
59
      end
60
   end)
61
end
62

63
package.documentation = [[
64
\begin{document}
65
\use[module=packages.specimen]
66
SILE has found itself becoming well used by type designers, who often want to create specimen documents to show off their new fonts.
67
This package provides a few commands to help create test documents.
68
(The \autodoc:class{fontproof} class, available from the package manager, contains many more tools for creating specimens.)
69
The \autodoc:command{\repertoire} command prints out every glyph in the font, in a simple table.
70
The \autodoc:command{\pangrams} command prints out a few pangrams for the Latin script.
71
Finally, \autodoc:command{\set-to-width[width=<dimension>]{<content>}} will process each line of content, changing the font size so that the output is a constant width.
72

73
\begin[type=autodoc:codeblock]{raw}
74
\begin[width=4cm]{set-to-width}
75
CAPERCAILLIE
76
LAMMERGEYER
77
CASSOWARY
78
ACCENTOR DOWITCHER DOTTEREL
79
\end{set-to-width}
80
\end{raw}
81

82
\begin{autodoc:example}
83
\begin[width=4cm]{set-to-width}
84
CAPERCAILLIE
85
LAMMERGEYER
86
CASSOWARY
87
ACCENTOR DOWITCHER DOTTEREL
88
\end{set-to-width}
89
\end{autodoc:example}
90
\end{document}
91
]]
×
92

93
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