Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

fontspec and tipa inside macros

42 views
Skip to first unread message

Pavel Iosad

unread,
Jan 26, 2009, 4:28:00 AM1/26/09
to
Hello,

It seems I have a problem with fontspec commands inside macros (this
is obviously a XeLaTeX question). What I want to do is create a macro
to change the font to the one that I use for IPA, and then use the
\textipa{} command to enable entering IPA symbols thorugh tipa
shortcuts. It is possible with a fontspec declaration in running text,
but if I try to issue the command inside the macro, it breaks: the
font changes, but the IPA shortcuts don't work. Here is an example (I
use \newfontfamily for brevity, it makes no difference if I use the
explicit \fontspec command).

%%% START EXAMPLE %%%

\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setromanfont[Mapping=tex-text]{Latin Modern Roman}
\usepackage{tipa}
\newfontfamily\ipafont[Mapping=tex-text]{Charis SIL}
\newcommand{\ipa}[1]{\ipafont\textipa{#1}}
\begin{document}

Some text in Latin Modern

\ipa{Ekspl@''neIS@n}

\rmfamily More text in Latin Modern

\ipafont\textipa{Ekspl@''neIS@n}

\end{document}

%%% END EXAMPLE %%%

Thanks in advance!

Pavel

Gareth Hughes

unread,
Jan 26, 2009, 9:08:51 PM1/26/09
to

Hi Pavel!

I think there a few things going on here. TIPA is mostly, but not
entirely, compatible with XeLaTeX. TIPA is designed to work with its own
fonts. I'm not sure if the issues are with fontenc.sty. I notice that
\newcommand{\ipa}[1]{\textipa{#1}} does not render the IPA symbols. This
is why your \ipafont\textipa works, but
\newcommand{\ipa}[1]{\ipafont\textipa{#1}} doesn't.

The real XeTeX answer is to have the correct IPA symbols in your input
rather than use TIPA's ASCII rendering. Simply use an IPA virtual
keyboard, and you can use any font that has the symbols. This would
require fewer macros, and would make your source file more readable. If
you still want to use TIPA, you might want to use the fonts that come
with the package. You should be able to scale them to your default font
using something like \defaultfontfeatures{Scale=MatchLowercase}. I
notice that \tipaencoding produces the correct secondary stress, where
\textipa incorrectly doubles primary-stress marks.

Gareth.

Pavel Iosad

unread,
Jan 27, 2009, 12:14:43 PM1/27/09
to
Hi,

On Jan 27, 3:08 am, Gareth Hughes <gar...@garzo.co.uk> wrote:
> I think there a few things going on here. TIPA is mostly, but not
> entirely, compatible with XeLaTeX. TIPA is designed to work with its own
> fonts. I'm not sure if the issues are with fontenc.sty. I notice that
> \newcommand{\ipa}[1]{\textipa{#1}} does not render the IPA symbols. This
> is why your \ipafont\textipa works, but
> \newcommand{\ipa}[1]{\ipafont\textipa{#1}} doesn't.

Yes, I noticed that too; it's part of the question...

> The real XeTeX answer is to have the correct IPA symbols in your input
> rather than use TIPA's ASCII rendering.

I understand that, of course, but I would really like to try and fix
the tipa thing, for several reasons such as backwards compatibility
(not to mention the fact that monospace fonts with full IPA support
through Unicode aren't exactly a dime a dozen, and you need one for
the editor).

> If you still want to use TIPA, you might want to use the fonts that come
> with the package. You should be able to scale them to your default font
> using something like \defaultfontfeatures{Scale=MatchLowercase}.

Well, first, I'm not quite sure how one could do that (I'm only a
newbie in XeLaTeX-related things...); second, the whole point of this
thing is to get access to the IPA in typefaces other than the Computer
Modern, Times, Courier and Helvetica provided by tipa itself; e. g. if
I were to use a Palatino-like font in the text, Gentium for the IPA
would go much better with it than either of those. If I wanted IPA
symbols in Times or something, I'd just stick with good ol' LaTeX.

Pavel

Alan Munn

unread,
Jan 27, 2009, 2:19:55 PM1/27/09
to
In article
<a6c61c0c-894d-41c0...@k1g2000prb.googlegroups.com>,
Pavel Iosad <edri...@gmail.com> wrote:

Hi Pavel, there is, I think, a somewhat tedious solution to your
problem, but it would involve making a new mapping file for fontspec to
use. This would map the T3 encoding that TIPA uses into the appropriate
unicode characters.

Here's a basic outline of what you would need to do (this was something
I posted on the ling-tex mailing list a while ago:)

Fonts in XeTeX are accessed using the fontspec package. One of the
things that it allows one to do is use a particular mapping file for the
font, which essentially is a set of instructions that map one character
or string of characters into the correct unicode character for the font.
The map files are created by compiling a text file of the mapping into a
.tec file that can be read by xetex. This is done by installing the
TECkit software from SIL.

A quick test shows that it would be possible (and relatively easy,
though tedious) to create a mapping file to map TIPA input into the
correct unicode characters. Here is a small sample of what the mapping
file looks like:

; Sample TIPA to UNICODE mapping file for XeTeX
; TIPA-text.map
;
; the left hand side can be a string of U+xxxx separated by spaces (for
example to get \ae encoded.
LHSName "TIPA-text"
RHSName "UNICODE"

pass(Unicode)

U+0045 <> U+025B ; E -> open E
U+0040 <> U+0259 ; @ -> schwa
U+0049 <> U+026A ; lax I

This file is a text file that gets compiled with teckit_compile (in Unix
flavours (Mac OS X or linux) the command is (there's also a .EXE file
for windows use).

teckit_compile TIPA-text.map -o TIPA-text.tec

I put these files in my local texmf tree under fonts/misc/xetex

Then I created a unicode encoded file to use with xelatex:

Notice that this file does NOT call TIPA; the whole point is to map the
TIPA input into Doulos SIL using the font mapping.

\documentclass[11pt]{article}
\usepackage{xltxtra}
\newenvironment{IPA}{\fontspec[Mapping=TIPA-text]{Doulos SIL}}{}
\setmainfont{Doulos SIL}
\begin{document}

\begin{IPA}s@m f@nEtiks\end{IPA}
\end{document}

You wouldn't need to create a map file for the whole TIPA, but you would
need to get a translation for each TIPA glyph you use.

Also, it would be easiest if all your TIPA input was in the IPA
environment rather than the other forms allowed by TIPA, since this
would allow the redefinition of IPA as I have done in the example.

Hopefully this gives you enough to get you going. It's actually not as
intractable a problem as I first thought, and in fact, creating a full
TIPA-text map file would be a worthwhile endeavour...

Alan

Pavel Iosad

unread,
Jan 27, 2009, 5:31:48 PM1/27/09
to
Hi,

On Jan 27, 8:19 pm, Alan Munn <am...@msu.edu> wrote:

> Hi Pavel, there is, I think, a somewhat tedious solution to your
> problem, but it would involve making a new mapping file for fontspec to
> use.  This would map the T3 encoding that TIPA uses into the appropriate
> unicode characters.

I see.

> Here's a basic outline of what you would need to do (this was something
> I posted on the ling-tex mailing list a while ago:)

Serves me right for searching Google instead of my email :). Must've
missed that.

> Fonts in XeTeX are accessed using the fontspec package.

[skip instructions]

> Notice that this file does NOT call TIPA; the whole point is to map the
> TIPA input into Doulos SIL using the font mapping.

Makes sense.

> You wouldn't need to create a map file for the whole TIPA, but you would
> need to get a translation for each TIPA glyph you use.

Well, once you start, why not go to the end :)

> Also, it would be easiest if all your TIPA input was in the IPA
> environment rather than the other forms allowed by TIPA, since this
> would allow the redefinition of IPA as I have done in the example.

Here's the other thing I don't get. Why doesn't \newcommand\ipa[1]
{\textipa{#1}} work in XeLaTeX? (Again, it's a largely a question of
backwards compatibility for me, since that it the way I have invoked
tipa in several years' worth of work...)

> Hopefully this gives you enough to get you going. It's actually not as
> intractable a problem as I first thought, and in fact, creating a full
> TIPA-text map file would be a worthwhile endeavour...

Thanks! That's a great help. I'm sure there are pitfalls around; say,
\textramshorns and \textbabygamma are both U+0264, and a font like
Charis SIL uses the advanced font features to select either of those,
not different codepoints. But it seems quite doable, and given that
I'll be on leave from April, something worth doing, I guess :).

Thanks again!

Pavel

0 new messages