Repository navigation
Drawing export: a sheet's PNG draws its text, filled like the SVG's (#4890) - #12355
Merged
Merged
Conversation
A sheet's text is drawn from the same glyph outlines the SVG writer fills, filled nonzero so a glyph's overlapping contours fill whole, where the PNG writer refused any text before. Text counts toward the point cap and is drawn band by band like any fill, in every colour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
This was referenced Nov 5, 2026
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.
Change
A drawing sheet can be exported as a PNG picture. Text on a sheet (a dimension's number, a title block's values) is set as filled glyph outlines, and the PNG writer refused any sheet with text on it, by name. Now it draws the text: each line's glyph outlines are filled where the sheet puts them, the same outlines the SVG export writes.
Part of #4890, into
drawings. Please merge this before the dimension text and title block text PRs (opened next, as drafts): each of them puts text on a sheet, so without this a dimensioned sheet, or any sheet with a title block, is refused as a PNG.Changes a default: no
No setting, command or saved data changes; sheets without text export as before.
What it does
In
crates/io/src/paper/png.rs:TextRun::outlines), the same function the SVG writer uses, so PNG and SVG can't disagree on where a glyph is.Sheet::traced); only the fill rule differs, even-odd for a filled shape and nonzero for a glyph.A finding about bands. The writer draws tall sheets in horizontal bands, to keep memory low. Its notes said the bytes are the same whatever the band. Text showed that isn't exact. Where a band's edge cuts a glyph, tiny-skia can cover an edge pixel one anti-aliasing step (one sixteenth) differently, and in black and white such a pixel can fall on the other side of the threshold. No seam shows. Exports use one band height, so a sheet exported twice gives the same bytes, and the background PNG writer (#10431) uses the same bands. The module notes now say so. Making it exact would mean cutting paths at band edges ourselves; that's left for later.
Validation
Local, Windows,
--profile ci, ondrawings69709bd:cargo check --all-targetsof geom, sketch, doc, io and engine; fmt; clippy-D warnings; iopapertests: 45 passed. The same code was also checked in a group with the text PRs above it: sketchpaper_text47, geompaper72, docdrawing90, enginedrawing337,schema191, and the engine's wasm build.Tests (in
png_tests.rs):Planted faults, each caught by a failing test, then a clean run: text not drawn; text filled even-odd; text's points not counted across runs.
Screenshots of the behavior
A sheet with dimensions and the built-in title block, exported as a PNG at 300 dpi (A3). Before this change, the PNG export of this sheet is refused. (The sheet's text comes from the dimension text and title block text PRs, applied on top.)
Integration status
One commit on
drawings69709bd (the latest when pushed). Our #10431 (the PNG written in the background) moves the writer's item loop; whichever merges second carries the text arm (one line) across. @0xlillith's #12071 adds tests at the end ofpng_tests.rs: at most a textual conflict there.