summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pangram/pangram.sty
blob: b52306b8ad3a4bbebb760162407324677bf14084 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
%%
%% This is file `pangram.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pangram.dtx  (with options: `package')
%% 
%%   Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>
%% 
%%   This work may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3c of this license or (at your option) any later
%%   version. The latest version of this license is in:
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%%   and version 1.3 or later is part of all distributions of
%%   LaTeX version 2005/12/01 or later.
%% 
%%   This work has the LPPL maintenance status `maintained'.
%% 
%%   The Current Maintainer of this work is Zhang Tingxuan.
%% 
%%   This work consists of the files pangram.dtx,
%%             and the derived files pangram.ins,
%%                                   pangram.sty,
%%                                   pangram.pdf,
%%                               and README.md.
%% 
\NeedsTeXFormat{LaTeX2e}[2022/06/01]
\ProvidesPackage{pangram}[2022/10/09 Pangram, a tool for testing fonts]
\ExplSyntaxOn
\clist_new:N \l_pangram_sizes_clist
\int_new:N \l_pangram_size_index
\clist_set:Nn \l_pangram_sizes_clist
  {
    5pt,  7pt,  8pt,  9pt, 10pt, 11pt,
   12pt, 14pt, 16pt, 18pt, 20pt, 22pt,
   24pt, 36pt, 48pt, 60pt, 72pt
  }
\tl_const:Nn \c_pangram_text_default_tl
  { The~quick~brown~fox~jumps~over~the~lazy~dog. ~ 0123456789 }
\tl_const:Nn \c_pangram_text_uppercase_tl
  { THE~QUICK~BROWN~FOX~JUMPS~OVER~THE~LAZY~DOG. ~ 0123456789 }
\tl_const:Nn \c_pangram_text_glass_tl
  { I~can~eat~glass~and~it~doesn't~hurt~me. }
\NewDocumentCommand \NewPangramClass { m m }
  {
    \exp_after:wN \tl_const:Nn \cs:w c_pangram_text_#1_tl \cs_end: { #2 }
  }
\NewDocumentCommand \pangram_resetsizes:n { m }
  {
    \IfBlankF {#1} { \clist_set:Nn \l_pangram_sizes_clist { #1 } }
  }
\keys_define:nn { pangram }
  {
    textclass.tl_set:N  = \l_pangram_textclass_tl ,
    textclass.default:n = default ,
    textclass.initial:n = default ,
    sizes.code:n        = \pangram_resetsizes:n { #1 } ,
    linegap.skip_set:N  = \l_pangram_linegap_skip ,
    linegap.default:n   = 5pt plus 3pt minus 2pt ,
    linegap.initial:n   = 5pt plus 3pt minus 2pt ,
    tagskip.skip_set:N  = \l_pangram_tagskip_skip ,
    tagskip.default:n   = 5pt ,
    tagskip.initial:n   = 5pt ,
    tagfont.tl_set:N    = \l_pangram_tagfont_tl ,
    tagfont.default:n   = \ttfamily \footnotesize ,
    tagfont.initial:n   = \ttfamily \footnotesize ,
    font.tl_set:N       = \l_pangram_font_tl ,
    before.tl_set:N     = \l_pangram_before_tl ,
    after.tl_set:N      = \l_pangram_after_tl ,
  }
\NewDocumentCommand \PangramSetup { m }
  { \keys_set:nn { pangram } { #1 } }
\NewDocumentCommand \pangram { +O{} }
  {
    \group_begin:
    \keys_set:nn { pangram } { #1 }
    \clearpage
    \skip_set:Nn \parskip { \c_zero_dim }
    \int_set:Nn \l_pangram_size_index { 0 }
    \tl_use:N \l_pangram_before_tl
    \int_do_while:nNnn
      { \l_pangram_size_index } < { \clist_count:N \l_pangram_sizes_clist }
      {
        \mode_leave_vertical:
        \int_incr:N \l_pangram_size_index % index++;
        \hbox_to_zero:n
          {
            \hss
            \tl_use:N \l_pangram_tagfont_tl
            \clist_item:Nn \l_pangram_sizes_clist { \l_pangram_size_index }
            \skip_horizontal:N \l_pangram_tagskip_skip
          }
        \hbox_to_zero:n
          {
            \tl_use:N \l_pangram_font_tl
            \fontsize
              { \clist_item:Nn \l_pangram_sizes_clist { \l_pangram_size_index } }
              { \c_zero_dim } % \z@
            \selectfont
            \tl_use:c { c_pangram_text_ \tl_use:N \l_pangram_textclass_tl _tl }
            \hss
          }
        \int_compare:nNnT
          { \l_pangram_size_index } = { \clist_count:N \l_pangram_sizes_clist }
          { \skip_set:Nn \l_pangram_linegap_skip {0pt} }
        \par
        \skip_vertical:N \l_pangram_linegap_skip
      }
    \tl_use:N \l_pangram_after_tl
    \clearpage
    \group_end:
  }
\ExplSyntaxOff
\endinput
%%
%% End of file `pangram.sty'.