Skip to content

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

Closed

Description

@hmmdev97

Summary

A WMF can draw several sub-pictures into parts of its frame: each one saves the DC, halves (or otherwise scales) the viewport with META_SCALEVIEWPORTEXT, sets its own window, draws, and restores the DC. Charts and clip art pasted from older Office versions are often stored like this. DeckCraft ignores the scale, so the first sub-picture is stretched over the whole frame and the next ones land outside it.

Version: deckcraft-cli 0.18.1 (built from tag v0.18.1, 7cc73ab), macOS 26.6.2, Intel. Same result with the 0.17.0 release.

Sample

Records

SetWindowOrg   0, 0
SetWindowExt   800 x 400            ; the frame
SaveDC
  SetMapMode        MM_ANISOTROPIC
  ScaleViewportExt  x * 1/2, y * 1/1
  SetWindowOrg      0, 0
  SetWindowExt      400 x 400
  Ellipse           20,20 – 380,380  ; red brush
RestoreDC -1
SaveDC
  SetMapMode        MM_ANISOTROPIC
  ScaleViewportExt  x * 1/2, y * 1/1
  SetWindowOrg      -400, 0         ; shifts this sub-picture into the right half
  SetWindowExt      400 x 400
  Ellipse           20,20 – 380,380  ; blue brush
RestoreDC -1

Expected vs actual

Expected (LibreOffice, ONLYOFFICE): a red circle in the left half and a blue circle in the right half.

Actual: one red ellipse stretched over the whole frame; no blue circle.

Left: DeckCraft 0.18.1, middle: LibreOffice 26.8.2, right: ONLYOFFICE 10.0.

WMF sub-pictures

Where it seems to come from

crates/metafile/src/wmf.rs (record, at 7cc73ab) handles META_SETWINDOWORG/EXT and META_SETVIEWPORTORG/EXT, but has no case for META_SCALEVIEWPORTEXT (0x0412), META_OFFSETVIEWPORTORG (0x0211), META_SCALEWINDOWEXT (0x0410) or META_OFFSETWINDOWORG (0x020F), so they fall through and are skipped ([MS-WMF] 2.3.5). #2064 moves this reader to craft-metafile; the same four cases are missing in craft-libs main too, so a fix would probably go there.

Steps to reproduce

  1. deckcraft-cli render r8-wmf-scale-viewport.pptx --all --scale 2 out/
  2. Compare with LibreOffice or ONLYOFFICE.

Activity

  1. ticket-craft commented on Nov 12, 2026

    @ticket-craft

    Possibly related: storytold/vectorcraft#2673 and #327.

    This looks like a problem shared by several apps: VectorCraft and WordCraft.

  2. added
    bugfixFixes something that is broken: wrong result, crash, data loss
    on Nov 12, 2026
  3. kiwi5boy commented on Nov 20, 2026

    @kiwi5boy
    Contributor

    Taking this: bumping DeckCraft's craft-metafile pin past craft-libs #1816, with a regression test.

  4. added a commit that references this issue on Nov 22, 2026
  5. added a commit that references this issue on Nov 22, 2026
  6. dotCooCoo commented on Nov 22, 2026

    @dotCooCoo
    Contributor

    Fixed in #2266, merged 2026-11-22. It is expected in v0.19.0.

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

    bugSomething isn't workingbugfixFixes something that is broken: wrong result, crash, data lossfile-compatpriority: mediumshared

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions