w:rtl (Right-to-Left Text)
Marks a run as right-to-left text, applying RTL character ordering and complex-script shaping.
Parent elements
Description
w:rtl is a toggle property that marks the run as right-to-left text. When active:
- The Unicode Bidi Algorithm is applied with a right-to-left base direction for the run.
- Complex-script font and size properties (
w:rFonts w:cs,w:szCs,w:bCs,w:iCs) are used instead of their Latin counterparts. - Character ordering within the run follows RTL conventions.
It is defined in ECMA-376 Part 1 §17.3.2.30.
Note that w:rtl affects the run, while w:bidi on w:pPr affects the paragraph’s base direction.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_OnOff |
true, false, 1, 0, on, off |
Sets run direction to RTL. Omit to inherit. |
Examples
<!-- Hebrew run inside a left-to-right paragraph -->
<w:r>
<w:rPr>
<w:rtl/>
<w:rFonts w:cs="David"/>
</w:rPr>
<w:t>שלום עולם</w:t>
</w:r>
using DocumentFormat.OpenXml.Wordprocessing;
var run = new Run(
new RunProperties(
new RightToLeftText(),
new RunFonts { ComplexScript = "David" }
),
new Text("שלום עולם")
);
Notes
- Use together with
w:bidionw:pPrfor a fully RTL paragraph. - The Unicode Bidi Algorithm still resolves the visual order of mixed-direction text within runs.
w:rtl w:val="false"explicitly sets a run to LTR, useful when overriding an inherited RTL style.