Difference between revisions of "RTL"
Jump to navigation
Jump to search
(Basic usage of setupalign) |
(Farsi text with (LTR) number) |
||
Line 2: | Line 2: | ||
== Basics == | == Basics == | ||
− | Use {{cmd|setupalign}} to change the text direction to RTL. | + | Use {{cmd|setupalign}} to change the text direction to RTL. This command sets the page, paragraph and text directions. |
<context source=yes mode=mkiv text="This produces:"> | <context source=yes mode=mkiv text="This produces:"> | ||
− | |||
\setupalign[r2l] | \setupalign[r2l] | ||
\starttext | \starttext | ||
\input knuth | \input knuth | ||
\stoptext | \stoptext | ||
+ | </context> | ||
+ | |||
+ | === BiDi text === | ||
+ | To work with documents with mixed RTL and LTR text, we need the bidi algorithm implemented in {{cmd|setupdirections}}. Since numbers are LTR elements in Arabic, Persian and other RTL languages, we almost always need this. | ||
+ | <context source=yes mode=mkiv text="This produces:"> | ||
+ | % mode=mkiv | ||
+ | \usemodule[simplefonts] | ||
+ | \setmainfont[ALM Fixed][features=arabic,range=arabic] | ||
+ | \setcharacterstripping[1] % don't show ZWNJ, etc. | ||
+ | \setupdirections[bidi=global,method=one] | ||
+ | \setupalign[r2l] | ||
+ | \starttext | ||
+ | این نمونه ساده از متنی فارسی است که در \CONTEXT\ تهیه شده است. | ||
+ | توجه کنید که عدد ۱۰۰۰ به صورت صحیح نمایش داده میشود. | ||
</context> | </context> |
Revision as of 04:29, 27 January 2016
Here we collect several tips and tricks for dealing with right-to-left (RTL) texts as well as BiDi (bidirectional) texts. The large number of hooks in different commands makes it possible to use CONTEXT's support for such documents. However, there are limitations and/or bugs, as well.
Basics
Use \setupalign to change the text direction to RTL. This command sets the page, paragraph and text directions.
\setupalign[r2l] \starttext \input knuth \stoptext
This produces:
BiDi text
To work with documents with mixed RTL and LTR text, we need the bidi algorithm implemented in \setupdirections. Since numbers are LTR elements in Arabic, Persian and other RTL languages, we almost always need this.
% mode=mkiv \usemodule[simplefonts] \setmainfont[ALM Fixed][features=arabic,range=arabic] \setcharacterstripping[1] % don't show ZWNJ, etc. \setupdirections[bidi=global,method=one] \setupalign[r2l] \starttext این نمونه ساده از متنی فارسی است که در \CONTEXT\ تهیه شده است. توجه کنید که عدد ۱۰۰۰ به صورت صحیح نمایش داده میشود.
This produces:
internal error: copy error CFlraA/cropped.pdf