|  |  | 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. When Ipe writes the Pdflatex source file, it replaces all Unicode characters by a Latex macro, such as `\unichar{44032}` for the Korean syllable "가".

All you need to do is to make sure Pdflatex can process this `\unichar` macro. An easy 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.

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{cyberbit}{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{cyberbit}{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.

|  |  | 12 Unicode text