summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/microtype/microtype-show.sty
blob: f52b167938f9860ab7978bdfc8cd67e3d3908544 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
%%
%% This is file `microtype-show.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% microtype.dtx  (with options: `show')
%% 
%% ------------------------------------------------------------------------
%% 
%%                       The `microtype' package
%%         Subliminal refinements towards typographical perfection
%%           Copyright (c) 2004--2021 R Schlicht <w.m.l@gmx.net>
%% 
%% 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.3c or later is part
%% of all distributions of LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% This work consists of the files microtype.dtx, microtype-utf.dtx and
%% microtype.ins and the derived files microtype.sty, microtype-pdftex.def,
%% microtype-luatex.def, microtype-xetex.def, microtype.lua, letterspace.sty
%% and microtype-show.sty.
%% 
%% ------------------------------------------------------------------------
%%   This companion package offers various commands that might be helpful
%%   when creating protrusion settings. See the documentation in microtype's
%%   User manual, section 10, and the examples in test-microtype.tex.
%% ------------------------------------------------------------------------ 
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage
  {microtype-show}
  [2021/10/31 v3.0
  Visual debugging for the microtype package
   (RS)]
\RequirePackage{iftex}
\ifetex\else
  \PackageError{microtype-show}
               {This package only works with e-TeX}{Use e-TeX}
\fi
\ifxetex
  \PackageError{microtype-show}
               {This package only works with pdfTeX or luaTeX}{Don't use XeTeX}
\fi
\PackageWarning{microtype-show}{DO NOT USE THIS PACKAGE FOR REAL DOCUMENTS\@gobble}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{microtype}}
\ProcessOptions\relax
\PassOptionsToPackage{verbose}{microtype}
\RequirePackage{microtype,graphicx,xcolor}
\newif\ifShowGlyphIndex
\newif\ifShowMissingGlyphs
\newcommand*\GlyphScaleFactor{2}
\newcommand*\Showbaselinecolor{\color{black!40}}
\newcommand*\Showposcolor{\color{green!50}}
\newcommand*\Shownegcolor{\color{red!50}}
\ifluatex
  \def\MTS@printtext#1{{\usefont{TU}{lmr}{m}{n}#1}}
\else
  \def\MTS@printtext#1{{\usefont{T1}{cmr}{m}{n}#1}}
\fi
\def\MTS@show@index#1{\ifShowGlyphIndex{\tiny$_{#1}%
 %  \ifluatex^{\mathrm{%
 %    \MT@lua{tex.print(luaotfload.aux.name_of_slot(tonumber([[#1]])))}}}\fi
  $}\fi\space}
\def\MTS@crulefill{\leaders\hrule height \dimexpr1ex/2+.4pt depth -\dimexpr1ex/2\hfill}
\g@addto@macro\MT@setupfont{\MTS@Prot\MTS@Char}
\let\MTS@Prot\relax
\let\MTS@Char\relax
\def\MTS@setup{%
  \fboxsep=0pt
  \fboxrule=.1pt
  \raggedright
  \let\MTS@glyphlist\@gobble
  \def\MT@feat{pr}%
}
\newcommand*\ShowProtrusion{%
  \begingroup
    \MTS@setup
    \let\MTS@Prot\MTS@Prot@do
    \def\MT@cat{c}%
    \selectfont
}
\def\MTS@Prot@do{%
    \MT@ltx@pickupfont
    \let\MT@pr@split@val\MTS@pr@split@val
    \let\MT@load@list\MTS@load@list
    \let\MT@set@pr@prefixes@\MTS@set@pr@prefixes@
    \MTS@show@pr
  \endgroup
  \aftergroup\selectfont
}
\newcommand*\ShowCharacterInheritance{%
  \begingroup
    \MTS@setup
    \let\MTS@Char\MTS@Char@do
    \def\MT@cat{inh}%
    \selectfont
}
\def\MTS@Char@do{%
    \MT@ltx@pickupfont
    \let\MT@set@pr@prefixes@\MTS@set@pr@prefixes@
    \MTS@show@inheritance
  \endgroup
  \aftergroup\selectfont
}
\newcommand*\ShowProtrusionLineGlyph[1]{%
  {\MTS@setup
   \MTS@showprotrusionline{`#1}}%
}
\newcommand*\ShowProtrusionLineIndex[1]{%
  {\MTS@setup
   \MTS@showprotrusionline{#1}}%
}
\def\MTS@showprotrusionline#1{%
  \edef\MTS@lpcode{\number\lpcode\font#1}%
  \edef\MTS@rpcode{\number\rpcode\font#1}%
  \char#1%
    lorem ipsum dolor sit amet, \MTS@crulefill\ %
    \MTS@printtext{\ifnum\MTS@lpcode=\z@\Showbaselinecolor\fi[\MTS@lpcode]}
    \fbox{\char#1}\MTS@show@index{\number#1}
    \MTS@printtext{\ifnum\MTS@rpcode=\z@\Showbaselinecolor\fi[\MTS@rpcode]}
    \MTS@crulefill\ you know the rest%
  \char#1\par
  \ShowDummyLine
}
\newcommand*\ShowDummyLine{%
 {\fontencoding{\encodingdefault}\fontseries{\seriesdefault}\fontshape{\shapedefault}%
  \selectfont\noindent
  here is the beginning of a line, \dotfill and here is its end}\par
}
\newcommand*\ShowProtrusionAll{%
  {\MTS@setup
   \MTS@lede{}%
   \MT@do@font{\iffontchar\font\@tempcnta\MTS@showprotrusionline{\@tempcnta}\fi}}%
}
\newcommand*\ShowProtrusionDefined{%
  {\MTS@setup
   \MTS@lede{defined}%
   \let\MTS@first\@gobble
   \let\MTS@second\@firstofone
   \MT@do@font{%
     \MTS@firstorsecond
     \MTS@temp{%
       \iffontchar\font\@tempcnta\MTS@showprotrusionline{\@tempcnta}\else
         \MT@warning@nl{Glyph \the\@tempcnta\space is missing in font
                        \MessageBreak\font@name}%
       \fi}}}%
}
\newcommand*\ShowProtrusionMissing{%
  {\MTS@setup
   \MTS@lede{missing}%
   \let\MTS@first\@firstofone
   \let\MTS@second\@gobble
   \MT@do@font{%
     \MTS@firstorsecond
     \iffontchar\font\@tempcnta\MTS@temp{\MTS@showprotrusionline{\@tempcnta}}\fi}}%
}
\def\MTS@lede#1{%
  \selectfont
  \edef\MTS@font{\expandafter\string\font@name}%
  \MTS@printtext{All glyphs \MT@ifempty{#1}{in}{#1 in protrusion list for}
                 font \texttt{\MTS@font}:}\par
  \ShowDummyLine
}
\def\MTS@firstorsecond{%
  \let\MTS@temp\MTS@first
  \ifnum\lpcode\font\@tempcnta=\z@ \else
    \let\MTS@temp\MTS@second
  \fi
  \ifnum\rpcode\font\@tempcnta=\z@ \else
    \let\MTS@temp\MTS@second
  \fi
}
\newdimen\MTS@charwd
\newdimen\MTS@lp@
\newdimen\MTS@rp@
\def\MTS@show@char@pr#1{%
  \xdef\MTS@glyphlist{\MTS@glyphlist,#1}%
  \scalebox{\GlyphScaleFactor}{\strut\escapechar`\\
    \MTS@charwd=\fontcharwd\MT@font#1\relax
    {\Showbaselinecolor\vrule width \dimexpr\MTS@charwd+.3em\relax height 1sp depth 0pt}%
    \hskip-\dimexpr\MTS@charwd+.15em\relax
    {\ifdim\MTS@lp@<\z@\Shownegcolor\else\Showposcolor\fi
     \vrule width \ifdim\MTS@lp@<\z@ -\fi\MTS@lp@ height 1em depth .2em}%
    \hskip\dimexpr\MTS@charwd\ifdim\MTS@lp@>\z@-\MTS@lp@\fi
                             \ifdim\MTS@rp@>\z@-\MTS@rp@\fi\relax
    {\ifdim\MTS@rp@<\z@\Shownegcolor\else\Showposcolor\fi
     \vrule width \ifdim\MTS@rp@<\z@ -\fi\MTS@rp@ height 1em depth .2em}%
    \hskip-\dimexpr\MTS@charwd+\fboxrule\ifdim\MTS@rp@<\z@-\MTS@rp@\fi\relax
    \fbox{\char#1}}\,%
    \MTS@show@index{#1}%
}
\def\MTS@show@char#1{\scalebox{\GlyphScaleFactor}{%
  \strut\fbox{\char#1}}\MTS@show@index{#1}}
\def\MTS@show@char@x#1{\xdef\MTS@glyphlist{\MTS@glyphlist,#1}\MTS@show@char{#1}}
\def\MTS@show@missing{%
  \MT@ifdefined@c@T\MT@pr@inh@name{%
    \MTS@lp@=\z@ \MTS@rp@=\z@
    \par \MTS@printtext{Glyphs not included in configuration (with defined heirs):}%
    \MT@do@font{%
      \edef\MT@temp{\the\@tempcnta}%
      \MT@ifdefined@n@T{MT@inh@\MT@pr@inh@name @\MT@temp @}{%
        \MT@exp@one@n\MT@in@clist\MT@temp\MTS@glyphlist
        \ifMT@inlist@\else \newline
        \llap{\MTS@show@char@pr{\MT@temp} \MTS@printtext{=} }%
         \MT@exp@cs\MT@map@tlist@c
           {MT@inh@\MT@pr@inh@name @\the\@tempcnta @}%
           \MTS@show@char@x
        \fi
      }%
    }%
  }%
  \MTS@show@missing@
}
\def\MTS@show@missing@{%
  \par \MTS@printtext{Other glyphs not in configuration:}\newline
  \MT@do@font{%
    \edef\MT@temp{\the\@tempcnta}%
    \MT@exp@one@n\MT@in@clist\MT@temp\MTS@glyphlist
    \ifMT@inlist@\else
      \MTS@show@char\MT@temp
    \fi
  }%
}
\def\MTS@show@inheritance{%
  \MT@get@inh@list
  \MTS@printtext{Character inheritance for font `\texttt{\MT@@font}':}\\
  \MT@ifdefined@c@TF\MT@listname{%
    \MTS@printtext{First matching list is for `\texttt{\@tempa}':\\
              \texttt{\MT@listname}:}\par\leavevmode
    \MT@do@font{%
      \MT@ifdefined@n@T{MT@inh@\MT@listname @\the\@tempcnta @}{%
        \newline
        \xdef\MTS@glyphlist{\MTS@glyphlist,\the\@tempcnta}%
        \llap{\MTS@show@char{\the\@tempcnta}\MTS@printtext{= }}%
        \MT@exp@cs\MT@map@tlist@c
          {MT@inh@\MT@listname @\the\@tempcnta @}%
          \MTS@show@char@x
      }%
    }%
    \MT@ifdefined@n@T{MT@inh@\MT@listname @prefixes}{%
      \par \MTS@printtext{(with prefixes:)}%
      \@tempcntb=\z@
      \let\MTS@show@char@pr\MTS@show@char@x
      \MT@set@pr@prefixheirs}%
    \ifShowMissingGlyphs\MTS@show@missing@\fi
  }{%
    \MTS@printtext{NOT DEFINED}%
  }%
  \par
}
\def\MTS@show@pr
  {%
  \MTS@printtext{Protrusion settings for font `\texttt{\MT@@font}':}\\
  \MT@if@list@exists{%
    \MTS@printtext{First matching list is for `\texttt{\@tempa}':\\\texttt{\MT@pr@c@name}}%
    \MT@get@opt
    \MT@reset@pr@codes
    \MT@get@inh@list
    \MT@set@inputenc{c}%
    \MT@load@list\MT@pr@c@name
    \MT@set@listname
    \MT@let@cn\@tempc{MT@pr@c@\MT@pr@c@name}%
    \expandafter\MT@set@codes\@tempc,\relax,%
    \vrule width 4cm height .5pt \\
    \MTS@printtext{End of list `\texttt{\MT@pr@c@name}'}\\[.5em]
    \MT@ifdefined@c@T\MT@pr@inh@name{%
      \MT@ifdefined@n@T{MT@inh@\MT@pr@inh@name @prefixes}{%
        \par \MTS@printtext{(with prefixes:)}%
        \@tempcntb=\z@
    \MT@set@pr@prefixheirs
    }}%
    \ifShowMissingGlyphs\MTS@show@missing\fi
  }%
  {\MTS@printtext{NOT DEFINED}%
  \MT@reset@pr@codes
  }\par
}
\def\MTS@pr@split@val#1,#2\relax
  {\def\@tempb{#1}%
  \MT@ifempty\@tempb
  {\MTS@lp@=\z@ \let\MTS@lpcode\@empty}%
  {\MT@scale@to@em
    \MTS@lp@=\dimexpr\@tempcntb em/1000\relax\relax
    \edef\MTS@lpcode{[\@tempb] \the\@tempcntb/\the\MTS@lp@}%
  }%
  \def\@tempb{#2}%
  \MT@ifempty\@tempb
  {\MTS@rp@=\z@ \let\MTS@rpcode\@empty}%
  {\MT@scale@to@em
    \MTS@rp@=\dimexpr\@tempcntb em/1000\relax\relax
    \edef\MTS@rpcode{[\@tempb] \the\@tempcntb/\the\MTS@rp@}%
  }%
  \llap{\MTS@show@char@pr\MT@char\quad}%
  \parbox[b][][b]{3.5cm}{\MTS@printtext{%
      \footnotesize\makebox[.4cm][l]{L:} \MT@ifempty{\MTS@lpcode}{---}{\MTS@lpcode}\\
                   \makebox[.4cm][l]{R:} \MT@ifempty{\MTS@rpcode}{---}{\MTS@rpcode}}}%
  \parbox[t][][t]{\dimexpr\textwidth-3.5cm}{%
  \MT@ifdefined@c@T\MT@pr@inh@name{%
    \MT@ifdefined@n@T{MT@inh@\MT@pr@inh@name @\MT@char @}{%
      \MT@exp@cs\MT@map@tlist@c
        {MT@inh@\MT@pr@inh@name @\MT@char @}%
      \MTS@show@char@pr
    }%
  }%
  }\newline
}
\def\MTS@set@pr@prefixes@#1#2#3#4%
  {%
  \MTS@lp@=\z@ \MTS@rp@=\z@
  \ifnum#1=\@tempcntb \else
    \par\leavevmode
    \llap{\MTS@show@char@pr{#1} \MTS@printtext{=} }%
  \fi
  \@tempcnta=\z@
  \ifnum#3>\z@
    \@tempcnta=\numexpr
      (\fontcharwd\MT@font#2-\fontcharwd\MT@font#1)%
      *#3/\MT@dimen@six\relax
  \fi
  \MTS@lp@=\dimexpr\numexpr\lpcode\MT@font#1+\@tempcnta\relax em/1000\relax
  \@tempcnta=\z@
  \ifnum#4>\z@
    \@tempcnta=\numexpr
      (\fontcharwd\MT@font#2-\fontcharwd\MT@font#1)%
      *#4/\MT@dimen@six\relax
  \fi
  \MTS@rp@=\dimexpr\numexpr\rpcode\MT@font#1+\@tempcnta\relax em/1000\relax
  \MTS@show@char@pr{#2}%
  \@tempcntb=#1\relax
}
\def\MTS@load@list#1%
  {\edef\@tempa{#1}%
  \MT@let@cn\@tempb{MT@\MT@feat @c@\@tempa @load}%
  \MT@ifstreq\@tempa\@tempb{%
    \MT@error{\@nameuse{MT@abbr@\MT@feat} list `\@tempa' cannot load itself}{}%
  }{%
    \ifx\@tempb\relax
    :\par\medskip\leavevmode
    \else
      \MT@ifdefined@n@TF{MT@\MT@feat @c@\@tempb}{%
        \MTS@printtext{, loading \texttt{\@tempb}}%
        \MT@vinfo{... : First loading \@nameuse{MT@abbr@\MT@feat} list `\@tempb'}%
        \begingroup
          \MT@load@list\@tempb
        \endgroup
        \edef\MT@curr@list@name{%
                  `\@tempb'}%
        \MT@let@cn\@tempc{MT@\MT@feat @c@\@tempb}%
        \expandafter\MT@set@codes\@tempc,\relax,%
        \vrule width 4cm height .5pt \\
        \MTS@printtext{End of list \texttt{\MT@curr@list@name}}%
        \par\medskip\leavevmode
      }{%
        \MT@error{\@nameuse{MT@abbr@\MT@feat} list `\@tempb' undefined.\MessageBreak
                    Cannot load it from list `\@tempa'}{}%
      }%
    \fi
  }%
}
\endinput
%%
%% End of file `microtype-show.sty'.