Skip to content

#2069: WMF scale and offset mapping records place sub-pictures - #2266

Merged
FredApps merged 2 commits into
storytold:mainfrom
kiwi5boy:ccr-3400a88a-qfiv9l
Nov 22, 2026
Merged

FredApps merged 2 commits into
storytold:mainfrom
kiwi5boy:ccr-3400a88a-qfiv9l

Conversation

@kiwi5boy

@kiwi5boy kiwi5boy commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2069.

What was wrong

DeckCraft reads WMF through craft-metafile, pinned at craft-libs 63196e66. That revision skips the four relative mapping records (META_SCALEVIEWPORTEXT, META_SCALEWINDOWEXT, META_OFFSETVIEWPORTORG, META_OFFSETWINDOWORG). A WMF that draws sub-pictures with them (charts and clip art from older Office versions) stretches the first sub-picture over the whole frame and draws the rest outside it.

The reader fix is already in craft-libs: Hamza's storytold/craft-libs#1183, merged through storytold/craft-libs#1816 together with its frame-sizing fix. #1183 notes that the issue stays open until DeckCraft's pin moves. This PR moves it.

What changed

  • Cargo.toml / Cargo.lock: craft-metafile moves to craft-libs f428c3d3. The other craft-libs pins don't change. The lockfile diff is that one source line.
  • crates/render/src/tests.rs: metafile_scaled_viewport_places_each_sub_picture_in_its_half builds the issue's WMF in code. It has no placeable header, an 800 × 400 frame and two sub-pictures. The test rasterizes it through metafile::rasterize and checks for red in the left half, blue in the right half and nothing between them.
  • docs/file-format-parity.md (EMF / WMF row, status line, revision history) and ROADMAP.md (progress log, status line, revision history).

The other craft-metafile changes since the old pin are the skipped-content counts on Picture from craft-libs #1918. They add fields only, and DeckCraft doesn't construct Picture. Showing those counts in the app is left for a follow-up.

Testing (Linux x86_64)

Check Result
New test on the old pin 63196e66 fails: blue circle in the right half: Rgba([255, 0, 0, 255]), the red ellipse stretched over the frame as reported
New test on the new pin passes
cargo test -p deckcraft-render 225 passed, 0 failed
cargo clippy -p deckcraft-render --all-targets -- -D warnings clean
cargo fmt --all --check clean
cargo xtask layers, cargo xtask assets, cargo xtask wasm ok
cargo metadata --locked ok

Not run: the full cargo xtask ci workspace sweep (tests and clippy for every crate). deckcraft-render is the only crate that uses craft-metafile. I also didn't render the issue's .pptx in the app or the CLI; the test builds the same records in code.

Summary by CodeRabbit

  • Bug Fixes
    • Improved rendering of WMF images that use scale and offset records to position subpictures within their frame. Multiple subpictures now retain their intended placement and sizing, including when viewport settings change, helping prevent incorrect overlap or positioning.
  • Documentation
    • Updated file-format coverage information to reflect WMF scale-and-offset mapping support for subpictures.

Move the craft-metafile pin to storytold/craft-libs f428c3d3, past
craft-libs storytold#1816 (Hamza's mapping records from storytold#1183, with the frame
fix). WMF files that draw sub-pictures with SCALEVIEWPORTEXT,
SCALEWINDOWEXT, OFFSETVIEWPORTORG and OFFSETWINDOWORG now place each
one in its part of the frame instead of stretching the first over it.

Only craft-metafile moves; the other craft-libs pins are unchanged.

The render test builds the issue's WMF in code and fails on the old
pin: the right half is red, not blue.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 00:26
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The craft-metafile dependency revision changes. A renderer regression test checks WMF sub-picture placement with scaled viewport mappings. The roadmap and file-format parity documentation record the mapping behavior.

Changes: WMF mapping support and validation

Layer / File(s) Summary
WMF mapping and regression coverage
Cargo.toml, crates/render/src/tests.rs, ROADMAP.md, docs/file-format-parity.md
The craft-metafile revision changes. A test builds a WMF without a placeable header and checks the rendered placement of two sub-pictures. The roadmap and parity documentation record the mapping behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: dylanmtaylor, echelon

Merge Risk: Minimal · up to 06c77

