Commit Graph
29 Commits
Author SHA1 Message Date
aiongg cf35f7dbae Merge remote-tracking branch 'upstream/main' into next-sync-1123
# Conflicts:
#	Cargo.toml
#	crates/audio/src/track.rs
2026-11-23 01:29:52 +00:00
FredApps 931d648681 Merge branch 'main' into feat/pict-reader
# Conflicts:
#	crates/metafile/src/lib.rs
2026-11-23 06:37:07 +07:00
FredApps 77807fd1be craft-metafile: keep the outer file's decode budget for a nested PICT
A PICT inside another metafile now draws on that file's decode budget
instead of resetting it. The public PICT entry point still starts a
fresh budget.
2026-11-23 05:58:16 +07:00
FredApps 5153451938 Merge branch 'main' into feat/pict-reader 2026-11-23 05:54:22 +07:00
FredApps 01e08770ef Merge branch 'main' into feat/metafile-embedded-emf 2026-11-23 05:54:17 +07:00
Dylan M. TayloranddotCooCoo d2a776ee56 metafile: expose frame and source-unit facts (#3071)
* metafile: expose frame and source-unit facts (#788)

Adapt the VectorCraft WMF unit scanner and EMF header-scale source facts from current VectorCraft main (db9acab4), preserving original authorship. Keep physical fallback scales and picture interpretation in the consumer.

* Distinguish EMF fixed calibration from variable header data

Retain the current app sizing policy. Correct the shared header classification when a description or pixel descriptor starts before the micrometre fields; this intentionally differs from the former size-only interpretation for those files.

* Use fixed-size chunks in the EMF header regression

* Reject negative EMF micrometre dimensions

ENHMETAHEADER stores szlMicrometers as signed SIZEL. Fall back to positive millimetre dimensions when either micrometre axis is nonpositive.

---------

Co-authored-by: dotCooCoo <RobertLeeLW@gmail.com>
2026-11-22 15:45:26 -05:00
ruchirguitar 6d02a9d791 craft-metafile: format pict.rs and lib.rs 2026-11-23 00:34:24 +05:30
ruchirguitar e0f7f787ce Merge upstream/main into feat/pict-reader 2026-11-23 00:20:43 +05:30
ruchirguitar ccd093d231 craft-metafile: retain pattern fills, prioritize emf/wmf in parse, report dropped drawings 2026-11-22 23:55:36 +05:30
ruchirguitar 0bf4cb99da craft-metafile: address CodeRabbit feedback on bare v1 routing and decoding 2026-11-22 22:57:39 +05:30
dotCooCoo 5239b47ad2 Share the legacy EMF and WMF EOF diagnostic
Extract the original diagnostic from dotCooCoo’s VectorCraft import commit 9efde43f1d827b95b838b75cc5d310362a9814f7.
2026-11-22 12:15:08 -05:00
ruchirguitar db9b6ac700 craft-metafile: address review feedback on PICT reader and formatting 2026-11-22 22:38:00 +05:30
ruchirguitar 75279bac65 craft-metafile: add QuickDraw PICT v1/v2 reader
Port bounded QuickDraw PICT parsing from VectorCraft into craft-metafile, outputting the neutral Picture model. Preserves limits, error reporting, and test coverage.
2026-11-22 22:08:54 +05:30
so-sai 09ac7119e6 craft-metafile: decode WMF META_ESCAPE_ENHANCED_METAFILE fallback 2026-11-21 19:20:07 +07:00
aiongg 640a3972a1 Sync follow-ups: upstream's Flatpak remote checks in packages.rs, docs of the public install::linux items, metafile test import, facade forwards update's oci_migration
The 17 Nov merge dropped is_artcraft_remote, oci_ref_available and remote_manages_flatpak (and their tests, as trials) with the test hunk they followed; install::linux is public upstream, so its newly public items are documented; craft-update's oci_migration gates no dependency, so the facade forwards it (design-lint features/gate).
2026-11-17 12:50:26 +00:00
aiongg ac3dfd1f53 Merge storytold main into next (17 Nov sync)
storytold main 83cb1133dd (291 commits) into the integration head bab1a99b85; 47 conflicted files.

- Domain test files (metafile, prepress, pdf plates, settings store, heif, media-testkit, atomic): tests next cut stay cut; tests new on main are kept, as trials where the crate's test target runs trials.
- atomic: main's group-bits test and Faulty::set_group go to src/tests.rs. audio: main's GSM and SBC oracles join tests/main.rs. cms constructors, pdf knockout_backdrop and testing_pdf join their crates' one test binary; timeline's preflight tests become src/preflight_tests.rs trials.
- update: main's changes to detect, install (linux, macos) and the tests land in next's split modules. The app's own offer is inspected on a thread of its own, picked up by tick's polling; settle_for_tests settles offers too. Later on a ready update drops the close it asked for. updater_pin_tests.rs stays deleted; its new pin test is in tests/it/update.rs.
- craft-color: main added a different crate at crates/color (the colour tags of compositor and display frames); it is next's craft-color module `tags`, re-exported at the root.
- Old crates/ui (combo, docking, testing, README) and keymap's ui/view.rs stay deleted; main's new crates/ui/src/testing files are dropped with them.
- New crates in the craft facade: ai, control, dds, frame, ipc, media-source, palette, press-print, score, ssip. testkit and xtask are listed outside it.
- Cargo.lock: the union of both locks, resolved by cargo metadata. Workflow: main's nextest Windows leg, with next's --keep-going clippy.
2026-11-17 12:44:52 +00:00
dotCooCoo 227ea620b1 craft-metafile: count refused bitmaps and lost pen textures, empty line clips
- A bitmap that the item or byte limit refuses is counted in
  dropped_images once, however many pieces a clip cuts it into.
- An EMF+ pen whose texture brush was not read is counted in
  dropped_images, as a lost texture brush object is.
- An EMF+ clip path or region path whose figures all lie on a line
  encloses no area, so it gives an empty area instead of its bounding
  rectangle.
2026-11-16 12:05:10 -08:00
dotCooCoo 23317d3284 craft-metafile: report what the reader leaves out
A caller could only tell from skipped_records that part of a file was
not read. Picture now also reports:

- truncated: the parse stopped at a limit that ends it (items, bytes
  kept, SAVEDC depth, clip paths), in the file or in an EMF+ metafile
  image drawn in it.
- dropped_images: images that were not read: bitmaps past a size, byte
  or decode limit or not decodable, EMF+ metafile images that do not
  parse or are nested too deep, and pattern or texture brushes whose
  bitmap was not read. An image with no pixels, or drawn from a source
  rectangle that selects none, is not counted.
- ignored_clips: SELECTCLIPPATH with RGN_OR, RGN_XOR or RGN_DIFF, EMF+
  clips combined with XOR, exclude or complement, EMF+ unions drawn as
  the rectangle around both areas, and EMF+ clip paths and regions
  whose area stands in for the one the file gives, when the clip that
  results can differ from the one the file asks for.
- unplayed_raster_ops: bitmaps drawn as plain copies because their
  raster operation is not SRCCOPY, SRCAND, SRCPAINT or SRCINVERT, and
  operations without a source other than PATCOPY, BLACKNESS and
  WHITENESS.

Behavior changes:

- An EMF+ metafile image adds its own counts, skipped_records included,
  once, the first time it is drawn. A nested picture without a size
  still draws nothing, and its counts are kept.
- A raster operation that takes no source no longer draws the record's
  bitmap. PATCOPY, BLACKNESS and WHITENESS fill the destination in
  STRETCHDIBITS and STRETCHDIB, as they already did in BITBLT,
  STRETCHBLT, DIBBITBLT and DIBSTRETCHBLT. Other such operations
  (DSTINVERT, PATINVERT) are left out and counted.
2026-11-16 11:00:57 -08:00
aiongg 2df33d2f01 Merge remote-tracking branch 'upstream/main' into sync/main-1116
# Conflicts:
#	Cargo.lock
#	crates/audio/src/lib.rs
#	crates/exr/src/decode.rs
#	crates/font-catalog/src/lib.rs
#	crates/ps/src/lib.rs
#	crates/svg/Cargo.toml
#	crates/text/Cargo.toml
#	crates/text/src/lib.rs
#	crates/video/Cargo.toml
#	crates/video/src/lib.rs
2026-11-16 14:23:07 +00:00
Dylan M. Taylor 8644532ed7 fix(metafile): preserve viewport scaling before inferred target 2026-11-16 00:05:09 -05:00
Dylan M. Taylor 7585d2df79 fix(metafile): retain WMF player target across viewport scaling 2026-11-15 23:50:34 -05:00
Hamza aaa7230822 craft-metafile: WMF scale and offset mapping records
META_SCALEVIEWPORTEXT, META_SCALEWINDOWEXT, META_OFFSETVIEWPORTORG and
META_OFFSETWINDOWORG were skipped, so a WMF that draws sub-pictures into
parts of its frame (each halving the viewport between SaveDC and RestoreDC)
stretched the first one over the whole frame and drew the next outside it
(storytold/deckcraft#2069).
2026-11-15 23:50:11 -05:00
aiongg 7808f7f6d2 Lints: fix clippy, rustdoc and test findings (shadowed f32 module, unused import, private doc link, struct-update defaults, test attributes lost in the 13 Nov sync) 2026-11-14 00:15:29 +00:00
aiongg 577055bc34 Merge storytold main 3c59a2aa5 into craft-framework (sync 13 Nov)
202 upstream commits since 6cb00467a. Resolutions:
- craft-window, craft-platform: ours. Upstream's frame policy v2, restore
  store and GNOME light/wait_first are the versions carried on 28 Oct;
  ours moved place() to craft-behavior and kept LayoutWatch and the
  appearance/portal.rs split.
- craft-timeline: ours. craft-time (crates/time) lands as upstream wrote
  it and is not yet used by craft-timeline.
- Old crates/ui modules stay removed. Upstream's frosted backdrops, shape
  gallery, dialog tabs and the iconic flyout top-edge rendering are not
  carried. The #1094 model half is in craft-behavior's dock:
  Group::flyout_offset and Action::MoveFlyoutTop.
- craft-update: #586 Save and Update, the install probe on the check
  thread and quiet per-user MSI self-updates, carried into updater.rs,
  stack_dialogs.rs, install/windows.rs and self_update/helper.rs.
- craft-jpeg: progressive Huffman decoding, carried into huffman.rs,
  parse.rs and scan.rs.
- craft-print: the driver settings dialog's new tests and the bounded
  XML parse's tests, as trials.
- Test-only conflicts: upstream tests from before the base that our side
  cut stay cut; tests new upstream are kept.
2026-11-13 17:11:48 +00:00
Dylan M. Taylor 21d7c1267e metafile: draw GDI+ percentage hatch styles 2026-11-13 06:05:42 +00:00
aiongg 25597ecfc7 Media, formats and engine crates: follow-ups from the framework migration 2026-11-12 14:32:38 +00:00
01cbc50269 metafile: dual EMF+ files draw their EMF+ records (stacked on #843) (#845)
* metafile: hold a placed pen width to what covers the frame

Picture::place scaled a pen width by the fit with no upper bound, so a
pen of 1e30 units made a renderer flatten round caps of that size. A
placed pen is now at most twice the diagonal of the frame and the path
together, which already covers the whole frame.

Ported from storytold/wordcraft#5427.

* metafile: one byte budget for items, EMF+ objects and clips; count clip regions when placing

- Canvas::shade_shape returns when the canvas is full or the clip is
  empty, instead of sampling a tile that is then dropped.
- EMF+ objects, the pieces of a continued object and the current and
  saved EMF+ clips count against the canvas's 256 MiB budget, in both
  directions: an object is not stored past what the canvas holds, and
  the canvas stops at what the objects hold.
- A nested metafile held by an EMF+ image object is charged for what its
  items own (segments, pixels, text, clip rectangles; a shared tile or
  clip path once) rather than 128 bytes an item.
- Picture::place charges each clip region it expands to the 500,000
  element budget, for every kind of item, and expands a region once for
  the consecutive items that share it.

Ported from storytold/deckcraft#1777, with its review comments addressed
(the canvas checks include the held bytes; text and bitmap items are
checked too; regions are matched by content, not by address).

* metafile: a negative crop side pads the picture

crop_window took each side as 0..1, so a negative side (a negative
a:srcRect side in an Office file, or a picture fitted whole into a frame
of another shape) was dropped and the picture was stretched over its
frame. A side is now taken down to -100: the window starts before the
source or ends past it, and Picture::fit places the source inside the
frame at its own proportions.

Ported from storytold/wordcraft#2027 (the -100 bound and the invariant
test) and storytold/wordcraft#5206 (the padding test).

* metafile: decode 8-bit text in the font's code page

8-bit text (WMF TEXTOUT and EXTTEXTOUT, EMF EXTTEXTOUTA and SMALLTEXTOUT)
was decoded in Windows-1250, 1251 or 1252 only, and a double-byte
character became a blank.

- Greek, Turkish, Vietnamese, Hebrew, Arabic, Baltic and Thai character
  sets decode in their code pages (encoding_rs, already a workspace
  dependency).
- Shift_JIS, UHC, GBK and Big5 pairs decode to their character, with the
  lead and trail ranges of each set; the character keeps the advances of
  both bytes. A lead byte without a trail byte is one undefined byte.
- A WMF face name is read in the font's code page.
- The Symbol font selected with DEFAULT_CHARSET keeps its bytes as symbol
  codes (U+F000 + code), as SYMBOL_CHARSET fonts do.

Ported from storytold/wordcraft#5187 (the code pages, the double-byte
ranges, the face name and the Symbol font) and storytold/deckcraft#792
(the Hebrew and Arabic tests).

* metafile: dual EMF+ files draw their EMF+ records, as GDI+ does

For a dual EMF+ file the reader played the plain EMF records and ignored
the EMF+ ones. Office draws metafiles with GDI+, which does the
opposite, and a file's GDI fallback can be incomplete (the EMF+ part
draws a nested metafile the fallback lacks).

EMF+ records now always play. In a dual file the plain EMF records are
skipped, except between an EmfPlusGetDC record and the next EMF+ record.
EMF+ only files and plain EMF files are read as before.

Ported from storytold/deckcraft#1464.

---------

Co-authored-by: Dmitrii Khlapov <19991457+dkhlapov@users.noreply.github.com>
Co-authored-by: David Lin <woei66@gmail.com>
Co-authored-by: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com>
2026-11-11 15:26:10 -05:00
75895c0321 metafile: pen width cap, shared byte budget, negative crops, code pages (#843)
* metafile: hold a placed pen width to what covers the frame

Picture::place scaled a pen width by the fit with no upper bound, so a
pen of 1e30 units made a renderer flatten round caps of that size. A
placed pen is now at most twice the diagonal of the frame and the path
together, which already covers the whole frame.

Ported from storytold/wordcraft#5427.

* metafile: one byte budget for items, EMF+ objects and clips; count clip regions when placing

- Canvas::shade_shape returns when the canvas is full or the clip is
  empty, instead of sampling a tile that is then dropped.
- EMF+ objects, the pieces of a continued object and the current and
  saved EMF+ clips count against the canvas's 256 MiB budget, in both
  directions: an object is not stored past what the canvas holds, and
  the canvas stops at what the objects hold.
- A nested metafile held by an EMF+ image object is charged for what its
  items own (segments, pixels, text, clip rectangles; a shared tile or
  clip path once) rather than 128 bytes an item.
- Picture::place charges each clip region it expands to the 500,000
  element budget, for every kind of item, and expands a region once for
  the consecutive items that share it.

Ported from storytold/deckcraft#1777, with its review comments addressed
(the canvas checks include the held bytes; text and bitmap items are
checked too; regions are matched by content, not by address).

* metafile: a negative crop side pads the picture

crop_window took each side as 0..1, so a negative side (a negative
a:srcRect side in an Office file, or a picture fitted whole into a frame
of another shape) was dropped and the picture was stretched over its
frame. A side is now taken down to -100: the window starts before the
source or ends past it, and Picture::fit places the source inside the
frame at its own proportions.

Ported from storytold/wordcraft#2027 (the -100 bound and the invariant
test) and storytold/wordcraft#5206 (the padding test).

* metafile: decode 8-bit text in the font's code page

8-bit text (WMF TEXTOUT and EXTTEXTOUT, EMF EXTTEXTOUTA and SMALLTEXTOUT)
was decoded in Windows-1250, 1251 or 1252 only, and a double-byte
character became a blank.

- Greek, Turkish, Vietnamese, Hebrew, Arabic, Baltic and Thai character
  sets decode in their code pages (encoding_rs, already a workspace
  dependency).
- Shift_JIS, UHC, GBK and Big5 pairs decode to their character, with the
  lead and trail ranges of each set; the character keeps the advances of
  both bytes. A lead byte without a trail byte is one undefined byte.
- A WMF face name is read in the font's code page.
- The Symbol font selected with DEFAULT_CHARSET keeps its bytes as symbol
  codes (U+F000 + code), as SYMBOL_CHARSET fonts do.

Ported from storytold/wordcraft#5187 (the code pages, the double-byte
ranges, the face name and the Symbol font) and storytold/deckcraft#792
(the Hebrew and Arabic tests).

