1
% tone.sty -- TIPA optional package for displaying `tone letters'.
2
% Copyright 2002 FUKUI Rei
4
% This program may be distributed and/or modified under the
5
% conditions of the LaTeX Project Public License, either version 1.2
6
% of this license or (at your option) any later version.
7
% The latest version of this license is in
8
% http://www.latex-project.org/lppl.txt
9
% and version 1.2 or later is part of all distributions of LaTeX
10
% version 1999/12/01 or later.
12
% This program consists of all files listed in Manifest.txt.
14
% 1996/06/10 first version.
15
% 2001/11/07 \stone (for a short tone bar) added.
16
% 2001/12/32 \@tonestembar added (due to encoding change;
17
% \char'277 is now exclusively used for tone letter stem.
19
\RequirePackage{tipa}[2001/12/31 TIPA version 1.1]
22
\newdimen\@tonebarhtunit
23
\newdimen\@tonebarhalfwd
25
\newcommand\@tonestembar{\tipaencoding\char'277}
27
\newcommand\tone[1]{\@inittone\leavevmode
28
\hbox{\kern\@sidegap\@tone#1\relax\kern-\@tonebarhalfwd{\@tonestembar}}}
30
\newcommand\rtone[1]{\@inittone\leavevmode
31
\hbox{{\@tonestembar}\kern-\@tonebarhalfwd\@tone#1\relax\kern\@sidegap}}
33
\newcommand\stone[1]{\@inittone\@longtonefalse\leavevmode
34
\hbox{\kern\@sidegap\@tone#1\relax\kern-\@tonebarhalfwd{\@tonestembar}}}
36
\newcommand\@tone[1]{%
38
\ifx\pr@vpr@vtone\relax \@outputtone\pr@vtone\pr@vtone
39
\else \@outputtone\pr@vpr@vtone\pr@vtone\fi
42
\ifx\pr@vpr@vtone\relax\else
43
\@longtonefalse\@outputtone\pr@vpr@vtone\pr@vtone\fi
44
\let\pr@vpr@vtone\pr@vtone\def\pr@vtone{#1}%
48
\newcommand\@outputtone[2]{{%
49
\count\z@ #1\advance\count\z@ -#2\def\@mintone{#2}%
50
\ifnum\count\z@>0\count\@ne128\advance\count\@ne \count\z@
51
\edef\@tonecode{\the\count\@ne}% falling tone
53
\ifnum\count\z@<0\count\@ne132\advance\count\@ne -\count\z@
54
\edef\@tonecode{\the\count\@ne}\def\@mintone{#1}% rising tone
56
\def\@tonecode{128}\fi\fi % level tone
57
\if@longtone\else\count\z@\@tonecode
58
\advance\count\z@ 9 \def\@tonecode{\the\count\z@}\fi
60
\count\@ne\@mintone \advance\count\@ne \m@ne
61
\dimen\z@\the\count\@ne\@tonebarhtunit
62
\raise\dimen\z@\hbox{%
63
\@accshift{-\dimen\z@}%
64
{\tipaencoding\char\@tonecode}%
65
\@accshift{\dimen\z@}}}}
67
\newcommand\@toneshift[1]{\dimen\@ne#1}
69
\newcommand\@inittone{%
70
\@getaccshift \let\c@lcshift\@toneshift
71
\let\pr@vtone\relax\let\pr@vpr@vtone\relax
72
\@longtonetrue{\setbox\z@\hbox{\@tonestembar}%
73
\global\@tonebarhtunit.25\ht\z@
74
\global\@tonebarhalfwd.5\wd\z@}}