summaryrefslogtreecommitdiff
path: root/fonts/stoneipa/stoneipa.dtx
blob: 7f07a891e73a47331247f06c60208b99725d5dc7 (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
% \iffalse meta-comment
%
% Copyright (C) 2018 by Leah Grace Velleman
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 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.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% \fi

% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2018/01/01]
%<package>\ProvidesPackage{stoneipa}
%<package> [2018/07/07 v0.8 Stone Sans Phonetic font support] 
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{stoneipa}
\setromanfont[Scale=MatchLowercase]{Cambria}
\setmonofont[Scale=MatchLowercase]{Consolas}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{stoneipa.dtx}
\end{document}
%</driver>
%\fi


% \title{The \textsf{StoneIPA} package}
% \author{Leah Grace Velleman \\ leahvelleman@gmail.com}
% \maketitle
%
% \section{About}
% Stone Sans Phonetic is an excellent IPA font designed by Sumner Stone in the
% 1980s. It harmonizes well with its companions Stone Serif and Stone Sans, and
% also with a number of other popular text fonts.
%
%  It remains commercially available, but in an idiosyncratic
% pre-Unicode encoding. 
%
% This package --- designed for use with XeLaTeX --- sets
% up Stone Sans as the sans-serif document font, and sets up the Unicode
% characters in the IPA range so that they will produce the correct glyphs from
% Stone Sans Phonetic. It does not include the fonts themselves, which must be
% purchased separately.
%
%\begin{figure}
% \sffamily
%\begin{center}
%\begin{tabular}{lllllllllllllllllllll}
%    p & b &   &   &   &   & t & d &   &   & ʈ & ɖ & c & ɟ & k & g & q & ɢ &   & ʔ \\
%    ƥ & ɓ &   &   &   &   & ƭ & ɗ &   &   &   &   & ƈ & ʄ & ƙ & ɠ & ʠ & ʛ \\
%      & m &   & ɱ &   &   &   & n &   &   &   & ɳ &   & ɲ &   & ŋ &   & ɴ \\
%      & ʙ &   &   &   &   &   & r &   &   &   &   &   &   &   &   &   & ʀ \\
%      &   &   &   &   &   &   & ɾ &   &   &   & ɽ \\
%    ɸ & β & f & v & θ & ð & s & z & ʃ & ʒ & ʂ & ʐ & ç & ʝ & x & ɣ & χ & ʁ & ħ ʕ & h ɦ \\
%      &   &   &   &   &   & ɬ & ɮ \\
%      &   &   & ʋ &   &   &   & ɹ &   &   &   & ɻ &   & j &   & ɰ \\
%      &   &   &   &   &   &   & l &   &   &   & ɭ &   & ʎ &   & ʟ\\
%\end{tabular}
%\caption{The IPA consonants in Stone Sans Phonetic}
%\end{center}
%\end{figure}
%\begin{figure}
%\sffamily
%\begin{center}
%\begin{tabular}{llllll}
%            i & y & ɨ & ʉ & ɯ & u \\
%            ɪ & ʏ &   &   &   & ʊ \\
%            e & ø & ɘ & ɵ & ɤ & o \\
%              &   & ə \\
%            ɛ & œ & ɜ & ɞ & ʌ & ɔ \\
%            æ &   & ɐ \\
%            a & ɶ &   &   & ɑ & ɒ\\
%\end{tabular} 
%\caption{The IPA vowels in Stone Sans Phonetic and Stone Sans Phonetic Alternates}
%\end{center}
%\end{figure}
%\begin{figure}
%\sffamily
%\begin{center}
%\begin{tabular}{lllll}
% ƥ & ƭ & ƙ & ʠ & ˀ \\
% š & č & ž \\
% λ & ƛ
%\end{tabular}
%\caption{Non-IPA characters from Stone Sans Phonetic and Stone Sans Phonetic Alternates}
%\end{center}
%\end{figure}
%
%\section{Requirements}
% \textsf{StoneIPA} requires XeLaTeX, \textsf{fontspec}, \textsf{newunicodechar}, and \textsf{pdftexcmds}. It also requires the fonts Stone Sans, Stone Sans Phonetic
% and Stone Sans Phonetic Alternates.
%
%\section{Package options}
% \textsf{StoneIPA} uses your system installed versions of Stone Sans, Stone Sans
% Phonetic, and Stone Sans Phonetic Alternates. By default, it expects these
% fonts to be installed under the names |StoneSans|, |StoneSans-PhoneticIPA|, and
% |StoneSans-PhoneticAlternate|. If yours are installed under different names, 
% specify those names using the |sansfontname|, |phoneticfontname|, and
% |alternatefontname| options.
%
%\begin{verbatim}
%\usepackage[phoneticfontname=StoneSansIPA, 
%            alternatefontname=StoneSansAlt]{stoneipa}
%\end{verbatim}
%
% If some characters appear too small, use the |noalternatescaling| option. As
% of this writing, the version of Stone Sans Phonetic Alternates that is for sale
% on Adobe's website has characters about 10\% too large, and the \textsf{StoneIPA}
% package attempts to compensate for this. The |noalternatescaling| option
% turns off this compensation.
%\begin{verbatim}
%\usepackage[noalternatescaling]{stoneipa}
%\end{verbatim}

