Matterhorn TG-RTL-003 · PDF/UA-1 Taggart extension

English inside Hebrew: mixed-direction text lands wrong

Warning Checkpoint TG-RTL: Right-to-left text and reading order (Taggart extension) WCAG 1.3.2 (A)

Hebrew sentences containing English product names, dates, percentages or citation numbers are the hardest bidi case. Producers frequently reverse the RTL and leave the LTR runs alone, or reverse everything.

The condition, as the protocol states it. “A run mixing right-to-left script with Latin text or numerals does not resolve to the intended logical order under UAX #9.”

Matterhorn Protocol 1.1, checkpoint TG-RTL, index TG-RTL-003, section Taggart extension. Software can decide this one on its own.

What a screen reader actually does

The English words inside a Hebrew sentence are announced in the wrong position, often at the far end of the sentence.

Why mixed direction is the hard case

Pure Hebrew stored in visual order is TG-RTL-001, and once you have detected it the repair is a string reversal. Mixed direction is harder in both halves of the problem.

Consider a line that should read, logically:

התקן ISO 14289 מגדיר מסמך נגיש

Rendered on the page, right to left, the eye sees the Hebrew flowing right-to-left with ISO 14289 as an island flowing left-to-right inside it. That island is the problem. Three things can be true of the stored bytes, and all three render identically:

  1. Stored logically. Correct. Nothing to do.
  2. Whole line reversed. The Hebrew is backwards and ISO is stored as OSI, 14289 as 98241.
  3. Hebrew reversed, Latin left alone. The most common producer output, and the most deceptive: ISO 14289 extracts correctly, so a spot check on the recognisable token passes while every Hebrew word around it is mirrored.

Case 3 is why “I checked, the English looks fine” is not evidence.

What UAX #9 actually says

The Unicode Bidirectional Algorithm assigns every character a direction class. Three matter here:

  • Strong — Hebrew and Arabic letters are strong RTL; Latin letters are strong LTR.
  • Weak — European digits, currency signs, the decimal separator. They do not set direction; they take it from context but keep their own internal order.
  • Neutral — spaces, most punctuation, brackets. They resolve to the direction of what surrounds them, and to the paragraph direction when they sit between opposing runs.

Two consequences follow, and both show up as bugs:

Digits inside RTL text keep left-to-right order. 4289 is stored and read 4, 2, 8, 9 even in a Hebrew sentence. A producer that reverses the line character-by-character breaks this, and it is the failure a reader spots first because a wrong number is wrong in any language.

Neutrals between an RTL run and an LTR run resolve to the paragraph direction. In a Hebrew paragraph, the space between ISO and 14289 is not between two opposing runs — Latin letters and digits are both effectively LTR here — so the two stay together. But the space before ISO, sitting between Hebrew and Latin, resolves RTL. Get that boundary wrong when repairing and ISO 14289 splits, with the pieces landing at opposite ends of the sentence.

What is in the file

There is no direction information in a PDF content stream. There are positioned glyphs:

BT /F1 11 Tf
  1 0 0 1 452 700 Tm (ןקתה) Tj       % "התקן", stored reversed
  1 0 0 1 398 700 Tm (ISO 14289) Tj  % Latin island, stored forwards
  1 0 0 1 300 700 Tm (רידגמ) Tj      % "מגדיר", stored reversed
ET

Each Tm places a run absolutely, so the file renders perfectly whatever order the runs are in. Extraction concatenates in paint order and gets a mixture of reversed and forward text — which is why the same file gives different wrong answers in different extractors, depending on whether they sort by paint order or by x.

How to check your own file free

Copy a Hebrew sentence containing a number out of the PDF and paste it into a plain text editor — one that does not run the bidi algorithm on display, or the second reversal will hide the first. TextEdit in plain-text mode is fine; a browser address bar is not.

Then look only at the digits. If a number you can verify from the rendered page comes out with its digits in the opposite order, the line was reversed character-by-character. If the digits are right but the Hebrew words are mirrored, you are in case 3.

The Hebrew final letters are the second test, and they need no numbers. Five letters — ך ם ן ף ץ — occur only as the last letter of a word. Paste a Hebrew paragraph and look at where they fall. In a correctly stored string they end words. In a reversed string they begin them, and every one of them is at a word start.

How to fix it free, in Acrobat Pro

Honestly: this one is painful without tooling, and you should know that before you start.

Acrobat has no facility for repairing character order. What it does have is /ActualText, and that is the right mechanism:

  1. Open the Tags panel and find the element containing the affected text.
  2. Right-click → PropertiesTag tab.
  3. Type the correct sentence into the Actual Text field, in logical order — that is, type it the way you would type it normally in a Hebrew editor.
  4. Repeat per element.

