| 1 |
% \iffalse |
| 2 |
% Copyright 2022 Jiro Senju |
| 3 |
% |
| 4 |
% This package is free software; you can redistribute it and/or modify |
| 5 |
% it under the terms of the GNU General Public License as published by |
| 6 |
% the Free Software Foundation; either version 2 of the License, or |
| 7 |
% any later version. |
| 8 |
% |
| 9 |
% This package is distributed in the hope that it will be useful, |
| 10 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
% GNU General Public License for more details. |
| 13 |
% |
| 14 |
% You should have received a copy of the GNU General Public License |
| 15 |
% along with this package. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
% \fi |
| 17 |
% |
| 18 |
% \section{Library (\texttt{ft-lib.dtx})} |
| 19 |
% |
| 20 |
% While this is the last section of this document, |ft-lib.dtx| is located |
| 21 |
% top of |sty|. |
| 22 |
% |
| 23 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 24 |
% \subsectImpl |
| 25 |
% |
| 26 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 27 |
% |
| 28 |
% \begin{macrocode} |
| 29 |
\RequirePackage{relsize} |
| 30 |
\RequirePackage{xparse} |
| 31 |
% \end{macrocode} |
| 32 |
% |
| 33 |
% \DescribeMacro{\ft@unit} |
| 34 |
% Represents a width of a single character. |
| 35 |
% |
| 36 |
% \DescribeMacro{\if@tate} |
| 37 |
% Supports Japanese vertical mode (|jlreq.cls|). Other than Japanese, this |
| 38 |
% dummy |\if@tate| is always false. |
| 39 |
% \medskip |
| 40 |
% |
| 41 |
% \begin{macrocode} |
| 42 |
\global\newlength{\ft@unit}% |
| 43 |
\@ifundefined{if@tate}{% |
| 44 |
\global\newif\if@tate% |
| 45 |
\global\ft@unit=1em% |
| 46 |
}{ |
| 47 |
\global\ft@unit=1zw% |
| 48 |
}% |
| 49 |
% \end{macrocode} |
| 50 |
% |
| 51 |
% \DescribeMacro{\ft@alias} |
| 52 |
% Makes an alias with prefix-less (|ft|). |
| 53 |
% I don't know why such many |\expandafter|s are necessary. |
| 54 |
% \medskip |
| 55 |
% |
| 56 |
% \begin{macrocode} |
| 57 |
\newcommand{\ft@alias}[1]{% ft-less-name |
| 58 |
\@ifundefined{#1}{% |
| 59 |
\global\expandafter\expandafter\expandafter% |
| 60 |
\let\expandafter\expandafter\csname#1\endcsname\expandafter% |
| 61 |
=\csname ft#1\endcsname% |
| 62 |
}{% |
| 63 |
\message{skip alias to ft#1}% |
| 64 |
}% |
| 65 |
} |
| 66 |
% \end{macrocode} |
| 67 |
% |
| 68 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 |
% \subsubsection{utility} |
| 70 |
% |
| 71 |
% \DescribeMacro{\ftymd} |
| 72 |
% \DescribeMacro{\ymd} |
| 73 |
% \cmd{\ftymd |
| 74 |
% \marg{year} |
| 75 |
% \oarg{month} |
| 76 |
% \oarg{date} |
| 77 |
% } |
| 78 |
% |
| 79 |
% Arranges and prints year-month-date. Japanese vertical mode is supported. |
| 80 |
% Assumes to be used in \meta{additional info} of |\indvdldef|. |
| 81 |
% \medskip |
| 82 |
% |
| 83 |
% \begin{macrocode} |
| 84 |
\NewDocumentCommand{\ftymd}{moo}{% year [month] [date] |
| 85 |
\if@tate% |
| 86 |
\tatechuyoko{#1}% |
| 87 |
\IfValueT{#2}{\tatechuyoko{#2}}% |
| 88 |
\IfValueT{#3}{\tatechuyoko{#3}}% |
| 89 |
\else% |
| 90 |
#1% |
| 91 |
\IfValueT{#2}{\slash#2}% |
| 92 |
\IfValueT{#3}{\slash#3}% |
| 93 |
\fi% |
| 94 |
} |
| 95 |
\ft@alias{ymd} |
| 96 |
% \end{macrocode} |
| 97 |
% |
| 98 |
% \noindent |
| 99 |
% \DescribeMacro{\ftundef} |
| 100 |
% \cmd{\ftundef |
| 101 |
% \marg{box name} |
| 102 |
% } |
| 103 |
% |
| 104 |
% Undefines all internal \CS es who has \meta{box name} in its name. |
| 105 |
% For this macro, we don't define the prefix-less alias. |
| 106 |
% \medskip |
| 107 |
% |
| 108 |
% \begin{macrocode} |
| 109 |
\newcommand{\ftundef}[1]{% |
| 110 |
\@for\@temptokena:=#1\do{% |
| 111 |
\global\expandafter\let\csname\@temptokena\endcsname=\relax% |
| 112 |
\global\expandafter\let\csname\@temptokena nameCY\endcsname=\relax% |
| 113 |
\global\expandafter\let\csname\@temptokena mrrgCY\endcsname=\relax% |
| 114 |
\global\expandafter\let\csname\@temptokena hasmaleline\endcsname% |
| 115 |
=\relax% |
| 116 |
}% |
| 117 |
} |
| 118 |
% \end{macrocode} |
| 119 |
% |
| 120 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 121 |
% \subsubsection{internal library} |
| 122 |
% |
| 123 |
% \parag{global variable} |
| 124 |
% |
| 125 |
% \begin{macrocode} |
| 126 |
\newif\ifft@box@has@maleline |
| 127 |
\newif\ifft@widest@has@no@maleline |
| 128 |
\newlength{\ft@len} |
| 129 |
\newlength{\ft@width} |
| 130 |
\newlength{\ft@height} |
| 131 |
\newlength{\ft@depth} |
| 132 |
\newlength{\ft@theight} |
| 133 |
\newlength{\ft@x} |
| 134 |
\newlength{\ft@xx} |
| 135 |
\newlength{\ft@y} |
| 136 |
\newlength{\ft@yy} |
| 137 |
% \end{macrocode} |
| 138 |
% |
| 139 |
% \parag{utility function} |
| 140 |
% |
| 141 |
% \DescribeMacro{\ft@namexdef} |
| 142 |
% \DescribeMacro{\ft@namexdefstrip} |
| 143 |
% \NoDescription |
| 144 |
% \begin{macrocode} |
| 145 |
\newcommand{\ft@namexdef}[2]{% name value |
| 146 |
\global\expandafter\edef\csname#1\endcsname{#2}% |
| 147 |
%\expandafter\xdef\csname#1\endcsname{#2}% |
| 148 |
\ft@dbgmsg{xdef #1 #2}% |
| 149 |
} |
| 150 |
\newcommand{\ft@namexdefstrip}[2]{% name length |
| 151 |
\ft@namexdef{#1}{\strip@pt#2}% |
| 152 |
} |
| 153 |
% \end{macrocode} |
| 154 |
% |
| 155 |
% \DescribeMacro{\ft@savenamebox} |
| 156 |
% \DescribeMacro{\ft@newnamebox} |
| 157 |
% \NoDescription |
| 158 |
% \begin{macrocode} |
| 159 |
\newcommand{\ft@savenamebox}[2]{% name contents |
| 160 |
\expandafter\savebox\expandafter{\csname#1\endcsname}{#2}% |
| 161 |
} |
| 162 |
\newcommand{\ft@newnamebox}[2]{% name contents |
| 163 |
\global\expandafter\newsavebox\expandafter{\csname#1\endcsname}% |
| 164 |
\ft@savenamebox{#1}{#2}% |
| 165 |
} |
| 166 |
% \end{macrocode} |
| 167 |
% |
| 168 |
% \DescribeMacro{\ft@nameboxsz} |
| 169 |
% \DescribeMacro{\ft@boxsz} |
| 170 |
% \NoDescription |
| 171 |
% \begin{macrocode} |
| 172 |
\newcommand{\ft@nameboxsz}[4][]{% [width] name ht-value dp-value |
| 173 |
\ifx#1\empty\else% |
| 174 |
\expandafter\wd\csname#2\endcsname=#1% |
| 175 |
\fi% |
| 176 |
\expandafter\ht\csname#2\endcsname=#3% |
| 177 |
\expandafter\dp\csname#2\endcsname=#4% |
| 178 |
\ft@dbgmsg{#2 box, W \the\wd\@nameuse{#2}, H \the\ht\@nameuse{#2},% |
| 179 |
D \the\dp\@nameuse{#2}}% |
| 180 |
} |
| 181 |
\newcommand{\ft@boxsz}[3]{% box ht-value dp-value |
| 182 |
\expandafter\ht#1=#2% |
| 183 |
\expandafter\dp#1=#3% |
| 184 |
\ft@dbgmsg{#2 box, W \the\wd#1, H \the\ht#1, D \the\dp#1}% |
| 185 |
} |
| 186 |
% \end{macrocode} |
| 187 |
% |
| 188 |
% \DescribeMacro{\ft@list@append} |
| 189 |
% \NoDescription |
| 190 |
% \begin{macrocode} |
| 191 |
\newcommand{\ft@list@append}[3]{% list element |
| 192 |
\ifx#1\empty% |
| 193 |
\xdef#1{#2}% |
| 194 |
\else% |
| 195 |
\xdef#1{#1,#2}% |
| 196 |
\fi% |
| 197 |
} |
| 198 |
\iffalse |
| 199 |
\newcommand{\ft@detokenize}[1]{% |
| 200 |
{% |
| 201 |
\escapechar=`\ % |
| 202 |
\catcode`\ =9% |
| 203 |
%\string#1% |
| 204 |
\detokenize{#1}% |
| 205 |
}% |
| 206 |
} |
| 207 |
\fi |
| 208 |
% \end{macrocode} |
| 209 |
% |
| 210 |
% \parag{debugging} |
| 211 |
% |
| 212 |
% \DescribeMacro{\ifftdbg} |
| 213 |
% \DescribeMacro{\ft@dbgmsg} |
| 214 |
% \DescribeMacro{\ft@dbgframe} |
| 215 |
% \DescribeMacro{\ft@dbgplot} |
| 216 |
% \DescribeMacro{\ft@dbgbox} |
| 217 |
% \NoDescription |
| 218 |
% \begin{macrocode} |
| 219 |
\newif\ifftdbg |
| 220 |
\newcommand{\ft@dbgmsg}[1]{% |
| 221 |
\ifftdbg% |
| 222 |
\message{#1}% |
| 223 |
\fi% |
| 224 |
} |
| 225 |
\newcommand{\ft@dbgframe}[2][0,0]{% [point x,y] width,height |
| 226 |
\ifftdbg% |
| 227 |
\put(#1){\framebox(#2){}}% |
| 228 |
\fi% |
| 229 |
} |
| 230 |
\newcommand{\ft@dbgplot}[2][]{% |
| 231 |
\ifftdbg% |
| 232 |
\put(#2){\circle{1}{\tiny#1}}% |
| 233 |
\fi% |
| 234 |
}% |
| 235 |
\newcommand{\ft@dbgbox}[2][]{% [extra-put] box |
| 236 |
\ifftdbg% |
| 237 |
\ft@len=\dimexpr\ht#2 + \dp#2\relax% |
| 238 |
\begin{picture}(\strip@pt\wd#2,\strip@pt\ht#2)(0,-\strip@pt\dp#2)% |
| 239 |
\ft@dbgframe[0,-\strip@pt\dp#2]{\strip@pt\wd#2,\strip@pt\ft@len}% |
| 240 |
%\put(0,0){{\tiny\ft@detokenize{#2}}}% |
| 241 |
%\put(0,-\strip@pt\dp#2){\usebox{#2}}% |
| 242 |
\put(0,0){\usebox{#2}}% |
| 243 |
#1% |
| 244 |
\end{picture}% |
| 245 |
\fi% |
| 246 |
} |
| 247 |
% \end{macrocode} |