% \StopEventually{}
% \section{Implementation}
% \subsection{Option handling}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/06/01]

\RequirePackage{fontspec}
\RequirePackage{newunicodechar}
\RequirePackage{pdftexcmds}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=sipa, prefix=sipa@}
\DeclareStringOption[StoneSans]{fontname}
\DeclareStringOption[StoneSansSCITCTTMedium]{scfontname}
\DeclareStringOption[StoneSans-PhoneticIPA]{phoneticfontname}
\DeclareStringOption[StoneSans-PhoneticAlternate]{alternatefontname}
\DeclareBoolOption{noalternatescaling}
\ProcessKeyvalOptions*
%    \end{macrocode}
% \subsection{Font declarations}
%    \begin{macrocode}
\setsansfont{\sipa@fontname}[Scale=MatchLowercase, 
							 SmallCapsFont=\sipa@scfontname]

\newfontfamily{\sipafont}{\sipa@phoneticfontname}[Scale=MatchLowercase]

\ifsipa@noalternatescaling
    \newfontfamily{\sipaalternatefont}{\sipa@alternatefontname}[Scale=1.0]
\else
    \newfontfamily{\sipaalternatefont}{\sipa@alternatefontname}[Scale=0.9]
\fi
%    \end{macrocode}
% \subsection{Character macros}
% \DescribeMacro{\sipachoosephoneticchar} 
% \DescribeMacro{\sipachoosealternatechar}
% The Stone Sans Phonetic font is weirdly encoded. For instance, a symbol that 
% looks like \textsf{ʷ} is stored at the code point normally used for |+|. This means that
% sometimes, the Unicode in our |.tex| file will need to be translated. For
% instance, if we encounter a \textsf{ʷ} character when the current font family is Roman,
% we can print it as usual; but if we encounter the same character when the
% font family is sans serif, we should translate it to a |+| and print it in
% Stone Sans Phonetic. The |\sipachoosephoneticchar| and |\sipachoosealternatechar|% macros do this conditional translation:
% given two characters, when the current family is sans serif, they print the
% first in Stone Sans Phonetic; and when the current family is anything else,
% they print the second.
%    \begin{macrocode}
\def\sipachoosephoneticchar#1#2{%
    \ifnum\pdf@strcmp{\f@family}{\sfdefault}=\z@
        {\sipafont #1}%
    \else
        #2%
    \fi
}

\def\sipachoosealternatechar#1#2{%
    \ifnum\pdf@strcmp{\f@family}{\sfdefault}=\z@
        {\sipaalternatefont #1}%
    \else
        #2%
    \fi
}
%    \end{macrocode}
% \subsection{Character setup}
% \DescribeMacro{\sipasetup}\DescribeMacro{\sipaalternatesetup}
% Now we define two convenience functions that we will use to set up Unicode
% characters. The macro |\sipasetup#1#2| declares that the Stone Sans Phonetic glyph
% stored at |#1| should be used when the TeX source contains the Unicode character
% |#2|. The macro |\sipaalternatesetup| does the same, but for Stone Sans Phonetic
% Alternates.
%    \begin{macrocode}

