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

sile-typesetter / sile / 5913811407

19 Aug 2023 10:21PM UTC coverage: 73.575% (-0.8%) from 74.334%
5913811407

push

github

web-flow
Merge pull request #1849 from alerque/docs-note-style

10 of 10 new or added lines in 2 files covered. (100.0%)

11591 of 15754 relevant lines covered (73.57%)

6930.04 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 ()
×
7

8
  local metrics = require("fontmetrics")
×
9

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

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

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

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