Skip to content

Bidirectional text

Store text in logical reading order. Let the layout engine display right-to-left and left-to-right runs. Never reverse characters to make a screenshot look right.

An Arabic or Hebrew sentence can contain a Latin product name, an extension, a version, or a path. The surrounding direction can move punctuation or reorder adjacent runs. Check the whole sentence, not just each translated word.

Keep a phrase together

In HTML, mark the base direction of the document or containing block. Tightly wrap an opposite-direction phrase and give it its own direction. When the inserted text’s direction is unknown, use an isolated element such as bdi, which defaults to automatic direction detection.

<p lang="ar" dir="rtl">
  الملف: <bdi dir="ltr">Sample-2.otf</bdi>
</p>

This example labels a filename in Arabic and isolates the literal filename. It is an HTML example, not a FontLab API or a translated product string.

Use markup when it is available. Plain-text formats may require Unicode directional isolates instead; document that decision so invisible controls are not mistaken for accidental characters. Preserve the underlying identifier when preparing a copyable command or filename.

Review the difficult cases

  • A filename ending in a number or extension, followed by punctuation.
  • A quoted product name inside an opposite-direction sentence.
  • Two adjacent names with different directions.
  • Parentheses, a minus sign, a currency amount, and a version number.
  • Empty and unexpectedly long substituted values.
  • Selection and copy/paste: the copied text must retain the intended logical sequence.

Do not use a language code as a substitute for direction. A language can use more than one writing system, and a short string may consist only of neutral characters. Preserve explicit direction metadata when the source provides it.

In instructions, identify the control by name. “The button on the right” can become wrong after layout mirroring and gives little help to someone using a screen reader.