Repository navigation
Milestone 4: export to SVG, PNG and PDF - #4
Merged
Merged
Conversation
Every colour moves into one Palette (Palette::LIGHT) so a later theme can restyle the window and exports alike. scene.rs builds each object's items in board units, independent of the view, and Renderer::export draws them into a PNG: whole board or a selection, plus a margin, waiting for every formula in the worker, with caps on drawing work, math wait, pixels and bytes. The window's drawing is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each shape kind has one builder, which maps into board units for exports or into the view for the window, so the screen and every export draw the same objects with the same geometry. The window and PNG export share one set of vello calls. Screen output is byte-identical to before (298 dumped frames and images) and frame times are unchanged within noise. render_png moves its image out and writes the sRGB chunk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SVG export from the shared scene, written by hand: every glyph is an outline defined once and placed with <use>, shapes are paths with round caps and joins, colours come from the palette. No board text, no external reference, same bytes every run, and the 64 MiB cap is checked while writing. MathEngine::layout_until stops waiting at a deadline without caching a failure, so an export's 10 s math wait no longer runs seconds past its cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One page at 30 pt a unit, shrunk to fit PDF's 14,400 pt limit. Board text is real text through krilla (subset fonts, ToUnicode), so it can be searched and copied; math glyphs are drawn as reusable forms, each outline stored once. ICC sRGB, no date or metadata, same bytes every run. Every glyph id is checked before krilla sees it. hayro (dev) reads the file back and renders it against the PNG export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ow objects
:export {file} (:exp) picks the format from the extension and exports the
whole board, or the selection from Visual. :w with an .svg, .png or .pdf file
is refused and points to :export. pngscale and exportbg set PNG sharpness and
the background. One export per key, each also a write slot, charged to the
key's work budget. export_done reports without naming or saving the board.
:te, :ma and :sym with the cursor on an object now put the new block below it
by the place rule instead of on top of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d line :export resolves its path like :w, refuses the board's own file, shows "exporting" and presents that frame before the export runs, then writes atomically and reports. Effects and queued keys keep the engine's order. lawh export [--scale N] [--transparent] <board.lawh> <out.ext> exports without a window: math in the worker, no lawhrc, exit 0, 1 or 2. A board file named export opens with lawh ./export or lawh -- export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the cost review: PNG encoding ran outside every budget (one crafted board took 7 s to encode) and the byte cap was checked only after the whole image was compressed in memory. The encode is now charged to the export budget up front (zlib up to 2 Mpx, fdeflate above, both weights measured on their worst content) and streams through the byte cap. Dropping a worker-mode MathEngine kills and reaps the worker, so lawh export leaves no process behind. SVG width and height are capped like PNG sides. The PDF form weight is refitted on a board of distinct colours. A test now fails on any colour made outside palette.rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 1: a click, a close request or a failed present ran at most one waiting export, so a second one was dropped and keys queued behind it ran after the click moved the cursor. They now drain the whole queue in the engine's order first. Text and failed-formula colours are picked in one place (scene::text_paint) for the window and exports. A formula that fails only when fetched again to draw stops the export instead of drawing cropped. The math-wait CLI test no longer depends on the machine's speed. Doc comments brought up to date. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 2: a click that first ran a waiting export landed through the view the drained keys left; it now lands through the view the user clicked on. The report of an export run by a click or close is no longer cleared or hidden (Engine::restore_message). PNG takes fdeflate's charge before drawing and zlib's extra only if it fits, so a smaller image is never refused where a larger one is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
keys.md lists :export, the :w refusal, the two settings, lawh export and blocks placed below an object. Architecture gains an Export section and its caps; tech-stack moves krilla to in use and adds the test readers; testing, SECURITY and CLAUDE.md follow. M4 numbers, re-measured in release, are in docs/research/m4-measurements.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CLI exit codes and stdout stated exactly, claims about Ghostscript and rsvg re-measured and sourced, derived numbers marked, the SVG writer's chunk size added to the limits, <file> notation made consistent, and code comments brought in line with the re-measured numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Typst caches what it evaluated for the whole process. When the deadline test compiled the slow formula first, the timeout test got it back at once and failed (seen on CI; reproduced with --test-threads=1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Renderer::exportwrites a board to SVG, PNG or PDF, framed to its objects plus a 1-unit margin, with no grid dots or overlay. Every formula is compiled in the worker and waited for; one that fails is drawn in red, as on screen, and counted in the message.exportbg=none.<text>, no board text and no reference outside the file.scene.rs, and every colour comes fromPalette. A test fails on a colour made anywhere else, so the visual pass restyles exports too.:exp[ort] {file}(the format comes from the extension), only the selection from Visual,:set pngscaleandexportbg, and:w x.pngrefuses and names:export.:te,:maand:symon an object now place the block below it.lawh export [--scale N] [--transparent] <board.lawh> <out.ext>works without a window and exits 0, 1 or 2.CLAUDE.md.lawh exportleaves none behind.docs/keys.md, the architecture, testing, tech-stack and security docs, and M4 measurements.Result
lawh exporttakes 18 ms forexamples/area.lawhas SVG, 21 ms as PDF and 31 ms as PNG (release, worker start included). The board still takes 62 keys to build.Checks
-D warnings, 1,002 tests, the Rust 1.95 check and cargo-deny all pass.lawh-core's dependency tree is unchanged.🤖 Generated with Claude Code