This updates the WMF parser dependency so sub-pictures using scale and offset mapping records are placed in their intended parts of the frame, and adds a regression test for it. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "#2069: WMF scale and offset mapping records place sub-pictures" matches the main change. The PR adds support for WMF scale and offset mapping records (META_SCALEVIEWPORTEXT, META_SCALEWINDO…
Linked Issues check Passed Issue #2069 requires WMF relative mapping records (META_SCALEVIEWPORTEXT, META_SCALEWINDOWEXT, META_OFFSETVIEWPORTORG, META_OFFSETWINDOWORG) to take effect, so sub-pictures render in their intended fr…
Out of Scope Changes check Passed The reviewed changes are the craft-metafile pin bump in Cargo.toml, one regression test with WMF test helpers in crates/render/src/tests.rs, and documentation updates in docs/file-format-parity.md and…
Full details: Title check

Explanation

The title "#2069: WMF scale and offset mapping records place sub-pictures" matches the main change. The PR adds support for WMF scale and offset mapping records (META_SCALEVIEWPORTEXT, META_SCALEWINDOWEXT, META_OFFSETVIEWPORTORG, META_OFFSETWINDOWORG) so sub-pictures land in their intended halves, and it adds a test for this. The title is specific and names the linked issue. The PR also bumps a craft-metafile revision, which the title does not mention, but that bump is the mechanism for the fix and is not a separate change.

Full details: Linked Issues check

Explanation

Issue #2069 requires WMF relative mapping records (META_SCALEVIEWPORTEXT, META_SCALEWINDOWEXT, META_OFFSETVIEWPORTORG, META_OFFSETWINDOWORG) to take effect, so sub-pictures render in their intended frame regions. The PR moves the craft-metafile pin in Cargo.toml from 63196e66 to f428c3d3. The reader fix is in craft-libs, not in this repository. The PR adds metafile_scaled_viewport_places_each_sub_picture_in_its_half in crates/render/src/tests.rs. This test builds the issue's two-sub-picture WMF in code and checks red in the left half, blue in the right half, and no content at the midpoint. The author reports that the test fails on the old pin (blue circle absent, red ellipse stretched) and passes on the new pin. I did not rerun the test or inspect the craft-libs source. Limit: the test exercises META_SCALEVIEWPORTEXT only. Direct test coverage for META_SCALEWINDOWEXT, META_OFFSETVIEWPORTORG, and META_OFFSETWINDOWORG is not shown. Support for those three records relies on the pinned craft-libs reader, which I could not verify here. The Cargo.lock change is excluded from review (ignored_files, rule !**/*.lock). The changes since the previous reviewed head (921b455) were not isolated, so the prior PASS is preserved on the basis of the whole-PR summary and the unchanged pin.

Full details: Out of Scope Changes check

Explanation

The reviewed changes are the craft-metafile pin bump in Cargo.toml, one regression test with WMF test helpers in crates/render/src/tests.rs, and documentation updates in docs/file-format-parity.md and ROADMAP.md. The pin bump and test connect directly to #2069. The documentation updates record the status of this issue. The pin bump also brings in craft-libs #1918 changes that add skipped-content counts to Picture. The PR states these fields are additive, that DeckCraft does not construct Picture, and that UI display is deferred. No change was found that is unrelated to #2069. The Cargo.lock diff is excluded from review, so its exact contents were not checked. The incremental changes since 921b455 were not isolated, so this assessment relies on the whole-PR summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 921b455 and 06c7701.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 3

  • Cargo.toml
  • ROADMAP.md
  • docs/file-format-parity.md
Files skipped from review as they are similar to previous changes: 2

  • ROADMAP.md
  • docs/file-format-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is limited to a dependency pin update accompanied by a targeted WMF mapping-record regression test and corresponding documentation updates, with no remaining issues indicated in the provided review evidence.

No open issues 🎉

What changed in this PR

Moves DeckCraft’s craft-metafile dependency pin to a craft-libs revision that supports WMF scale/offset mapping records, fixing incorrect placement of WMF sub-pictures (e.g., older Office charts/clip art), and adds a regression test plus documentation updates.

Changes:

  • Bump craft-metafile to a newer craft-libs revision (and update Cargo.lock) to pick up WMF mapping-record handling.
  • Add a render regression test that constructs a minimal WMF and asserts correct left/right sub-picture placement after rasterization.
  • Update roadmap and file-format parity documentation to reflect the fix and its revision history.
File Description
ROADMAP.md Updates the project roadmap/progress log and revision history to record the #2069 fix landing.
docs/​file-format-parity.md Updates the EMF/WMF parity/status row and revision history to reflect improved WMF mapping-record support.
crates/​render/​src/​tests.rs Adds a regression test that programmatically builds a WMF exercising scale/offset mapping records and validates correct rasterized sub-picture placement.
Cargo.toml Advances the craft-metafile git revision pin to the craft-libs commit that includes WMF mapping-record handling.
Cargo.lock Updates the locked craft-metafile source line to match the new pinned git revision.

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

@autocraft-bot autocraft-bot Bot added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 20, 2026

@autocraft-bot autocraft-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review (Claude Opus 5.5). Not a maintainer decision.

No blocking problems found (not certain).

Moves the craft-metafile pin to a revision that handles the WMF scale and offset mapping records. Adds a test that builds a two-sub-picture WMF and checks where each circle lands.

  • Cargo.toml:75 changes only the craft-metafile revision; the other craft-libs pins stay as they were.
  • crates/render/src/tests.rs:3409 wmf_bare writes a correct 18-byte standard header and u32 record sizes, with odd-length parameters padded, so the test WMF is well formed.
  • crates/render/src/tests.rs:3436 the second sub-picture's window origin of -400, with the viewport width halved, places its circle at device x 420–780. The probes at x 50, 150 and 100 (of 200) therefore test left, right and the gap between them.
  • craft-metafile now uses a different craft-libs revision from craft-pdf and craft-update. Worth confirming in Cargo.lock that no shared craft-libs crate ends up in two copies.
  • docs/file-format-parity.md:57 and ROADMAP.md record the change in the existing revision-history format.

Claims checked:

  • verified: craft-metafile moves to craft-libs f428c3d3 and the other craft-libs pins don't change (Cargo.toml:75 rev changes from 63196e66… to f428c3d36e0faf3924b76956a01334c051543527; the craft-pdf and craft-update lines in the same hunk keep rev 63196e66…)
  • unverified: The lockfile diff is that one source line (Cargo.lock is not part of the reviewed diff; only Cargo.toml:75 changes in the manifest)
  • verified: WMF pictures that place sub-pictures with SCALEVIEWPORTEXT, SCALEWINDOWEXT, OFFSETVIEWPORTORG and OFFSETWINDOWORG now draw each sub-picture in its part of the frame (fixes issue 2069) (crates/render/src/tests.rs:3436-3468 builds a WMF with SAVEDC, SCALEVIEWPORTEXT 1/2, SETWINDOWORG and SETWINDOWEXT…
  • unverified: The new test fails on the old pin 63196e66 (crates/render/src/tests.rs:3466 the blue assertion would fail if the first circle were stretched over the frame, but the run on the old pin was not reproduced)
  • verified: File-format parity doc and roadmap record the change (docs/file-format-parity.md:57 EMF / WMF row names the four records; docs/file-format-parity.md:122 and ROADMAP.md:162 and ROADMAP.md:356 add dated entries)

Reviewed at 06c7701.

Recommendation: merge, after a maintainer's decision.

@autocraft-bot

autocraft-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

AI-generated comment (Sonnet). Not a maintainer decision.

Merged main into this branch to resolve the conflict.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 06c7701, which contains current main (0ccc68f).

  • The change is scoped to the issue. craft-metafile moves from 63196e66 to f428c3d3, which is on craft-libs main. The lockfile changes one source line, and the other craft-libs pins stay where they are. In craft-libs, crates/metafile changes between the two revisions only through the scale/offset mapping records (aaa72308, 7585d2df, 8644532e) and the skipped-content counts (23317d32, 227ea620). Neither adds a new error return, so a WMF/EMF that opens today keeps opening.
  • I confirmed the test locally on Linux x86_64. metafile_scaled_viewport_places_each_sub_picture_in_its_half passes on this head and fails with the pin set back to 63196e66.
  • Hosted CI on this head passes: the Ubuntu gate, lockfile, font-pin, nix and SonarCloud.
  • One note, not blocking: this adds a third craft-libs rev to the workspace (010702ee, 63196e66, f428c3d3). That departs from the single-rev SHOULD in rule 10. Moving every crate here would widen the risk well beyond #2069, so a separate unification PR is the right place for it.

Not tested: rendering the issue's .pptx in the app, and platforms other than Linux.

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

Labels

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WMF: ScaleViewportExt (and the other Offset/Scale mapping records) are ignored, so sub-pictures are drawn full size

4 participants