Skip to content

Find complex-script text the scan missed before drawing it with rhwp - #1131

Merged
KnifeLemon merged 1 commit into
mainfrom
fix/complex-script-scan-gaps
Nov 4, 2026
Merged

KnifeLemon merged 1 commit into
mainfrom
fix/complex-script-scan-gaps

Conversation

@KnifeLemon

Copy link
Copy Markdown
Owner

Refs #881
Refs #979

Cause

rhwp draws Arabic and Persian unjoined and backwards, so ComplexScripts scans a document first: with such text it takes a route through LibreOffice, or is refused with the reason. The scan missed text that still reaches the PDF, and that text came out unreadable:

Where the text is Route What came out
Excel number format (#,##0 "ریال") Excel → PDF ریال drawn unjoined and backwards
XML character references (گ), any Office package Office → PDF (run with Excel) not scanned, so it went to rhwp
Text box on a PowerPoint master or layout PowerPoint → PDF البطولة المفتوحة unjoined, overlapping and backwards
.potm PowerPoint → PDF not scanned as a presentation at all

The first and third match what #881 and #979 describe, but neither report has a file attached, so I can't say these were the reporters' cases. That is why this is Refs.

Fix

  • Number formats: only when xl/styles.xml has such letters in a format, the cells are read as they are shown, as already done for .xls. Excel keeps the currency formats of its language in files that don't use them, so a format nobody uses doesn't reroute or refuse a document.
  • Character references are read in package parts.
  • Masters and layouts: text boxes count, placeholder prompts don't (they are never drawn, and an English deck made in Arabic PowerPoint has Arabic ones).
  • .potm is scanned as a presentation.

The widths question uses the same scan, so a Cyrillic number format now also takes a route without rhwp when there is one.

What this doesn't change

Without LibreOffice these files are now refused with the existing "needs LibreOffice" message instead of being written broken. With LibreOffice, a Persian sheet and an Arabic slide render shaped and in the right order (checked on Windows with 26.2.6, rendered and looked at). Making rhwp itself draw them isn't reasonable. I tried handing it pre-shaped text: presentation forms in visual order, directly in an HWPX. The forms and the order come out right, but rhwp has no widths for these letters and sets each at a fixed half-em, so they stand apart with gaps and overlaps instead of joining. It also breaks lines left to right, so a wrapped paragraph would have its lines in the wrong order.

How this was checked

  • ArabicSheetTests: 5 new test cases fail with main's scan. The route test A_persian_number_format_is_never_drawn_unshaped skips here without rhwp in the test folder and should run in CI.
  • Before and after with real files through the CLI: the installed 2.1.0 wrote the broken PDF from the master text box (rendered and looked at); this branch refuses h_refs, h_numfmt and h_master, and still converts a workbook with only a Persian sheet name, which isn't drawn.

🤖 Generated with Claude Code

…rhwp

rhwp draws Arabic and Persian unjoined and backwards, so a document with such
text must take another route or be refused. The scan that decides this missed
text that still reaches the PDF, which came out unreadable:

- the text of an Excel number format (#,##0 "ریال"), read from the cells that
  use it, because Excel also keeps formats nobody uses
- text in XML character references (گ) in any Office package
- text boxes on a PowerPoint master or layout, whose placeholder prompts are
  never drawn and don't count
- .potm presentations, which weren't scanned as presentations at all

Refs #881
Refs #979

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KnifeLemon
KnifeLemon merged commit bb13c0e into main Nov 4, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant