Skip to content

fix(docx): a right-to-left paragraph is drawn flush left, and complex-script size is ignored #546

Description

@DemchaAV

Two separate faults, both visible on opening a DOCX with Hebrew or Arabic.

1. Alignment lands on the wrong side

DocxSemanticBackend writes the resolved alignment physically:

<w:pPr><w:bidi/><w:jc w:val="right"/></w:pPr>

Word reads w:jc's left/right as start/end relative to the paragraph direction, so in a w:bidi paragraph right means the end of the flow — the left edge. A right-to-left paragraph that the page laid out flush right is drawn flush left.

Fix: map alignment through the paragraph direction before writing it — a right-to-left paragraph aligned to its natural start must be written left, and an explicitly left-aligned one right.

2. Complex-script size and weight are never written

A 15pt Hebrew paragraph reaches Word as:

<w:rFonts w:ascii="David Libre" w:hAnsi="David Libre" w:cs="David Libre" w:eastAsia="David Libre"/>
<w:sz w:val="30"/>

The font slots are right, including w:cs. But w:szCs, w:bCs and w:iCs are never written — 0 occurrences in the output and no code for them in the backend — and the export ships no styles.xml, so there are no docDefaults to fall back to either. Word takes size, bold and italic for complex-script characters from w:szCs / w:bCs / w:iCs, so Hebrew and Arabic are drawn at Word's built-in default size and weight rather than the requested style, while Latin in the same run obeys w:sz.

Fix: write the complex-script twin alongside each of w:sz, w:b, w:i.

Both recorded in the capability matrix by #544.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions