7 Documents with text that is not in English7.3 Chinese, Japanese, and Korean7.4 Right-to-left writing: Farsi, Hebrew, and Arabic

7.4 Right-to-left writing: Farsi, Hebrew, and Arabic

Scripts with right-to-left writing require some extra care. The main document needs to be processed left-to-right for Ipe to work correctly. Only individual text objects can be translated using right-to-left mode.

Here are solutions that work for Farsi (Persian), Hebrew, and Arabic.

7.4.1 Persian

Include the stylesheet right-to-left.isy from the Ipe stylesheet folder. It defines a text style rtl for right-to-left text objects.

In the document properties (that is, in the Document properties dialog, available on the Edit menu), set Latex engine to xetex, and the Latex preamble to

\usepackage[documentdirection=lefttoright]{xepersian}
\settextfont{FreeFarsi}
I needed to install the packages texlive-lang-arabic and fonts-freefarsi on my Linux system to use this. On a Unix-system, you can determine which fonts on your system support Farsi by saying fc-list :lang=fa on the command line.

It is important to set the option documentdirection=lefttoright for the xepersian package, to make sure the main document is processed in left-to-right mode.

You can now have text objects with Latin script using the normal text style, and text objects with Persian script using the rtl text style.

If you want, you can make rtl the default text style, with the following customization:

prefs.initial_attributes.textstyle = "rtl"

If you do not use the right-to-left.isy stylesheet, then you have to put one more line in the preamble:

\ipedefinecolors{}
\usepackage[documentdirection=lefttoright]{xepersian}
\settextfont{FreeFarsi}
This is necessary, because Ipe normally loads the xcolors package after processing the document preamble. Some packages (like bidi and xepersian) require to be loaded after xcolors, so you need to use \ipedefinecolors{} to load xcolors early. We didn't need this above, because the stylesheet right-to-left.isy already contains the command.

7.4.2 Hebrew

Include the stylesheet right-to-left.isy from the Ipe stylesheet folder. It defines a text style rtl for right-to-left text objects.

In the document properties (that is, in the Document properties dialog, available on the Edit menu), set Latex engine to xetex, and the Latex preamble to

\ipedefinecolors{}
\usepackage{fontspec}
\setmainfont{Liberation Serif}
\setmonofont{Liberation Mono}
\setsansfont{Liberation Sans}
\usepackage{bidi}
I needed to install the package texlive-lang-arabic to use the bidi package. On a Unix-system, you can determine which fonts on your system support Hebrew by saying fc-list :lang=he on the command line.

You can now have text objects with Latin script using the normal text style, and text objects in Hebrew using the rtl text style.

If you want, you can make rtl the default text style, with the following customization:

prefs.initial_attributes.textstyle = "rtl"

7.4.3 Arabic

In the document properties (that is, in the Document properties dialog, available on the Edit menu), set Latex engine to luatex, and the Latex preamble to

\usepackage{arabluatex}

If you don't want to use the standard Amiri font, select another font in the preamble:

\newfontfamily\arabicfont[Script=Arabic]{KacstLetter}
On a Unix-system, you can list the fonts on your system supporting Arabic by saying fc-list :lang=ar on the command line.

You can now create text objects in Arabic using the macro \arb and the environment arab.

The following stylesheet arabic.isy makes this more comfortable:

<ipestyle name="arabic">
<textstyle name="arabic" type="minipage" begin="\begin{arab}" end="\end{arab}"/>
<textstyle name="arabic" type="label" begin="\arb{" end="}"/>
</ipestyle>
If you add this stylesheet to your document, you can select the arabic style for text objects, and directly write in Arabic inside these objects.

If you want, you can make arabic the default text style, with the following customization:

prefs.initial_attributes.textstyle = "arabic"