Debian Codegraph @

texmf-dist/source/latex/pangram/pangram.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2022--2023 by Zhang Tingxuan <[email protected]>
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.3c of this license or (at your option) any later
8 % version. The latest version of this license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3 or later is part of all distributions of
13 % LaTeX version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status `maintained'.
16 %
17 % The Current Maintainer of this work is Zhang Tingxuan.
18 %
19 % This work consists of the files pangram.dtx,
20 % and the derived files pangram.ins,
21 % pangram.sty,
22 % pangram.pdf,
23 % and README.md.
24 %
25 %<*internal>
26 \iffalse
27 %</internal>
28 %
29 %<*readme>
30 # The `pangram` Package
31
32 The `pangram` package aims to provide an easy way for testing fonts.
33
34 See `pangram.pdf` for more. Happy TeXing!
35
36 ## License
37
38 This work may be distributed and/or modified under the conditions of
39 the [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
40 either version 1.3c of this license or (at your option) any later version.
41
42 ------
43
44 Copyright (C) 2022--2023 by Zhang Tingxuan <[email protected]>.
45 %</readme>
46 %
47 %<*internal>
48 \fi
49 \begingroup
50 \def\NameOfLaTeXe{LaTeX2e}
51 \expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
52 \csname fi\endcsname
53 %</internal>
54 %
55 %<*install>
56 \input docstrip.tex
57 \keepsilent
58
59 \preamble
60
61 Copyright (C) 2022--2023 by Zhang Tingxuan <[email protected]>
62
63 This work may be distributed and/or modified under the
64 conditions of the LaTeX Project Public License, either
65 version 1.3c of this license or (at your option) any later
66 version. The latest version of this license is in:
67
68 http://www.latex-project.org/lppl.txt
69
70 and version 1.3 or later is part of all distributions of
71 LaTeX version 2005/12/01 or later.
72
73 This work has the LPPL maintenance status `maintained'.
74
75 The Current Maintainer of this work is Zhang Tingxuan.
76
77 This work consists of the files pangram.dtx,
78 and the derived files pangram.ins,
79 pangram.sty,
80 pangram.pdf,
81 and README.md.
82
83 \endpreamble
84
85 \generate{
86 \usedir{tex/latex/pangram}
87 \file{\jobname.sty} {\from{\jobname.dtx}{package}}
88 %</install>
89 %<*internal>
90 \usedir{source/latex/pangram}
91 \file{\jobname.ins} {\from{\jobname.dtx}{install}}
92 %</internal>
93 %<*install>
94 \usedir{doc/latex/pangram}
95 \nopreamble\nopostamble
96 \file{README.md} {\from{\jobname.dtx}{readme}}
97 }
98
99 \obeyspaces
100 \Msg{****************************************************}
101 \Msg{* *}
102 \Msg{* To finish the installation you have to move the *}
103 \Msg{* following file into a directory searched by TeX: *}
104 \Msg{* *}
105 \Msg{* pangram.sty *}
106 \Msg{* *}
107 \Msg{* The recommended directory is *}
108 \Msg{* TDS:tex/latex/pangram *}
109 \Msg{* *}
110 \Msg{* To produce the documentation run the file *}
111 \Msg{* pangram.dtx through XeLaTeX/LuaLaTeX. *}
112 \Msg{* XeLaTeX and LuaLaTeX are recommended if you *}
113 \Msg{* hope the PDF file to be smaller. *}
114 \Msg{* *}
115 \Msg{* Happy TeXing! *}
116 \Msg{* *}
117 \Msg{****************************************************}
118
119 \endbatchfile
120 %</install>
121 %
122 %<*internal>
123 \fi
124 %</internal>
125 %
126 %<*driver>
127 \ProvidesFile{pangram.dtx}[2023/03/01 (c) Copyright 2022--2023 by Zhang Tingxuan]
128 \documentclass{l3doc}
129
130 \usepackage[letterpaper,left=5cm,right=4cm,top=4cm,bottom=4cm,
131 includeheadfoot]{geometry}
132
133 \usepackage{xcolor}
134 \definecolor{titlecolor}{RGB}{0,12,160}
135 \usepackage{doc}
136 \usepackage{fancyvrb}
137 \fvset{xleftmargin=2.5em,fontsize=\small,gobble=2}
138 \MakeShortVerb|
139
140 \usepackage{hologo}
141 \def\XeTeX{\hologo{XeTeX}}
142 \def\LuaTeX{\hologo{LuaTeX}}
143
144 \def\pkg{\textsf}
145 \def\opt{\texttt}
146
147 \title{\leavevmode\hbox to 0pt{\hss\huge The quick brown fox jumps over the lazy dog\hss}\\
148 --- The \pkg{pangram} package}
149 \author{Zhang Tingxuan}
150 \long\date{2023/03/01\quad Version 0.0c\thanks{\url{https://github.com/AlphaZTX/pangram}
151 If you want to maintain this package, just contact me through GitHub issues or pull a
152 request.}}
153
154 \usepackage{hyperref}
155 \hypersetup{
156 pdftitle = {The pangram Package},
157 pdfauthor = {Zhang Tingxuan},
158 pdfcreator = {XeLaTeX/LuaLaTeX},
159 linkcolor = black,
160 urlcolor = titlecolor!80!black,
161 }
162 \def\pkg{\textsf}
163
164 \makeatletter
165 \renewcommand\section{\@startsection{section}{1}{\z@}%
166 {-2.5ex plus -1ex minus -.2ex}%
167 {1ex plus .2ex}%
168 {\normalfont\Large\bfseries\color{titlecolor}}}
169 \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
170 {-2ex plus -1ex minus -.2ex}%
171 {.5ex plus .2ex}%
172 {\normalfont\normalsize\bfseries\color{titlecolor}}}
173 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
174 {.8ex plus .4ex minus .2ex}%
175 {-1em}%
176 {\normalfont\normalsize\bfseries\color{titlecolor}}}
177 \makeatother
178 \usepackage{fontspec}
179 \setmainfont{Latin Modern Roman}
180 \setsansfont{Latin Modern Sans}
181 \setmonofont{Latin Modern Mono}
182 \usepackage{ragged2e}
183 \usepackage{pangram}
184
185 \linespread{1.05}
186 \parskip12pt plus 3pt minus 2pt
187 \parindent2.5em
188 \RaggedRight
189
190 \begin{document}
191 \DocInput{\jobname.dtx}
192 \end{document}
193 %</driver>
194 % \fi
195 %
196 %
197 % \maketitle
198 %
199 % \begin{abstract}
200 % Pangram is a phrase or sentence containing all letters in an alphabet,
201 % usually used for testing fonts. One famous pangram is ``The quick brown
202 % fox jumps over the lazy dog''. This package provides a (somewhat) simple
203 % way for font designers or users to test fonts.
204 % \end{abstract}
205 %
206 % \tableofcontents
207 %
208 % \newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
209 % \pangram[
210 % sizes = { 5pt, 6pt, 7pt, 8pt, 9pt,
211 % 10pt, 11pt, 12pt, 14pt, 16pt,
212 % 18pt, 20pt, 22pt, 24pt, 30pt,
213 % 36pt, 40pt, 44pt, 48pt, 64pt,
214 % 72pt, 96pt},
215 % linegap = 0pt plus 1fil,
216 % tagfont = \ttfamily\footnotesize\color{gray},
217 % font = \fontspec{Latin Modern Roman},
218 % after = \thispagestyle{empty},
219 % ]
220 % \restoregeometry
221 %
222 % \section{How to use this package}
223 % To load the package, just write
224 % \begin{Verbatim}
225 % \usepackage{pangram}
226 % \end{Verbatim}
227 % in preamble.
228 %
229 % Then in your document, write
230 % \begin{Verbatim}
231 % \pangram
232 % \end{Verbatim}
233 % to get the result like the previous page.
234 %
235 % Please notice that \cs{pangram} will stay in a seperate page.
236 %
237 % \section{Options}
238 % The \cs{pangram} command can receive an optional key-val list
239 % specifying the details of the pangram page. Here are the keys:
240 % \begin{itemize}
241 % \item \opt{textclass} stands for the pangram text in pangram page.
242 % The default value is \opt{default}, yields ``The quick brown fox
243 % jumps over the lazy dog. 0123456789''. \opt{uppercase} and \opt{glass}
244 % are also available, which yields ``THE QUICK BROWN FOX JUMPS OVER THE
245 % LAZY DOG. 0123456789'' and ``I can eat glass and it doesn't hurt me.''
246 % (although the latter one cannot be regarded as pangram).
247 %
248 % \item \opt{sizes} for the sizes shown in \cs{pangram}. Default value is
249 % \texttt{\{5pt, 7pt, 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 16pt, 18pt, 20pt,
250 % 22pt, 24pt, 36pt, 48pt, 60pt, 72pt\}}.
251 %
252 % \item \opt{linegap} is the line skip between two lines in \cs{pangram}.
253 % Default value is \opt{5pt plus 3pt minus 2pt}.
254 %
255 % \item \opt{tagskip} is the skip between the tag and the pangram text.
256 % Default value is \opt{5pt}.
257 %
258 % \item \opt{tagfont} sets the font of tag. Default value is
259 % |\ttfamily\footnotesize|.
260 %
261 % \item \opt{font} sets the font of pangram text. Default value is empty.
262 %
263 % \item \opt{before} stands for the content before pangram text in pangram page.
264 % Default value is empty.
265 %
266 % \item \opt{after} stands for the content after pangram text in pangram page.
267 % Default value is empty.
268 % \end{itemize}
269 % If you want to set the keys globally, use \cs{PangramSetup} in your preamble,
270 % the argument of \cs{PangramSetup} is the same as the one of \cs{pangram}.
271 %
272 % Attention! If any of the value to the keys contains an ``\opt{=}'' symbol,
273 % the value should be put into a group. For example,
274 % \begin{Verbatim}
275 % \pangram[ font={\fontspec{Latin Modern Roman}[Mapping=tex-text]} ]
276 % \end{Verbatim}
277 %
278 % \section{New pangram text classes}
279 % Besides the three pre-defined pangram text classes, you can define your own
280 % pangram text classes through \cs{NewPangramClass}:
281 %
282 % \cs{NewPangramClass}\marg{text class}\marg{text}
283 %
284 % \section{A complicated example}
285 % Set the package globally (used in preamble):
286 % \begin{Verbatim}
287 % \PangramSetup{
288 % sizes={9bp,10bp,12bp,20bp,36bp,44bp,48bp,64bp},
289 % tagfont=\color{gray}\ttfamily\footnotesize,
290 % }
291 % \NewPangramClass{abc}{abcdefghijklmnopqrstuvwxyz}
292 % \end{Verbatim}
293 %
294 % Get the result locally (Needs \pkg{fontspec} package and any package provides
295 % \cs{color} command):
296 % \begin{Verbatim}
297 % \pangram[font=\fontspec{Latin Modern Roman}]
298 % \pangram[textclass=glass,
299 % font={\fontspec{Latin Modern Sans}[Mapping=tex-text]}]
300 % \pangram[textclass=abc,font=\fontspec{Latin Modern Mono}]
301 % \end{Verbatim}
302 % The text class \opt{abc} here is defined in the previous paragraph.
303 %
304 % \section{The source code}
305 % \begin{macrocode}
306 %<*package>
307 %<@@=pangram>
308 \NeedsTeXFormat{LaTeX2e}[2022/06/01]
309 \ProvidesExplPackage{pangram}{2023/03/01}{0.0c}{a tool for testing fonts}
310 % \end{macrocode}
311 % Use a \opt{clist} to restore the sizes for \cs{pangram},
312 % and an integer for its index.
313 % \begin{macrocode}
314 \clist_new:N \l_@@_sizes_clist
315 \int_new:N \l_@@_size_index_int
316 \clist_set:Nn \l_@@_sizes_clist
317 {
318 5pt, 7pt, 8pt, 9pt, 10pt, 11pt,
319 12pt, 14pt, 16pt, 18pt, 20pt, 22pt,
320 24pt, 36pt, 48pt, 60pt, 72pt
321 }
322 % \end{macrocode}
323 % Three pre-defined text classes (token lists) for \cs{pangram}.
324 % \begin{macrocode}
325 \tl_const:Nn \c_@@_text_default_tl
326 { The ~ quick ~ brown ~ fox ~ jumps ~ over ~ the ~ lazy ~ dog. ~ 0123456789 }
327 \tl_const:Nn \c_@@_text_uppercase_tl
328 { THE ~ QUICK ~ BROWN ~ FOX ~ JUMPS ~ OVER ~ THE ~ LAZY ~ DOG. ~ 0123456789 }
329 \tl_const:Nn \c_@@_text_glass_tl
330 { I ~ can ~ eat ~ glass ~ and ~ it ~ doesn't ~ hurt ~ me. }
331 % \end{macrocode}
332 % \DescribeMacro{\NewPangramClass}
333 % Use way equivalent to \cs{csname}\dots\cs{endcsname} to define
334 % new text classes.
335 % \begin{macrocode}
336 \NewDocumentCommand \NewPangramClass { m +m }
337 {
338 \tl_const:cn { c_@@_text_#1_tl } { #2 }
339 }
340 % \end{macrocode}
341 % Inner function for \opt{sizes} option. Here use the \pkg{xparse}'s new
342 % \cs{IfBlankTF} mechanism to judge if the sizes should be reset.
343 % \begin{macrocode}
344 \cs_new:Npn \@@_resetsizes:n #1
345 {
346 \tl_if_blank:nF { #1 }
347 {
348 \clist_set:Nn \l_@@_sizes_clist { #1 }
349 }
350 }
351 % \end{macrocode}
352 % The keys.
353 % \begin{macrocode}
354 \keys_define:nn { pangram }
355 {
356 textclass.tl_set:N = \l_@@_textclass_tl ,
357 textclass.default:n = default ,
358 textclass.initial:n = default ,
359 sizes.code:n = \@@_resetsizes:n { #1 } ,
360 linegap.skip_set:N = \l_@@_linegap_skip ,
361 linegap.default:n = 5pt plus 3pt minus 2pt ,
362 linegap.initial:n = 5pt plus 3pt minus 2pt ,
363 tagskip.skip_set:N = \l_@@_tagskip_skip ,
364 tagskip.default:n = 5pt ,
365 tagskip.initial:n = 5pt ,
366 tagfont.tl_set:N = \l_@@_tagfont_tl ,
367 tagfont.default:n = \ttfamily \footnotesize ,
368 tagfont.initial:n = \ttfamily \footnotesize ,
369 font.tl_set:N = \l_@@_font_tl ,
370 before.tl_set:N = \l_@@_before_tl ,
371 after.tl_set:N = \l_@@_after_tl ,
372 }
373 % \end{macrocode}
374 % \DescribeMacro{\PangramSetup}
375 % Set up the package in preamble.
376 % \begin{macrocode}
377 \NewDocumentCommand \PangramSetup { +m }
378 { \keys_set:nn { pangram } { #1 } }
379 % \end{macrocode}
380 % \DescribeMacro{\pangram}
381 % The function itself.
382 % \begin{macrocode}
383 \NewDocumentCommand \pangram { +O{} }
384 {
385 \group_begin:
386 \keys_set:nn { pangram } { #1 }
387 \clearpage
388 \skip_set:Nn \parskip { \c_zero_dim }
389 % \end{macrocode}
390 % Use a loop to get all of the entries in the sizes \opt{clist}.
391 % \begin{macrocode}
392 \int_set:Nn \l_@@_size_index_int { 0 }
393 \tl_use:N \l_@@_before_tl
394 \int_do_while:nNnn
395 { \l_@@_size_index_int } < { \clist_count:N \l_@@_sizes_clist }
396 {
397 \mode_leave_vertical:
398 \int_incr:N \l_@@_size_index_int
399 \hbox_to_zero:n
400 {
401 \hss
402 \tl_use:N \l_@@_tagfont_tl
403 \clist_item:Nn \l_@@_sizes_clist { \l_@@_size_index_int }
404 \skip_horizontal:N \l_@@_tagskip_skip
405 }
406 \hbox_to_zero:n
407 {
408 \tl_use:N \l_@@_font_tl
409 \fontsize
410 { \clist_item:Nn \l_@@_sizes_clist { \l_@@_size_index_int } }
411 { \c_zero_dim } % \z@
412 \selectfont
413 \tl_use:c { c_@@_text_ \tl_use:N \l_@@_textclass_tl _tl }
414 \hss
415 }
416 \int_compare:nNnT
417 { \l_@@_size_index_int } = { \clist_count:N \l_@@_sizes_clist }
418 { \skip_set:Nn \l_@@_linegap_skip { \c_zero_dim } }
419 \par
420 \skip_vertical:N \l_@@_linegap_skip
421 }
422 % \end{macrocode}
423 % The loop ends here.
424 % \begin{macrocode}
425 \tl_use:N \l_@@_after_tl
426 \clearpage
427 \group_end:
428 }
429 %</package>
430 % \end{macrocode}
431 \endinput