<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE abiword PUBLIC "-//ABISOURCE//DTD AWML 1.0 Strict//EN" "http://www.abisource.com/awml.dtd">
<abiword template="false" fileformat="1.1" xmlns="http://www.abisource.com/awml.dtd" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:svg="http://www.w3.org/2000/svg" xml:space="preserve" xmlns:awml="http://www.abisource.com/awml.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="http://www.w3.org/1999/XSL/Format" props="lang:en-GB; dom-dir:ltr">
<!-- =====================================================================  -->
<!-- This file is an AbiWord document.                                      -->
<!-- AbiWord is a free, Open Source word processor.                         -->
<!-- More information about AbiWord is available at http://www.abisource.com     -->
<!-- You should not edit this file by hand.                                 -->
<!-- =====================================================================  -->

<metadata>
<m key="dc.format">application/x-abiword</m>
<m key="abiword.generator">AbiWord</m>
<m key="abiword.date_last_changed">Thu Jul 10 20:31:37 2003</m>
</metadata>
<styles>
<s type="P" name="Heading 1" basedon="Normal" followedby="Normal" props="keep-with-next:1; margin-top:22pt; font-weight:bold; margin-bottom:3pt; font-family:Arial; font-size:17pt"/>
<s type="P" name="Normal" basedon="" followedby="Current Settings" props="font-family:Times New Roman; margin-top:0pt; font-variant:normal; margin-left:0pt; text-indent:0in; widows:2; font-style:normal; font-weight:normal; text-decoration:none; dom-dir:ltr; color:000000; line-height:1.0; text-align:left; margin-bottom:6pt; text-position:normal; margin-right:0pt; bgcolor:transparent; font-size:12pt; font-stretch:normal"/>
<s type="P" name="Heading 2" basedon="Normal" followedby="Normal" props="keep-with-next:1; margin-top:22pt; font-weight:bold; margin-bottom:3pt; font-family:Arial; font-size:14pt"/>
<s type="P" name="Heading 3" basedon="Normal" followedby="Normal" props="keep-with-next:1; margin-top:22pt; font-weight:bold; margin-bottom:3pt; font-family:Arial; font-size:12pt"/>
<s followedby="Normal" name="Heading 4" basedon="Normal" type="P" props="font-weight:normal; font-family:Arial; margin-top:6pt; font-style:normal; margin-left:0pt; text-align:left; text-decoration:none; text-indent:0in; margin-bottom:3pt; bgcolor:transparent; margin-right:0pt; color:000000; font-variant:normal; line-height:1.0; font-size:12pt; font-stretch:normal"/>
</styles>
<pagesize pagetype="Letter" orientation="portrait" width="8.500000" height="11.000000" units="in" page-scale="1.000000"/>
<section>
<p style="Heading 1"><c props="lang:en-GB">Bidirectional Wordprocessing With AbiWord</c><c props="lang:en-GB"></c></p>
<p style="Normal">May 2, 2003</p>
<p style="Normal"><c props="lang:en-GB">Tomas Frydrych &lt;</c><c props="lang:en-GB"></c><a xlink:href="mailto:tomas@frydrych.uklinux.net"><c props="lang:en-GB">tomas@frydrych.uklinux.net</c></a><c props="lang:en-GB">&gt;</c></p>
<p style="Heading 2">Contents</p>
<p style="Normal"><a xlink:href="#intro"><c props="font-weight:bold">Introduction</c><c props="font-weight:bold"></c></a></p>
<p style="Normal" props="margin-bottom:0pt"><a xlink:href="#bidi_control"><c props="font-weight:bold">Controlling Bidirectional Ordering</c><c props="font-weight:bold"></c></a></p>
<p style="Normal" props="text-indent:0.0000in; margin-bottom:0pt; margin-left:0.5000in"><a xlink:href="#dom-dir">Dominant Direction of Text</a></p>
<p style="Normal" props="text-indent:0.0000in; margin-bottom:0pt; margin-left:0.5000in"><a xlink:href="#overrides">Explicit Direction Overrides</a></p>
<p style="Normal" props="text-indent:0.0000in; margin-left:0.5000in"><a xlink:href="#markers">Direction Markers</a></p>
<p style="Normal"><a xlink:href="#shaping"><c props="font-weight:bold">Glyph Shaping</c><c props="font-weight:bold"></c></a></p>
<p style="Heading 2"><bookmark type="start" name="intro"/><bookmark type="end" name="intro"/><c props="lang:en-GB">Introduction</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">Some languages, such as English, are written from left to right, while other languages, such as Arabic, from right to left. AbiWord can handle both directions of text, as well as their combinations -- AbiWord is a bidirectional wordprocessor. </c><c props="lang:en-GB"></c></p>
<p style="Heading 2"><bookmark type="start" name="bidi_control"/><bookmark type="end" name="bidi_control"/><c props="lang:en-GB">Controlling Bidirectional Ordering</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">The bidirectional ordering of text in AbiWord is done closely following the Unicode Bidirectional Algorithm, which means that most of it is done automatically without the user's intervention. At the same time, the user has at his or her disposal three basic mechanisms that allow him or her to fine-tune the results. These are </c><c props="lang:en-GB"></c><c props="font-style:italic; lang:en-GB">specifying dominant direction of text</c>, <c props="font-style:italic">overriding implicit directional properties of characters</c>, and <c props="font-style:italic">inserting direction markers</c>.</p>
<p style="Heading 3"><bookmark type="start" name="dom-dir"/><bookmark type="end" name="dom-dir"/>Dominant Direction of Text</p>
<p style="Normal">The same sequence of characters with different directional properties will look differently if it is assumed to be basically an left-to-right text with right-to-left text embedded, in it, or  if it is understood to be basically a right-to-left text with left-to-right text emebedded. In  AbiWord we refer to the basic direciton of text as the <c props="font-style:italic">dominant direction</c><c props="font-style:italic"></c> (in the the Unicode documentation it is known as the base embedding lev<c props="font-style:italic">el).</c></p>
<p props="font-style:italic"><c props="font-style:italic">The dominant di</c><c props="font-style:italic"></c>rection in AbiWord operates on four hierarchical levels, <c props="font-style:italic">paragraph</c>, <c props="font-style:italic">section</c>, <c props="font-style:italic">document</c>, and <c props="font-style:italic">the program</c>, all of which are controlled by the user.</p>
<p style="Heading 4">Paragraph-Level Dominant Direction</p>
<p style="Normal">The paragraph-level dominant direction can be set either by the  <c props="font-style:italic">Right-to-left</c><c props="font-style:italic"></c><c props="font-style:normal"> dominant check box in the Format-&gt;Paragraph dialogue, or by using the equivalent button on the Extra toolbar. If the dominant direction is not set explicitly by the user, AbiWord will work it out from  the rest of the dominant direction hierarchy, i.e., it will check if dominant direction is set explicitly for the section in which the  paragraph is located, and if not, it will check the document level settings, finally resorting to program-level defaults.</c></p>
<p style="Heading 4">Section-Level Dominant Direction</p>
<p style="Normal">The section-level dominant direction is controlled by the <c props="font-style:italic">Use RTL order</c><c props="font-style:italic"></c> check box of the Format-&gt;Columns dialogue. Apart from providing a default for any of the section paragraphs that do not have their dominant direction set explicitly, the section dominant direction controls how columns in multicolumn sections are ordered, it determines the dominant direction of text of footnotes inserted into the section, and the order of columns in tables. If section-level dominant direction is not given, AbiWord will derive it from the rest of the dominant direction hierarchy as described earlier.</p>
<p style="Heading 4">Document-Level Dominant Direction</p>
<p style="Normal">The document-level dominant direction is controlled from  the Other tab of the Format-&gt;Document dialogue. It provides default dominant direction for all paragraphs and sections in the document that do not have explicit dominant direction set.</p>
<p style="Heading 4">Program-Level Dominant Direction</p>
<p style="Normal">The program-level value of dominant direction is hard-coded at compile time and it is the  value to which AbiWord recourses if everything else fails. It is set to left-to-right unless the  right-to-left is explicitly specified when the program is built.</p>
<p style="Heading 3"><bookmark type="start" name="overrides"/><bookmark type="end" name="overrides"/>Explicit Direction Overrides</p>
<p style="Normal">In the Unicode character set each character is assigned certain directional properties which are then used by the Unicode Bidirectional Algorithm to order text. Thus, Hebrew or Arabic characters will automatically be treated as right-to-left, and English characters as left-to-right. In some circumstances, however, the user might require that characters are treated differently. In this case, AbiWord allows the user to specify that certain characters should be treated as left-to-right or right-to-left. This is done by selecting the characters in question and then applying the override using the  and  buttons.</p>
<p style="Heading 3"><bookmark type="start" name="markers"/><bookmark type="end" name="markers"/>Direction Markers</p>
<p style="Normal">In the Unicode character set there are two special characters called direction markers,  LRM (left to right direction marker) and RLM (right to left direction marker). When a Unicode text is  reordered these characters behave as normal left-to-right and right-to-left characters, but when the text is displayed they are not shown. Their purpose is to allow small adjustments of the bidirectional order, particularly in combination with characters the direction of which depends on what precedes them and follows them. For example if a formula such as <c props="font-style:italic">log(x)</c><c props="font-style:italic"></c> is embeded into a right to left text (represented here by capital letters), it will look like this:</p>
<p style="Normal" props="text-align:right">	GFE (log(x CBA</p>
<p style="Normal">i.e., the closing parenthesis of the formula will be treated as an right-to-left character; this is a feature of the Unicode Bidirectional Algorithm. If the order the user wants is:</p>
<p style="Normal" props="text-align:right">GFE log(x) CBA</p>
<p style="Normal">it can be achieved by following the closing parenthesis with the LRM marker; the LRM and RLM markers are assigned to keyboard shortcuts Alt+Ctrl+&gt; and Alt+Ctrl+&lt; respectively.</p>
<p style="Normal">The same result could, of course, be achieved by selecting the closing parenthesis and applying to it and explicit left-to-right override as described in the previous section. However, in simple situations like in this example, where only the direction of a single character needs to be altered, the direction markers provide a more convenient mechanism.<c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">Another situation in which such markers come handy, is with phone numbers. For instance, if the  phone number 123 456 789 is embedded into a right-to-left text, it will look like this:</c><c props="lang:en-GB"></c></p>
<p style="Normal" props="text-align:right; dom-dir:ltr"><c props="lang:en-GB"> FED 789 456 123 CBA</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">This is because the space between the three groups of numbers behaves as a right-to-left character. If what the user wants is</c><c props="lang:en-GB"></c></p>
<p style="Normal" props="text-align:right"><c props="lang:en-GB">FED 123 456 789 CBA</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB">all that is requires is that the LRM character is inserted just before typing in the first digit.</c><c props="lang:en-GB"></c></p>
<p style="Normal"><c props="lang:en-GB"></c>In certain circumstances AbiWord is capable of inserting these direction markers automatically  based on the keyboard layout used (this is currently only supported under Windows). In order for this work, the user needs to first of all make sure that the option to change language when changing keyboard layout is turned on (Tools-&gt;Preferences-&gt;Language-&gt;Change Language When Changing Keyboard), and that also the bidirectional option <c props="font-style:italic">auto-insert direction markers</c> is turned on (Tools-&gt;Preferences-&gt;Language-&gt;). AbiWord will then follow all ), ], and } characters with a direction marker derived from the language applied to that character. For instance, if a ) character is set as being in Hebrew, it will be followed by a RLM marker but if it is set as being in English, it will be followed by a LRM marker. Similarly, it will precede all (, [, and { characters with a direction marker.</p>
<p style="Heading 2"><bookmark type="start" name="shaping"/><bookmark type="end" name="shaping"/>Glyph Shaping</p>
<p style="Normal">Closely related to AbiWord's bidirectional capabilities is its ability to  change visual appearance of certain glyphs depending on their context. This is essential for languages that use scripted alphabets, such as Arabic, in which each letter has up to four different shapes depending whether it stands alone, or at the beginning, in the middle or at the end of a word. Alongside this type of glyph shaping, AbiWord can also replace a sequence of two glyphs with a special ligature glyph where needed.</p>
<p style="Normal">It should be noted that at present AbiWord uses  a proprietary shaping engine of fairly limited capabilities, and that the shaping can only be done for languages for which the alternative glyph shapes have code points assigned in the Unicode character set (such as Arabic) but not for languages that rely solely on advanced font technologies for shaping (such as Syriac). Furthermore, AbiWord does not check  whether the alternative glyph exists in the current font. This means that if the glyph shaping is turned on and the glyph is not found in the font, you will see a square or a circle in its place. In other words, glyph shaping will only work with proper fonts (the core MS TTF fonts <c props="font-style:italic">Times New Roman </c><c props="font-style:italic"></c>and <c props="font-style:italic">Arial</c> have a reasonable Unicode coverage, and there are other TTF Unicode based fonts available). In future the proprietary shaping engine will be replace with a more powerful third-party library, possibly Pango.</p>
<p style="Normal">An important thing to understand about the glyph shaping is that the the changes only take place in the visual plain, the characters that are contained in the document do not change in the process.</p>
<p style="Normal">Glyph shaping is controlled from the Language tab of the Tools-&gt;Preference dialogue. There are two check boxes there: <c props="font-style:italic">Determine glyph shapes from context</c><c props="font-style:italic"></c> and <c props="font-style:italic">Use glyph shaping for Hebrew</c>. The former of these is the master-switch that turns the glyph shaping engine on and off. When the second check box is checked, the shaping engine will shape also the five Hebrew letters that have a final form. <c props="font-weight:bold">Please note that this is not intended to be used for writing modern Hebrew and Yiddish documents</c>, since in modern Hebrew and Yiddish the final forms are considered different characters (and because as I have explained above the shaping does not change the characters in a document, if nothing else, your spell-checker will not work).</p>
</section>
</abiword>

