summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/showcharinbox/showcharinbox.dtx
blob: 7bdfb6f4164a2946f403da67c93670e1b2c10632 (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
% \iffalse 
%<*internal>
\iffalse
%</internal>
%<*readme>
_______________________
The showcharinbox package
v0.1

Show charcters inside a box display its height, depth, and width information.

If you want to report any bugs or typos and corrections in the documentation,
or ask for any new features, or suggest any improvements, or ask any questions
about the package, then please do not send any direct emails to us; we will not 
answer any direct emails. Instead please use the issue tracker:
  <https://github.com/persian-tex/showcharinbox/issues>
In doing so, please always explain your issue well enough, always include
a minimal working examples showing the issue, and always choose the appropriate
label for your query (i.e. if you are reporting any bugs, choose `bug' label). 

Current version release date: 2013/04/04

______________
Persian TeX Group
persian-tex@tug.org

Copyright © 2012–2013
Distributed under the LaTeX Project Public License
It may be distributed and/or modified under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

This work is “maintained” (as per LPPL maintenance status) 
by Persian TeX Group.
%</readme>
%<*internal>
\fi
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble

  ______________________________________
  Copyright © 2012–2013  Persian TeX Group

  License information appended.


\endpreamble
\postamble

Copyright © 2012–2013  Persian TeX Group <persian-tex@tug.org>

It may be distributed and/or modified under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

This work is “maintained” (as per LPPL maintenance status) 
by Persian TeX Group.



\endpostamble
\askforoverwritefalse
\generate{\file{showcharinbox.sty}{\from{\jobname.dtx}{showcharinbox.sty}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
\endgroup
\immediate\write18{mv README.txt README}
\immediate\write18{makeindex -s gind.ist -o \jobname.ind  \jobname.idx}
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls  \jobname.glo}
%</internal>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{bidicode,fontspec}
\usepackage{calc}
\usepackage{pifont}
\usepackage{bbding}
\setlength\columnseprule{.4pt}
\newfontfamily\testfont{XB Yas}
\usepackage[numbered]{hypdoc}
\usepackage{showcharinbox}
\definecolor{myblue}{rgb}{0.1,0.2,0.8}
\hypersetup{linkcolor=myblue,urlcolor=myblue,citecolor=myblue}
\makeatletter
\renewcommand\tableofcontents{\relax
  \begin{multicols}{2}[\section*{\contentsname}]\small
    \@starttoc{toc}\relax
  \end{multicols}}
\makeatother
\newcounter{local}
\renewcommand\theenumi{\protect\setcounter{local}%
  {201+\the\value{enumi}}\protect\ding{\value{local}}}
\renewcommand\labelenumi{\theenumi}
\renewcommand\labelitemi{\HandRight}
\renewcommand\labelitemii{\HandRightUp}
\renewcommand\labelitemiii{\HandCuffRight}
\renewcommand\labelitemiv{\HandPencilLeft}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
\begin{document}
  \DocInput{\jobname.dtx}
  \PrintIndex
  \PrintChanges
\end{document}
%</driver>
%
%
% \fi
%
% \GetFileInfo{\jobname.cls}
% \CheckSum{0}
% \makeatletter
%\title{The \textsf{showcharinbox} package\\
%\href{https://github.com/persian-tex/showcharinbox}{\texttt{https://github.com/persian-tex/showcharinbox}}}
%\author{Persian TeX Group\\ \href{mailto:persian-tex@tug.org}{\texttt{persian-tex@tug.org}}}
%\date{Version 0.1\qquad\today}
%\maketitle
%\tableofcontents
%\section{What does the \textsf{showcharinbox} package do?}
% This package defines the command \Lcs{ShowCharInBox} which has the following syntax:
%\begin{BDef}
%\Lcs{ShowCharInBox}\Largb{\Larga{charcter}}
%\end{BDef}
% This will show \Larga{charcter} inside a box showing its height, depth, and width information. 
%\begin{LTXexample}[morekeywords={ShowCharInBox,testfont,newfontfamily},pos=b]
%\documentclass{article}
%\usepackage{fontspec}
%\newfontfamily\testfont{XB Yas}
%\usepackage{showcharinbox}
%\begin{document}
%\begin{center}
%\ShowCharInBox{\fontsize{200}{210}\testfont \char"FEA5}
%\end{center}
%\end{document}
%\end{LTXexample}
% \StopEventually{}
%
% \section{Implementation of \textsf{showcharinbox} package}
%\iffalse
%<*showcharinbox.sty>
%\fi
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\newcommand*{\showcharinbox@date}{2013/04/04}
\newcommand*{\showcharinbox@version}{v0.1}
\ProvidesPackage{showcharinbox}
          [\showcharinbox@date\space \showcharinbox@version\space 
          Showing characters inside a box]
\newdimen\showcharinbox@charwidth
\newdimen\showcharinbox@charheight
\newdimen\showcharinbox@chardepth
\newbox\showcharinbox@bigdot
\newbox\showcharinbox@smalldot
%    \end{macrocode}
% Macros for drawing figures:
%    \begin{macrocode}
\newcommand*{\showcharinbox@hidehrule}[2]{%
\kern-#1\hrule height#1 depth#2 \kern-#2 }
\newcommand*{\showcharinbox@hidevrule}[2]{\kern-#1{\dimen0=#1
    \advance\dimen0 by#2\vrule width\dimen0}\kern-#2 }
%    \end{macrocode}
% \Lcs{showcharinbox@makeblankbox} puts rules at the edges of a blank box
% whose dimensions are those of \Lcs{box0} (assuming nonnegative wdith, height, and depth). 
% Argument 1 is rule thickness outside, and argument 2 is rule thickness inside:
%    \begin{macrocode}
\newcommand*{\showcharinbox@makeblankbox}[2]{\hbox{\lower\dp0\vbox{\showcharinbox@hidehrule{#1}{#2}%
%    \end{macrocode}
%overlap the rules at the corners:
%    \begin{macrocode}
    \kern-#1% 
    \hbox to\wd0{\showcharinbox@hidevrule{#1}{#2}%
%    \end{macrocode}
%set the vrule height:
%    \begin{macrocode}
      \raise\ht0\vbox to #1{}% 
%    \end{macrocode}
%set the vrule depth:
%    \begin{macrocode}
      \lower\dp0\vtop to #1{}% 
      \hfil\showcharinbox@hidevrule{#2}{#1}}%
    \kern-#1\showcharinbox@hidehrule{#2}{#1}}}}
\newcommand*{\showcharinbox@maketypebox}{\showcharinbox@makeblankbox{0pt}{1pt}}
\newcommand*{\showcharinbox@makelightbox}{\showcharinbox@makeblankbox{.2pt}{.2pt}}
%    \end{macrocode}
% \Lcs{box}\Lcs{showcharinbox@bigdot} is a null box with a bullet at its reference point. \Lcs{ht0} is the axis height:
%    \begin{macrocode}
\setbox0=\hbox{$\vcenter{}$} % 
%    \end{macrocode}
%bullet is centered on the axis:
%    \begin{macrocode}
\setbox1=\hbox to\z@{$\hss\bullet\hss$} % 
\setbox\showcharinbox@bigdot=\vbox to\z@{\kern-\ht1 \kern\ht0 \box1 \vss}
%    \end{macrocode}
%\Lcs{cdot} is centered on the axis:
%    \begin{macrocode}
\setbox1=\hbox to\z@{$\hss\cdot\hss$} % 
\setbox\showcharinbox@smalldot=\vbox to\z@{\kern-\ht1 \kern\ht0 \box1 \vss}
%    \end{macrocode}
% \Lcs{showcharinbox@arrows} makes things like $\leftarrow\hbox{ text }\rightarrow$:
%    \begin{macrocode}
\newcommand*{\showcharinbox@arrows}[2]{% 
%    \end{macrocode}
%Argument 1 is width and argument 2 is text:
%    \begin{macrocode}
  {\setbox0=\hbox{$\mkern-2mu\mathord-\mkern-2mu$}
    \hbox to #1{\kern-.055556em$\leftarrow\mkern-6mu$%
      \cleaders\copy0\hfil
      \kern.4em #2\kern.4em
      \cleaders\copy0\hfil
      $\mkern-6mu\rightarrow$\kern-.055556em}}}
%    \end{macrocode}
% \Lcs{showcharinbox@samplebox} makes the outline of a box, with big dot at reference point. Argument 1 is height, argument 2 is depth, argument 3 is width, and argument4 is text:
%    \begin{macrocode}
\newcommand*{\showcharinbox@samplebox}[4]{% 
  {\setbox0=\vtop{\vbox to #1{\hbox to #3{}\vss}
      \nointerlineskip
%    \end{macrocode}
%Now \Lcs{box0} has the desired height, depth, and width:
%    \begin{macrocode}
      \vbox to #2{}}% 
    \hbox{\copy\showcharinbox@bigdot
      \vrule height.2pt depth.2pt width#3%
      \kern-#3%
      \showcharinbox@makelightbox
      \kern-#3%
      \raise#1\vbox{\hbox to #3{\hss#4\hss}
        \kern 3pt}}}}
        
\newcommand{\ShowCharInBox}[1]{%
\setbox9=\hbox{#1}
\setlength{\showcharinbox@chardepth}{\dp9}
\setlength{\showcharinbox@charheight}{\ht9}
\setlength{\showcharinbox@charwidth}{\wd9}
\setbox0=\hbox{$\uparrow$}
%    \end{macrocode}
% With luck, they'll line up:
%    \begin{macrocode}
\setbox1=\hbox to \wd0{$\hss\mid\hss$} % 
\setbox2=\vbox to \showcharinbox@charheight{\copy0
  \nointerlineskip \kern-.5pt \copy1
  \nointerlineskip \kern-.5pt \copy1
  \vfil
  \moveleft 1em\hbox{height$=$\the\showcharinbox@charheight}
  \vfil
  \copy1 \nointerlineskip \kern-.5pt
  \copy1 \nointerlineskip \kern-.5pt
  \hbox{$\downarrow$}
  \kern.2pt}
\setbox3=\vbox to \showcharinbox@chardepth{\kern.2pt\copy0
  \vfil
  \moveleft 1em\hbox{depth$=$\the\showcharinbox@chardepth}
  \vfil
  \hbox{$\downarrow$}
  \kern0pt}
%    \end{macrocode}
%This cancels the null text above the \Lcs{showcharinbox@samplebox}:
%    \begin{macrocode}
\setbox4=\vtop{\kern-3pt % 
  \hbox{\showcharinbox@samplebox{\showcharinbox@charheight}{\showcharinbox@chardepth}{\showcharinbox@charwidth}{}%
    \kern-\showcharinbox@charwidth
 \hbox to \showcharinbox@charwidth{\hss \unhbox9\hss}}
  \kern3pt
  \showcharinbox@arrows{\showcharinbox@charwidth}{width$=$\the\showcharinbox@charwidth}}
\medskip\indent
%    \end{macrocode}
%\Lcs{ht0} is the axis height:
%    \begin{macrocode}
\setbox0=\hbox{$\vcenter{}$}% 
\lower\ht0\hbox{Reference point$-$\kern-.2em$\rightarrow$\kern2pt}%
\raise\ht2\box4
\kern1.5em
\raise\ht2\vtop{\kern0pt\box2\nointerlineskip\box3}}
%    \end{macrocode}
% \iffalse
%</showcharinbox.sty>
%\fi
%
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by TeX:}
% \typeout{*}
% \typeout{* \space\space\space showcharinbox.sty  file}
% \typeout{*}
% \typeout{*************************************************************}
%
\endinput