Skip to content

PPTX: character spacing (spc attribute) not parsed #102

@developer0hye

Description

@developer0hye

Description

The PPTX parser ignores the spc attribute on <a:rPr> (run properties), which controls character/letter spacing. This causes text to render with incorrect spacing, particularly noticeable on CJK text and headings with wide tracking.

Root Cause

In crates/office2pdf/src/parser/pptx.rs, extract_rpr_attributes() (line ~2348) only handles: b, i, u, strike, sz. The spc attribute is never read. Searching for "spc" in the parser yields zero matches.

Additionally, the TextStyle struct in crates/office2pdf/src/ir/elements.rs has no field for letter/character spacing.

PPTX XML structure:

<a:rPr lang="en-US" sz="4800" spc="300">
  ...
</a:rPr>
<a:t>SOME HEADING TEXT</a:t>

Here spc="300" means 300 hundredths of a point = 3pt letter spacing.

Expected

Text rendered with 3pt spacing between characters (wider, more airy).

Actual

Text rendered with default (0) letter spacing — characters appear closer together than intended.

Fix Required

  1. Add letter_spacing: Option<f64> to TextStyle struct
  2. Parse spc attribute in extract_rpr_attributes(): spc / 100.0 to get points
  3. Emit tracking: Xpt in Typst codegen's write_text_params()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions