|  |  | 12 Unicode text

# 12 Unicode text

If you make figures containing text objects in languages other 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 is 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 `\unichar{44032}` for the Korean syllable "가". 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 `\unichar` macro to the right glyph in this font.

Follow the instructions on my webpage to declare a Truetype font to be used for Unicode characters in the document. We first test it "manually", by running Pdflatex on this test file:

    % File 'unitest.tex'
    \documentclass{article}
    \usepackage{ttfucs}
    \DeclareTruetypeFont{cyberb}
    \begin{document}
    Here is a character from Cyberbit: \unichar{44032}.
    \end{document}

Assuming this works fine, we can now try to use the font from Ipe. All you need to do is to add the following stylesheet to your document:

    <ipestyle name="cyberbit">
    <cmap font="cyberb"/>
    <preamble>
    \usepackage{ttfucs}
    \DeclareTruetypeFont{cyberb}
    </preamble>
    </ipestyle>

Unicode characters entered from the Ipe user interface should now be displayed correctly. Note the use of the `<cmap>` tag: it tells Ipe to add a Unicode character map to the LaTeX fonts declared by `\DeclareTruetypeFont{cyberb}`. When saving as PDF, this ensures that Unicode text in the PDF file can be interpreted by the viewer application (that is, you can select it and paste it into, say, a text editor).

You can use more than one TTF font, and add several `\DeclareTruetypeFont` 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 `\TruetypeFont` command defined in the `ttfucs` package.

You can also mix this strategy with using the `ucs` package--the command `\ucsfamily` will switch to using `ucs`, until you switch back to using a Truetype font by saying `\TruetypeFont`.

|  |  | 12 Unicode text