/ActualText replaces the extracted text for that element entirely, for every consumer: screen readers, copy-paste, and reflow. The glyphs on the page are untouched, so the appearance cannot change.

The cost is that you are re-typing the document. For a paragraph it is reasonable. For a 60-page report it is not, and this is the specific case where a service vendor’s per-page price starts to look sane.

How Taggart does it

Detection is structural, not linguistic. For each line, Taggart pairs the sequence in which runs are painted with their positions on the page, then asks whether those two orders agree for the script in question. A right-to-left line whose paint order runs left-to-right is stored visually. Hebrew final-letter positions are checked as an independent corroborating signal, and the two together are what produce a confidence figure rather than a guess.

Repair reverses the line, then reverses back each maximal left-to-right run — Latin letters and digits together with the neutrals between them, but not the whitespace on either side, so ISO 14289 survives as one token. A final pass un-mirrors brackets, and only where the pairing is actually inside-out: a ( that closes and a ) that opens is evidence of a mirrored store, whereas a correctly paired bracket in an RTL context is left exactly as it is.

The result is written as /ActualText on the structure element. No content stream is touched, and the output is re-rendered and compared against the original at structural similarity ≥ 0.999 before you get the file back.

The fix is not in the safe set. Taggart shows you the original string, the repaired string and its confidence, and waits for you to accept it — because a repair that is confidently wrong about a document’s language is worse than the defect it replaces.

How Taggart handles it

Taggart detects this condition automatically. It is reported as a warning, with the page, the structure path and the object id of every occurrence.

The fix is Repair right-to-left text to logical order. It changes what the document means, so Taggart proposes it and waits for your approval rather than applying it unattended.

Whatever Taggart changes, the page still looks identical. Fixes edit the PDF object model, not the content streams, and every remediation is re-rendered and compared against the original at structural similarity ≥ 0.999 before you get the file back. A tool that quietly reflows your document is worse than no tool.

Frequently asked questions

The number in my Hebrew PDF reads as 9824 instead of 4289. Is that this?

Almost certainly. Digits are weak-direction characters under UAX #9: a run of European digits inside right-to-left text keeps its own left-to-right order while sitting in an RTL context. A producer that reverses the whole line character by character reverses the digits too, and 14289 becomes 98241. This is the single most common symptom because a wrong number is the one error a reader notices without understanding the language.

Can I not just reverse the whole string back?

No, and this is precisely why the condition is separate from TG-RTL-001. Reversing a mixed line reverses the Latin runs as well, turning ISO into OSI. The repair has to reverse the line and then reverse back each maximal left-to-right run — including the neutral characters between Latin tokens, but excluding the whitespace on either side, or ISO 14289 breaks apart into two tokens that end up at opposite ends of the sentence.

Is this fixed by adding RLM and LRM marks?

Directional marks fix display in a system that runs the bidi algorithm at render time. A PDF does not: the glyph positions are already baked in. Marks in the extracted text can help a downstream consumer resolve an ambiguous case, and Taggart emits them where the ordering genuinely is ambiguous — but they are not a substitute for storing the logical string.

How can Taggart tell an intentional order from a broken one?

It compares two independent signals. The order glyphs are painted in is one; where they sit on the page is the other. For a line stored logically, paint order and right-to-left geometry agree. For a pre-reversed line they disagree in a specific way, and Hebrew final letters — ך ם ן ף ץ, which occur only at the end of a word — corroborate it, because in a reversed string they appear at word beginnings.

Where this sits in the standards

Standards this condition maps to
StandardReference
Matterhorn Protocol 1.1 Checkpoint TG-RTL (Right-to-left text and reading order (Taggart extension)), index TG-RTL-003
PDF/UA-1 (ISO 14289-1) Taggart extension
WCAG 2.1 1.3.2 Meaningful Sequence — Level A
EN 301 549 / Section 508 / ADA Title II All three point at WCAG 2.1 Level AA for non-web documents, so a Level A or AA criterion here is in scope for each of them.
IS 5568 (Israel) Included in Taggart’s IS 5568 profile. Confirm the statutory scope for your obligation with a licensed מורשה נגישות — Taggart makes no legal determination.

Other conditions in checkpoint TG-RTL

Checkpoint TG-RTL covers right-to-left text and reading order (taggart extension). These are its other failure conditions; the ones without a link are in the rule set but do not have a written page yet.

Check your own file. Taggart’s validator is free and unlimited — every machine-checkable Matterhorn condition, no watermark, no expiry, and no account needed up to 60 pages.

See it on a Hebrew file, free

Verified against a real document on . Last updated .