Skip to content
Talk to an engineerRequest access

Right-to-left math

Arabic mathematical notation — mirrored layout, Arabic-Indic and Persian digits, Arabic operator names — and how text inside formulas follows its own direction.

Two formulas in Arabic notation laid out right to left: a limit with the Arabic name of lim and sin, and the quadratic formula in Arabic letters with Arabic-Indic digits

LayoutOptions(mathDirection: MathDirection.rtl) lays a formula out right to left, as Arabic mathematical notation does: the formula is mirrored, and directional symbols — brackets, radicals, ∑, ∫, arrows, < — are drawn mirrored, while numbers and text keep their own direction. Equation numbers go on the left (on the right with leqno).

Option Values
digits DigitStyle.western (default), arabicIndic (٠١٢٣), persian (۰۱۲۳)
operatorNames Replacement names for named operators, keyed by command. arabicOperatorNames covers \sin, \cos, \tan, \cot, \sec, \csc, \lim and \log.
kashida Stretch Arabic operator names with kashida (ـ) to span wide limits. Default true.

Arabic letters in a formula are text, shaped by Flutter’s text engine, so the app needs a font that has them. After the families in MathTextFonts.fallback the platform’s fonts are tried; to be sure of the result, bundle a font, declare it in your pubspec.yaml and name it in fallback, as the example does with Noto Naskh Arabic.

In ordinary left-to-right math, the text runs inside a formula (\text{…}) take their base direction from LayoutOptions.textDirection. Its default, TextRunDirection.auto, uses the surrounding Directionality in a Math widget, and otherwise each run’s first strong character.

toSpeech(result, language: SpeechLanguage.arabic) reads formulas in Modern Standard Arabic school phrasing; Math’s speechLanguage does the same for screen readers. Part of its vocabulary (less common symbols, and the words for tables and lists) is still a draft, not yet checked by a native reader.