openSUSE / suse-xsl

DocBook XSL Stylesheets for SUSE branding
Other
11 stars 10 forks source link

Arabic: FOP 1.1 does not like Amiri and is buggy with mixed Arabic/Latin text #76

Open ghost opened 9 years ago

ghost commented 9 years ago

Amiri seems like a pretty nice font for Arabic, because it

For whatever reason, however, FOP will not work correctly with Amiri, and produces ligature-free Arabic content (i.e. letters are not joined and instead have gaps between them). This sort of output cannot be used.

Using e.g. Droid Arabic Naskh, documents get proper ligatures (letters are joined and the gaps are between words). However, Droid Arabic Naskh does not include Latin letters.

This could be worked around with the a font-family setting like font-family="'Arabic Font', 'Latin Font'". But then FOP creates output that looks like this:

Arabic text
           Latin text that should be on the same line

Not helpful.

Wrapping all Latin letters, Western numbers and punctuation in <fo:inline font-family="'Latin Font'"/> seems to work around this issue. However, from my limited testing, it seems to create line breaks in unexpected places. (Will need to check again.) Doing this may actually be feasible... given the fact that we only need to replace [a-zA-Z0-9], maybe [äöüßÄÖÜ] and punctuation [.,-=] etc.

Another avenue might be Droid Naskh Shift Alt which combines a Naskh (=Arabic ~serif) typeface with a Western sans-serif (Droid Sans). If this font proves to be available enough, it might just be the way to go. However, like most Arabic fonts, it does not offer bold/italic versions.

Testing...

A very simple FO document containing some Arabic text:

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="'Droid Naskh Shift Alt', serif" direction="left" line-height="1.3em" text-align="right">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="A4-portrait"
              page-height="29.7cm" page-width="21.0cm" margin="2cm">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="A4-portrait">
        <fo:flow flow-name="xsl-region-body">
          <fo:block script="arab">
البداية السريعة للتثبي
SUSE Linux Enterpriseبنجاح في مركز عملاء SUSE, فسيُطلب منك تثبيت آخر التحديثات المتوفرة على الإنترنت أثناء التثبيت. في حالة تحديد نعم، سيتم تثبيت النظام بأحدث الحزم دون الحاجة لتطبيق التحديثات بعد التثبيت. يُوصى بتنشيط هذا الخيار.الالعثور على الأنظمة الأخرى المثبتة. إذا تعذر تكوين الشبكة تلقائيًا عند بدء نظام التثبيت، يظهر حواربداية السريعة للتثبييعرض متطلباتالنظام ويرشدك خطوة بخطوة خلال تثبيت
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>

Use fop input.fo output.pdf to transform. No other options necessary.

tomschr commented 2 years ago

Needs to be check with recent version of FOP.