Skip to content

fix(xlsx): read self-closing drawing run properties#468

Open
developer0hye wants to merge 1 commit into
mainfrom
fix/xlsx-drawing-rpr-empty
Open

fix(xlsx): read self-closing drawing run properties#468
developer0hye wants to merge 1 commit into
mainfrom
fix/xlsx-drawing-rpr-empty

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

Summary

  • extract the <a:rPr> attribute loop into apply_run_properties
  • call it from the reader's Event::Empty arm as well as Event::Start, so a self-closing <a:rPr/> keeps its size, bold, and italic

Related issue

Fixes #466

Details

Excel writes a shape label's run properties as a self-closing element, <a:rPr lang="en-US" sz="1100"/>, which quick-xml reports as Event::Empty. The drawing reader matched rPr only in its Event::Start arm, so every attribute on that spelling was discarded and the run fell back to the renderer's default 11pt regular.

That default happens to equal the common sz="1100", which hid the defect until a label used another size or weight. Parsing the same attributes in both spellings showed the split:

Run properties font_size bold italic
<a:rPr lang="en-US" sz="1400" b="1" i="1"/> None None None
<a:rPr … ><a:solidFill>…</a:solidFill></a:rPr> Some(14.0) Some(true) Some(true)

Only the presence of a child element changed the outcome, which is not a distinction DrawingML makes. The new tests assert both spellings resolve identically, and that b="0"/i="0" still mean "not bold"/"not italic".

Testing

  • cargo fmt --all -- --check
  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features
  • rendered all 68 committed XLSX fixtures before and after and compared pdftotext -bbox output

Visual impact

  • No rendered PDF change
  • Rendered PDF change or visual evidence added
  • Reason: no committed fixture exercises the defect. The only self-closing run properties in the corpus use sz="1100", which equals the renderer default. Rendering all 68 XLSX fixtures before and after leaves 67 byte-identical in pdftotext -bbox layout; the 68th (tests/fixtures/xlsx/WithDrawing.xlsx) differs only by 1e-5 pt on two word coordinates, from taking Typst's explicit-11pt path instead of its default-11pt path. Documents outside the corpus that use another size, bold, or italic on a self-closing <a:rPr/> will render differently — correctly — after this change.

Checklist

  • Commits include a Signed-off-by line
  • PR scope contains one root cause
  • Remaining visual deviations each reference an open issue

Excel writes a shape label's run properties as a self-closing element,
`<a:rPr lang="en-US" sz="1100"/>`, which quick-xml reports as
`Event::Empty`. The drawing reader matched `rPr` only in its `Event::Start`
arm, so every attribute on that spelling was discarded and the run fell
back to the renderer's default 11pt regular. The default happens to equal
the common `sz="1100"`, which hid the defect until a label used another
size or weight: a 14pt bold italic label still rendered 11pt regular.

Extract the attribute loop into `apply_run_properties` and call it from
both arms, so a run's size, bold, and italic resolve identically whether or
not its `<a:rPr>` has children.

No committed fixture is affected: the only self-closing run properties in
the corpus use `sz="1100"`. Rendering all 68 XLSX fixtures before and after
leaves 67 byte-identical in layout, and the 68th differs only by 1e-5 pt of
float noise on two words, from taking Typst's explicit-11pt path instead of
its default-11pt path.

Fixes #466

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye
developer0hye force-pushed the fix/xlsx-drawing-rpr-empty branch from fb7a419 to 587acb8 Compare July 25, 2026 18:10
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.

XLSX: self-closing <a:rPr/> drops a worksheet drawing run's size, bold, and italic

1 participant