---------

Co-authored-by: Dmitrii Khlapov <19991457+dkhlapov@users.noreply.github.com>
Co-authored-by: David Lin <woei66@gmail.com>
2026-11-11 14:25:35 -05:00
Dylan M. Taylor 9dfc35965c Add craft-metafile: WMF and EMF reader and writer (#830)
* craft-metafile: DeckCraft's WMF, EMF and EMF+ reader with WordCraft's changes merged

The base is DeckCraft's crates/metafile at cf0d7fbb. WordCraft's changes since
the copy was taken (WordCraft 05679497, the ancestor) are merged three ways from
WordCraft 639b8133: the cropped, depth-once DIB decoder, the bitmap side cap,
the header-only size(), crop_window, the free-slot object table, capacity-based
budget charging and the exact reservation in subpaths. WordCraft's own text
records lose to DeckCraft's richer text model. All 120 DeckCraft tests and all
69 WordCraft tests are kept (132 distinct).

* craft-metafile: line styles, clip paths and the records behind them, from VectorCraft's reader

The model gains what VectorCraft's reader kept and the other two dropped:
LineStyle (cap, join, miter limit, dashes) on paths, and clip paths
(SELECTCLIPPATH) shared between the items they clip. The reader now plays
EXTCREATEPEN style entries and the pen's cap and join bits, SETMITERLIMIT,
SETARCDIRECTION, SCALEVIEWPORTEXTEX, SCALEWINDOWEXTEX, SELECTCLIPPATH and
ABORTPATH; STROKEANDFILLPATH closes open figures and CLOSEFIGURE moves the
current position; the header's micrometre device size is used when present;
BITMAPCOREHEADER, BI_JPEG and BI_PNG bitmaps decode; records of unknown types
are counted in Picture::skipped_records. Each has a test.

* craft-metafile: EMF and WMF writers behind the write feature, bitmap transforms, a decode budget

The writers are VectorCraft's, taking a list of drawing operations (fills,
strokes with pens, images, clips) instead of its document; the document walk
stays in the application. Bitmap items gain a transform, so an image drawn
under a turning world transform keeps its turn (the writer places images that
way). JPEG and PNG bitmaps share one per-file pixel budget. The tests cover the
writers record by record, round-trip both formats through the reader, and play
VectorCraft's hand-built files into the picture model.

* craft-metafile: a test per limit, README, crate docs

Adds tests for the limits no test held to their value (string lengths, clip
region rectangles, placed elements, tile side, palette size, nesting, the EMF+
object table, save stack, point lists, gradient stops, region depth, continued
objects, bitmap masking work) and a truncation and mutation sweep over the new
records. Records that change what is drawn but are not played now count as
skipped instead of ignored. The README has the coverage tables, the limits,
what stays in the apps, the origin of each part and a migration table per app.

* craft-metafile: a region node cap test, the box of a turned bitmap

The region node cap gets a test of its own (a balanced tree of intersections),
and a turned bitmap's rectangle is the box around its four corners, so a caller
that draws rectangles still has an area to draw into.
2026-11-11 13:39:28 -05:00