![]() | ![]() | ![]() | 11 Unicode text |
If you make figures containing text objects in other languages than
English, you will need to enter accented characters, or characters
from other scripts such as Greek, Hangul, Kana, or Chinese characters.
Of course you can still use the LaTeX syntax K\"onig
to enter the
German word "König", but for larger runs of text it's more
convenient to exploit the fact that the Ipe user interface (thanks to
the Qt toolkit) is Unicode-aware, and let's you enter text in any
script supported by your system.
However, the Unicode text also has to be processed by Pdflatex. The easiest solution, sufficient for German, French, and other languages for which support is already in a standard LaTeX-setup, is to add the line
\usepackage{ucs}in your Latex preamble (set in the Document properties dialog, available on the Edit menu). You will need to install the ucs package for Latex by Dominique Unruh, if it not yet on your system.
For more complicated needs, you'll need to read further. When Ipe
writes the Pdflatex source file, it replaces all Unicode characters by
a Latex macro, such as \Ipechar{44032}
for the Korean syllable
"ga". It also adds a macro declaration at the beginning of the
document which defines \Ipechar{44032}
to expand
to \unichar{44032}
. The ucs
package
implements \unichar
for many scripts, including Chinese,
Japanese, and Korean. See the ucs
documentation to set this up
and for the options you need to use.
If you have Truetype (TTF) fonts that include the scripts you wish to
use in your Ipe document, there is an alternative solution. You can
set up Pdflatex to directly map the \Ipechar
macro to the right
character in the font and so you don't need to install the ucs
package for this.
Here follow instructions, using the Truetype font cyberbit.ttf
as an example. The instructions should work for any font that
includes a Unicode character map. You will need version 1.5 of the
ttf2tfm
tool, supporting the -w
option.11 We assume
familiarity with the explanations of Section 10
about finding the Pdftex configuration file and adding files to your
LaTeX installation.
Create a new directory (we'll generate plenty of new files) and copy cyberbit.ttf into it. Also copy the file Unicode.sfd into the current directory, and issue the command:
ttf2tfm cyberbit.ttf -w cyberb@Unicode@This will generate a large number of .enc and .tfm files. Move the font and these files to the appropriate place on your system.
We now need a font map file to tell Pdflatex about the cyberbit font. Add a line
map +cyberb.mapto your pdftex.cfg. The contents of cyberb.map is as follows:
cyberb00 <cyberbit.ttf <cyberb00.enc ... cyberbff <cyberbit.ttf <cyberbff.encThe map file needs to contain one line for each cyberbXX.tfm file that has been created before. (In my case, there are 165 lines.)
Finally, we need a LaTeX package cyberbit.sty for using the font. It could look like this:
%% %% Package 'cyberbit' to use the cyberbit.ttf font %% \ProvidesPackage{cyberbit}[2003/03/05 v1.0 Using font 'cyberbit.ttf'] \RequirePackage{ttfucs} % The command \cyberbitfamily selects the cyberbit font % for Unicode characters. \newcommand{\cyberbitfamily}{% \renewcommand{\Ipe@family}{cyberb}% \renewcommand{\Ipechar}[1]{\IpeTTFchar{##1}}} % The command \ucsfamily lets Unicode characters be processed by % the 'ucs' package. \providecommand{\ucsfamily}{% \renewcommand{\Ipechar}[1]{\unichar{##1}}} % Make 'cyberbit' the default. \cyberbitfamily % The font encoding 'C70' is originally defined by the CJK package. \DeclareFontEncoding{C70}{}{} \DeclareFontSubstitution{C70}{cyberb}{m}{n} % Finally, the Cyberbit font declarations. \DeclareFontFamily{C70}{cyberb}{\hyphenchar \font\m@ne} \DeclareFontShape{C70}{cyberb}{m}{n}{<-> IpeUnicode * cyberb}{} %%\DeclareFontShape{C70}{cyberb}{bx}{n}{<-> CJKb * cyberb}{\CJKbold} %% --------------------------------------------------------------------You will also need to install ttfucs.sty, the package it refers to.
We first test it "manually", by running Pdflatex on this test file:
% File 'ctest.tex' \documentclass{article} \newcommand{\Ipechar}[2]{} \usepackage{cyberbit} \title{Using the Cyberbit font} \author{Otfried Cheong} \begin{document} \maketitle Here are some characters from Cyberbit: \Ipechar{ac00}{44032}. \end{document}
Assuming it works fine from the command line, we can now use the font from Ipe. All you need to do is add the line
\usepackage{cyberbit}in the Latex preamble. Unicode characters entered from the Ipe user interface should now be displayed correctly.
You can create style files for more than one TTF font, and add several
such \usepackage
declarations to the Latex preamble of your Ipe
document. The last package determines the standard font for Unicode
characters. To select a different Unicode font, use the
\cyberbitfamily
command defined in the package.
You can also mix this strategy with using the ucs
package--the
command \ucsfamily
will switch to using ucs
.
![]() | ![]() | ![]() | 11 Unicode text |