PDFlib 8 Windows COM/.NET Tutorial
PDFlib 8 Windows COM/.NET Tutorial
PDFlib 8 Windows COM/.NET Tutorial
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
6.4 Complex Script Output<br />
Cookbook A full code sample can be found in the Cookbook topic complex_scripts/starter_shaping.<br />
6.4.1 Complex Scripts<br />
The Latin script basically places one character after the other in left-to-right order. Other<br />
writing systems have additional requirements for correct text output. We refer to<br />
such writing systems as complex scripts. <strong>PDFlib</strong> performs text processing for complex<br />
scripts for a variety of scripts including those listed in Table 6.2.<br />
In this section we will discuss shaping for complex scripts in more detail. While most<br />
Western languages can be written by simply placing one character after the other from<br />
left to right, some writing systems (scripts) require additional processing:<br />
> The Arabic and Hebrew scripts place text from right to left. Mixed text (e.g. Arabic<br />
with a Latin insert) contains both right-to-left and left-to-right segments. These segments<br />
must be reordered, which is referred to as the Bidi (bidirectional) problem.<br />
> Some scripts, especially Arabic, use different character shapes depending on the position<br />
of the character (isolated, beginning/middle/end of a word).<br />
> Mandatory ligatures replace sequences of characters.<br />
> The position of glyphs must be adjusted horizontally and vertically.<br />
> Indic scripts require reordering of some characters, i.e. characters may change their<br />
position in the text.<br />
> Special word break and justification rules apply to some scripts.<br />
Scripts which require one or more of these processing steps are called complex scripts.<br />
The process of preparing incoming logical text for proper presentation is called shaping<br />
(this term also includes reordering and Bidi processing). The user always supplies text<br />
in unshaped form and in logical order, while <strong>PDFlib</strong> performs the necessary shaping before<br />
producing PDF output.<br />
Complex script shaping can be enabled with the shaping text option, which in turn<br />
requires the script option and optionally allows the language option. The following option<br />
list enables Arabic shaping (and Bidi processing):<br />
shaping script=arab<br />
Caveats. Note the following when working with complex script shaping:<br />
> <strong>PDFlib</strong> does not automatically set the shaping and script options, but expects them to<br />
be supplied by the user.<br />
> Script-specific shaping (options shaping, script, language) will only be applied to<br />
glyphs within the same font, but not across glyphs from different fonts. If fallback<br />
fonts are used, shaping will only be applied within text runs which contain text in<br />
the same (master or fallback) font.<br />
> Since shaping may reorder characters in the text, care must be taken regarding attribute<br />
changes within a word. For example, if you use inline options in Textflow to<br />
colorize the second character in a word – what should happen when shaping swaps<br />
the first and second characters? For this reason, formatting changes should only be<br />
applied at word boundaries, but not within words.<br />
6.4 Complex Script Output 163