\def\sipasetup#1#2{\newunicodechar{#2}{{\sipachoosephoneticchar{#1}{#2}}}}
\def\sipaalternatesetup#1#2{\newunicodechar{#2}{{\sipachoosealternatechar{#1}{#2}}}}

\sipasetup{a\$}{ā}
\sipasetup{e\$}{ē}
\sipasetup{i\$}{ī}
\sipasetup{o\$}{ō}
\sipasetup{u\$}{ū}
\sipasetup{y\$}{ȳ}
\sipasetup{+}{ʷ}
\sipasetup{:}{ː}
\sipasetup{?}{ʔ}
\sipasetup{@}{ə}
\sipasetup{A}{ɑ}
\sipasetup{B}{ʙ}
\sipasetup{C}{ç}
\sipasetup{D}{ð}
\sipasetup{E}{ɛ}
\sipasetup{F}{ɸ}
\sipasetup{G}{ɢ}
\sipasetup{H}{ʜ}
\sipasetup{I}{ɪ}
\sipasetup{J}{ɟ}
%\sipasetup{K}{ɨ}
\sipasetup{L}{ʟ}
\sipasetup{M}{ɰ}
\sipasetup{N}{ɴ}
\sipasetup{O}{ɔ}
\sipasetup{Q}{ɾ}
\sipasetup{R}{ʀ}
\sipasetup{S}{ʃ}
\sipasetup{T}{θ}
\sipasetup{U}{ʊ}
\sipasetup{V}{ʋ}
\sipasetup{W}{ɺ}
\sipasetup{X}{χ}
\sipasetup{Y}{ʏ}
\sipasetup{Z}{ʒ}
\sipasetup{\ }{ʘ}
\sipasetup{\{}{æ}
\sipasetup{®}{ɲ}
\sipasetup{¿}{ʕ}
\sipasetup{Á}{ɒ}
\sipasetup{Â}{β}
\sipasetup{Ã}{ɕ}
\sipasetup{Ä}{ɖ}
\sipasetup{Æ}{ɜ}
\sipasetup{Ç}{ʛ}
\sipasetup{È}{ɦ}
\sipasetup{É}{ħ}
\sipasetup{Ë}{ɬ}
\sipasetup{Ì}{ɮ}
\sipasetup{Í}{ɱ}
\sipasetup{Î}{ŋ}
\sipasetup{Ï}{ɶ}
\sipasetup{Ð}{ɻ}
\sipasetup{Ñ}{ɽ}
\sipasetup{Ò}{ʁ}
\sipasetup{Ô}{ʈ}
\sipasetup{Õ}{ɵ}
\sipasetup{×}{ʄ}
\sipasetup{Ø}{ɧ}
\sipasetup{Ú}{ʑ}
\sipasetup{Þ}{ʢ}
\sipasetup{à}{ɫ}
\sipasetup{á}{ɐ}
\sipasetup{â}{ɓ}
\sipasetup{ã}{ƈ}
\sipasetup{ä}{ɗ}
\sipasetup{å}{ɣ}
\sipasetup{\ae}{ɤ}
\sipasetup{Ç}{ɠ}
\sipasetup{è}{ɥ}
\sipasetup{é}{ɨ}
\sipasetup{ê}{ʝ}
\sipasetup{ë}{ƙ}
\sipasetup{ì}{ɭ}
\sipasetup{í}{ɯ}
\sipasetup{î}{ɳ}
\sipasetup{ï}{ø}
\sipasetup{\dh}{ƥ}
\sipasetup{ñ}{ʠ}
\sipasetup{ò}{ɹ}
\sipasetup{ó}{ʂ}
\sipasetup{ô}{ƭ}
\sipasetup{õ}{ʉ}
\sipasetup{ö}{ʌ}
\sipasetup{÷}{ʍ}
\sipasetup{ù}{ʎ}
\sipasetup{ú}{ʐ}
\sipasetup{û}{œ}
\sipaalternatesetup{?}{ˀ}
\sipaalternatesetup{e}{ɘ}
\sipaalternatesetup{å}{ɞ}
\sipaalternatesetup{c}{č}
\sipaalternatesetup{s}{š}
\sipaalternatesetup{z}{ž}
\sipaalternatesetup{l}{λ}
\sipaalternatesetup{ì}{ƛ}
%    \end{macrocode}
% \Finale