mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-02 10:47:31 -06:00
aaadba7b117bea79f8bd53dfc58718e7aed445e4
207
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ebc67fa81d |
Dynamic blocks: stretch the points inside the frame, as AutoCAD does (#2627)
* Dynamic blocks: stretch the points inside the frame, as AutoCAD does A dynamic block made by a third-party tool came out distorted when a distance changed: its stretch action has distance multiplier 0 with angle offset 1, and stored vertex lists that don't match its objects. apply turned the 0 into 1 but kept the angle (a 57 degree slant), and moved exactly the listed points. AutoCAD 2024, on a copy of that drawing, moved the block straight along the parameter, and every point of its lines and polylines exactly when it was inside the frame, whatever the lists said. So: - a zero multiplier moves as 1, without its angle offset; - a line's or lightweight polyline's moving points are those inside the frame where the dynamic block has them; a selected one wholly outside the frame moves whole, as in AutoCAD's own stretched copies; - a frame of fewer than 2 or more than 1,000 points keeps the stored lists, so a huge frame can't make every point test every edge. Against AutoCAD's own anonymous copies in two library drawings (556 references set back to their block's distances), 249 come back exactly on main and 258 with this change; none stops matching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Dynamic blocks: a point on a polygon frame's edge is inside it in_frame counted a point on a two-corner frame's edge as inside, but the even-odd test of a polygon frame put one on its right edge outside. A line whose end lay there, with its other end outside, then had no point inside the frame and moved whole instead of its end alone. A polygon frame now counts a point on an edge (within 1e-9, relative to the edge's length) as inside too, as the two-corner frame does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Dynamic blocks: frame edge tolerance by the edge's length; tilted polylines keep their lists A point counted as on a polygon frame's edge within 1e-9 * (1 + the edge's length), so never less than 1e-9 drawing units: in a tiny frame, a point visibly outside was taken as inside. The tolerance is now a billionth of the edge's length. A lightweight polyline's vertices are in its own plane. The reader flips a mirrored one (extrusion along -z) into the block's plane, but leaves a tilted one's in its OCS, which the frame (block coordinates) can't be tested against. A tilted polyline keeps the stored vertex list, as before the frame test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dynblock: only an exactly untilted polyline is tested against the frame; a tilted one keeps its stored list Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fmt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com> |
||
|
|
2034d6899e |
Polyface meshes stay one object through DXF and DWG (#2600)
* Polyface meshes stay one object through DXF and DWG A polyface mesh (POLYLINE flag 64) was read as loose 3D faces. It is now read, drawn, exploded into its 3D faces and written back as a POLYLINE. Hidden edges aren't drawn. A mesh too large for the 16-bit groups 71-74 is saved as 3D faces. Split from #1005. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A polyface face ends at its first zero index A face record with a gap ([1, 2, 0, 3]) has two corners and is dropped, not read as a triangle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Polyface meshes: write only faces that name their vertices; ID gives their Z The writer drops the faces the reader would drop, so no record names a missing vertex, and the 16-bit check only needs the counts. ID and DIST give a mesh the Z of its nearest visible edge, as they do for 3D faces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com> |
||
|
|
152617f4df |
Plot: a layout's saved page setup is used by default (part of #2493) (#2586)
* Plot: a layout's saved page setup is used by default (#2493) A layout whose page setup says plot window, scale to fit or a plot scale was plotted 1:1 from the sheet origin unless the caller passed fit. plot, exportpdf, the PNG device and preview now read the layout's saved window, scale to fit, scale and centring when the options don't say (render::paper::saved_plot); explicit options win, and fit: false without a scale is still the plain 1:1 sheet. Tests: saved_setup_tests in pdf.rs (four), and preview_uses_the_layouts_saved_page_setup_by_default. * Parity checklist: regenerated after merging main * Parity checklist: regenerated after merging main * Plot: saved page setup in preview and PNG matches the PDF (review on #2586) Preview honours the saved centre when fitting a window and an explicit scale beats a saved scale to fit (PDF too); PNG places a saved window without fit and clips to the printable area. * Preview: a saved window clips to the printable area (review on #2586) The preview drew the placed plot over the margins while the PDF and PNG blank them. The blanking helper now lives in the render crate and both the PNG plot and the preview use it. Test: preview_clips_a_saved_window_to_the_printable_area. * Preview: pin hostile saved page setups and the default setup (review on #2586) Degenerate or far-away saved windows and saved scales of 0 or not finite already fall back to the plain plot in the PDF, PNG and preview; tests now pin that, and that a layout with no saved setup plots as before. * Preview: the printable clip follows the view's fit (review on #2586) The clip assumed the sheet filled the image; when the height cap applies View::fit scales and centres it. The printable corners now go through View::to_screen. Test: preview_clip_follows_the_view_when_the_height_cap_applies. * docs: leave the generated parity checklist to maintainers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Brandon Thomas <echelon@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ccbc4fa854 |
DXF: link dimension sources to their associations (fixes #2221) (#2589)
* DXF: link dimension sources to their associations (#2221) Source objects lacked the persistent reactor back to their DIMASSOC. Register validated source and intersection references once through the existing reactor list, keeping a self-link from duplicating the dimension's own reactor. Synthetic regressions cover missing links, repeated references and self-links. * Parity checklist: regenerated for dimension reactor gate * Parity checklist: regenerated after merging main * DXF: a dimension source keeps its other reactors next to the DIMASSOC (review on #2589) The DIMASSOC reactor made the writer emit an ACAD_REACTORS group, so the raw passthrough skipped the source's retained foreign reactors. They are now merged, deduplicated, into that one group. Test: a line reactor-linked to a kept object keeps both links after an associative dimension is added. * DXF: an unmodelled DIMASSOC source gets the DIMASSOC reactor (review on #2589) Unknown entities are written by the raw passthrough, which never saw the planned reactors. The map is now passed to dxf_raw::finish and merged into the entity's reactor group. Test: an unknown entity with a dimension snapped to it names the DIMASSOC. * Docs: leave the file-format parity document to maintainers (review on #2589) * DXF: pass the unknown-entity reactors as one argument (review on #2589) * DXF: collapse the extension dictionary condition (review on #2589) * Test: pin the reactor merge for dimension sources (review on #2589) * DXF: a kept extension dictionary follows the reactors group (review on #2589) When a written record already had its reactors group, the kept extension dictionary was inserted right after the handle, ahead of it; the DXF reference puts the reactors first. The reactor tests now find each group by name, so either order can no longer pass. * docs: leave the generated parity checklist to maintainers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Brandon Thomas <echelon@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f0b46e34dc |
Hit tests don't lay out dashes: moving the mouse over a block stays smooth (#2603)
* Hit tests don't lay out dashes: moving the mouse over a block stays smooth (#1285) Every mouse move hit-tests the block references under the cursor, and hit_polylines built them with a full-detail display list, one primitive per dash. A fine pattern on long lines in a block inserted at 0.001 made millions of dashes per move. Options::linetypes off draws every line whole and continuous, and hit_polylines uses it for blocks, dimensions and multileaders. A dashed line in a block is now hit across its gaps, as one outside a block already was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * render: with linetypes off, a lightweight polyline is one continuous stroke Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Steffen <camperking@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com> |
||
|
|
2d02a5faa5 |
DXF: escape carets in TEXT, ATTDEF, ATTRIB and DIMENSION strings (#2574)
* DXF: escape carets in TEXT, ATTDEF, ATTRIB and DIMENSION strings
AutoCAD reads `^x` in a DXF string as a control character, so a TEXT of
`10^2` opened in AutoCAD showed a control character instead of the caret.
The DXF Reference writes a caret as `^` and a space: the writer now does
for the text (group 1) of TEXT, ATTRIB, ATTDEF and DIMENSION and an
ATTDEF's prompt (group 3), and the reader turns it back. A bare `^x` from
older files stays as it is; single-line strings keep `^J` literal (they
hold no line feeds). AutoLISP's entget shows the plain caret, and a
DIMENSION's style name (also group 3) is left as written.
Tests: crates/io/tests/it/text_carets_roundtrip.rs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* entget gives TEXT strings as the file has them, like MTEXT
Decoding the carets in entity_groups broke entmod (it reads the groups
as a file, so `A^ B` came back as `A^B`) and reached into an ATTDEF's
embedded MTEXT. entity_groups is left as on main: it gives the file's
groups, as it already does for MTEXT, and entmod reads them back
unchanged (test entmod_of_entget_keeps_the_strings).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* entget unescapes carets, entmake and entmod escape them
|
||
|
|
5cc342b033 |
DXF/DWG: viewport frozen layers as group 331 (341 in an R2000 DXF) (#2575)
* DXF/DWG: viewport frozen layers as group 331 (341 in an R2000 DXF) AutoCAD 2004 and later, and the DWG converter, read a VIEWPORT's frozen layers from group 331; CADCraft wrote only group 341 (the DXF 2000 form), so a DWG or 2004+ DXF lost the freeze outside CADCraft, and a file frozen only in group 331 (as AutoCAD 2026 and ezdxf write it) lost it on the first save. Now: group 341 in an R2000 DXF, 331 otherwise and for the DWG bridge; both are read, each layer once. CADCraft's own xdata still wins. Tests in crates/io/src/tests.rs, including a_331_only_viewport_freeze_survives_open_and_save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Leave the parity docs to the maintainers CLAUDE.md: PRs don't edit the parity docs; the affected rows are named in the PR description instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Viewport frozen layers: group 331 wins over stale xdata AutoCAD now sees the freeze in group 331, edits it, and keeps CADCraft's VPFROZEN xdata as it was. Reading preferred the xdata, so a layer thawed in AutoCAD came back frozen. The handles now win; the xdata still gives names that have no LAYER record, and the whole list for records without handles (entget/entmod, older files). The handles are written before group 90, as in the DXF Reference. Test: viewport_frozen_331_wins_over_the_xdata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Viewport frozen layers: handles for real layers, xdata only for the rest Simpler and safe against edits in AutoCAD. A layer with a LAYER record is written only as a handle (331, or 341 in an R2000 DXF); CADCraft's VPFROZEN xdata now holds only the names with no record (and the whole list for entget, which writes no handles). Reading takes the handles, then the xdata names, each layer once: no precedence, and a viewport thawed in AutoCAD (even its last frozen layer) stays thawed, since no stale list is left behind. The reader no longer builds a layer-name set per viewport. Tests: viewport_frozen_layers_read_from_331_or_341_once_each, viewport_freeze_edited_in_autocad_is_read_as_edited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Viewport frozen layers: skip 102 application groups A group 331 inside another application's `102 {…}` group isn't a frozen layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c72c0eebfb |
SAVEAS portableFonts: Windows fonts for Linux text style fonts (#2576)
* SAVEAS portableFonts: Windows fonts for Linux text style fonts
A text style using a Linux TrueType font (Liberation, DejaVu, Open Sans)
shows in AutoCAD on Windows with a substitute it picks. A save now names
those styles on the command line (and as `nonPortableFonts` in the
result), and SAVEAS {"portableFonts": true} writes the Windows equivalent
in the file (Liberation -> Arial, Times New Roman, Courier New; DejaVu
Sans -> Verdana; Open Sans -> Arial) while the drawing keeps its own
fonts. Narrow and condensed families have no Windows stand-in (Arial
Narrow comes with Office) and are kept and named. QSAVE takes no SAVEAS
options.
Tests: stand_in_tests in cmd/file.rs, tests/save_portable_fonts.rs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Portable fonts kept in the file, applied by the writer
Reworked after review. SAVEAS `portableFonts` writes a copy of the drawing
with `Drawing::portable_fonts` set, and the DXF/DWG writer turns each
style's Linux font into its Windows font, keeping the style's own font in
the CADCraft FONT xdata already used for the built-in font. Reading the
file gives the Linux fonts back (unless the font was changed since, in
AutoCAD); the drawing itself is never changed.
It applies to that save: a later QSAVE writes the drawing's fonts and
says so, naming the styles and SAVEAS portableFonts. The family table
moves to `cadcraft_fonts::windows`, used by the writer and the note.
Styles from an xref aren't saved and aren't named. The parity docs are
left to the maintainers (CLAUDE.md).
Tests: crates/io/tests/it/portable_fonts.rs (DXF, DWG, a font changed in
AutoCAD), crates/engine/tests/save_portable_fonts.rs, windows.rs tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Portable fonts: match the Windows font by file name
A STYLE whose Windows font carries a path (C:\Windows\Fonts\…) still
gets its own font back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Portable fonts: say the font list again only when it changes
A save still returns nonPortableFonts, but the command line note isn't
repeated on every QSAVE of the same drawing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
7cee28580d |
fix(dxf): preserve 3D LEADER vertex elevations (#2245) (#2397)
Co-authored-by: Zaxaerith <189452125+Zaxaerith@users.noreply.github.com> |
||
|
|
737f8a2ec6 | Merge remote-tracking branch 'origin/main' into pr-2467 | ||
|
|
c808939bd1 | Merge remote-tracking branch 'origin/main' into pr-1693 | ||
|
|
5bc93ccf18 |
test(io): add independent DXF/DWG conformance and preservation matrices (#2237)
* test(dxf): add deterministic codec and drawing round-trip matrices Exercise typed tags and model-space LINE/CIRCLE/TEXT through in-memory ASCII and binary DXF at every save version. Compare both reads with the original model and check independent handwritten byte/entity fixtures. Keep desired-behaviour tests for extrusion and ByBlock plot-style loss explicitly ignored until fixed. No production or docs changes. * test(dxf): independently verify common entity properties * test(io): add a broad DWG preservation matrix with focused pending regressions Share deterministic Drawing cases and exact assertions between DXF and DWG without reducing DXF coverage. Run representable DWG cases at all six save versions, twice in RAM. Test R2000 color/transparency and the single TEXT elevation as explicit format limits. Keep six independently reproduced loss regressions ignored without weakening comparisons. No production or docs changes. * test(io): close binary-width and referenced-linetype coverage gaps Check every integer group range against independently constructed binary payloads, catching shared reader/writer width mistakes. Resolve linetypes with Drawing lookup and compare layer linetypes too. Add missing/changed-reference self-tests and inherited-pattern DXF/DWG round trips. Reproduced the review counterexamples before and after; full CI passes with two nextest threads. Test-only changes. * test(io): expand DXF and DWG matrices across entities and drawing collections Add basic coverage for all 29 modeled entity kinds, block graphs and attributes, all ACI colors, richer properties/XDATA, sparse handles, headers, symbol tables, views, groups, layouts and foreign payloads. Preserve typed fields and authored references through two RAM saves. Add independent DXF groups and native DWG bridge checks, plus explicit refusal-or-preservation tests for unknown entities. Keep confirmed discrepancies and unresolved preservation contracts as focused ignored tests; native linetype angles and silently dropped unknown DWG entities are independently reproduced. Version limits and foreign object handle remapping are explicit contracts, not blanket normalization. Tests only; no production or docs changes. Full CI passes with two nextest threads: 2777 passed, 27 skipped. * test(io): cover bounded property domains and targeted field interactions Independently check all ACI values and transparency percentages, native layer/style flag combinations, and literal large handles. Add shared DXF/DWG cases for alignment with mirrored styles, inherited versus explicit zero properties, repeated nested attributes, and integer-boundary handles. Keep exhausted handle allocation separate: DWG refuses the save; a focused ignored DXF regression reproduces silent loss of all nine model entities. No production or documentation changes. Validation: full cargo xtask ci with NEXTEST_TEST_THREADS=2 passes all seven gates (2792 passed, 28 skipped). The pending DXF regression fails explicitly when run with --ignored. * test(dxf): separate chunk conformance from binary reader tolerance Address PR #2237 review: shared exact-tag round trips only use hex chunks within the documented 127-byte group limit. Independently inspect ASCII and binary writer bytes, reassemble payloads, and verify following-record framing. Keep full 0..255 length-byte read tolerance in handwritten fixtures, not as a claim of conforming writer output. Add two focused ignored regressions for oversized ASCII/binary output, reproduced with 128-byte payloads. They extend existing issue #1025. No production changes. Validation: cargo xtask ci passes all seven gates with nextest 0.9.150 and two test threads (2782 passed, 30 skipped). Both new pending checks fail explicitly when run with --ignored. * test(io): compare DWG dimension blocks through their references Anonymous dimension-block suffixes may change between drawing sessions (Autodesk documentation; ODA DWG section 20.4.52.1). Resolve their names through preserved dimension identities and keep strict checks for cache content, entity handles, block properties and reference integrity. Enable the pending dimensions test across all six DWG versions and two saves. Add a paired-cache fixture and comparator controls rejecting swapped/merged/dangling references, geometry and property changes, stale caches, and named-block renaming. Leave the shared comparator and DXF contract unchanged. Validation: cargo xtask ci (all seven stages; 2786 passed, 29 skipped); roundtrip matrix (211 passed, 26 ignored). Resolves the preservation-contract decision in #2257 (tracker #2238, B4); no production codec fix. * test(io): specify WIPEOUT explicit closure on roundtrip An implicit WIPEOUT boundary gains one explicit closing marker in DXF/DWG. Compare against independently authored explicit boundaries in both winding directions across all six versions and two saves; retain strict field and resave comparisons. Enable the two pending closure checks without changing the shared comparator. Distinguish this valid file representation from the grip-edit defect: the latter is fixed separately in PR #2284, with engine, outline and rendering regressions. No production change in this test-only branch. Validation: cargo xtask ci, all seven stages passed (2788 passed, 27 skipped); active roundtrip matrix 213 passed; remaining ignored checks reproduce 24 drawing failures and two codec failures. One unrelated HTTP control-server test failed transiently, then passed in isolation and in the full rerun. Related #2256 and tracker #2238 B3. * test(io): expose multiline ATTRIB alignment corruption Keep the original origin witness and add distinct nonzero TEXT/MTEXT anchors. An active R2018 ASCII/binary two-save check verifies world-space multiline geometry and value edits; this does not excuse corrupted fallback TEXT fields. Retain the strict pending #2255 check and add comparison of independently downgraded R2000/R2004 geometry. The observed Left -> Center change is a real reader error, not permitted alignment-point canonicalization. The reader hunk from existing PR #1942 makes the extended strict check pass in an isolated experiment; no competing production fix is included here. Validation of this test-only tree: all seven cargo xtask ci stages pass (2789 passed, 27 skipped); active matrix 214 passed; remaining 24 drawing and two codec diagnostics still fail. An unrelated HTTP control-server test failed transiently, then passed alone and in the complete rerun. Related #2255, #1942 and tracker #2238 B2. * test(io): separate ATTRIB value and legacy-placement guarantees Assert exact saved ATTRIB values, read_as and authored embedded MTEXT contents before and after value edits. A mutation test rejects corrupt fields, including a value/read_as pair whose rendered geometry remains unchanged. Make legacy placement an independently runnable pending regression instead of a callback behind the failing field comparator. Compare direct R2000/R2004 exports with exports after one/two R2018 roundtrips, both encodings in each stage, and verify that the primary single-line fallback actually survives. Keep all three contracts local and distinct; remove the old cross-module callback. The new legacy test fails directly on world-space geometry with the unchanged reader. Both pending ATTRIB tests pass with the reader hunk from existing PR #1942 in an isolated experiment (548 IO tests also pass). No production fix is included. Validation: all seven cargo xtask ci stages pass with NEXTEST_TEST_THREADS=1 (2790 passed, 28 skipped). Earlier parallel runs and one isolated retry hit pre-existing HTTP/busy control-server failures; no exclusions or test changes. Active matrix 215 passed; all 25 drawing and two codec pending diagnostics still fail. Addresses review of #2237; related #2255, #1942 and tracker #2238 B2. --------- Co-authored-by: cloudj <jonbahnes@gmail.com> |
||
|
|
9c0c02f917 | Merge main into #2467 | ||
|
|
8822462be2 | Merge main into #1693 | ||
|
|
4792ca2941 |
fix(io): a centred ATTDEF keeps its insertion point in a DWG (#2464) (#2466)
* test(io): a centred ATTDEF keeps its insertion point in a DWG (#2464) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): an ATTDEF with no default value is placed by its tag's width in DWG (#2464) The writer keeps a justified text's stored insertion point only when it is near where the baseline starts for the text's width; an ATTDEF with an empty default value has width 0, so every AutoCAD insertion point further than half a height from the alignment point was replaced by the alignment point. The tag is what is drawn: judge against its width. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): keep a stored ATTDEF point that is close to the empty text's start The tag-width baseline check replaced a point read from a drawing whenever the font's width of the tag put the computed start further than the allowance away, e.g. a centred LONGTAG with group 10 at x=99.5 and group 11 at x=100 moved to about 92.17 in DXF and DWG. A stored point close to the empty text's own start is now kept as before; only otherwise is it judged against the tag. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(io): store an ATTDEF point that differs from the computed baseline `assert_kept(start)` stored exactly the baseline the tag-width fallback computes, so a write that replaced group 10 with that baseline passed too. The point is now 1 off the start, within the tolerance. Review of #2466. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(io): an empty-value ATTDEF keeps its point with an empty or absent prompt too The tag-width check applies to every ATTDEF with no default value, since the CAD displays the tag whatever the prompt: the guard now says `attdef` instead of reading as a prompt test, and the test covers a prompt, an empty one and none. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
b4b8ae294a |
fix(io): write a LINE's extrusion (210/220/230) (#2241) (#2417)
* test(io): a LINE keeps its extrusion through DXF and DWG (#2241) `line_extrusion_roundtrips_with_world_endpoints` (red: group 230 is not written for a LINE with normal (0, 0, -1), so it comes back with (0, 0, 1)). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): write a LINE's extrusion (210/220/230) (#2241) A LINE's points are world coordinates and the reader already keeps its extrusion (the direction of its thickness), but the writer left the groups out, so a normal (0, 0, -1) came back as (0, 0, 1) from DXF and from DWG, which is written through DXF. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(io): a LINE's extrusion is written as a unit vector or not at all (#2241) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): write a LINE's extrusion normalized, nothing for a zero or NaN normal (#2241) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): write a tiny extrusion's direction, drop a non-finite one Vec3::normalized returns zero at or below the drawing tolerance, so a LINE with extrusion (0, 0, -1e-10) saved with no 210/220/230 and reopened as +Z, flipping a thickness; an infinite component normalized to NaN and was written as a zero vector. The writer now normalizes by the vector's own length and writes nothing only for a zero or non-finite vector. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): keep the direction of a huge finite extrusion The length of (0, -1.5e308, 1.5e308) overflows to infinity, so the normal came out as (0, 0, 0) and was written as such. The vector is scaled by its largest component before it is normalized; the case is in `line_extrusion_is_written_as_a_unit_vector_or_not_at_all`. Review of #2417. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
85fc3991b1 |
fix(io): an attached ATTRIB keeps its Constant mode through DXF and DWG (#2246) (#2418)
* test(io): the Constant mode of an attached ATTRIB survives DXF and DWG (#2246) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * fix(io): an attached ATTRIB keeps its Constant mode through DXF and DWG (#2246) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test(io): attached ATTRIB Constant mode over every save version and encoding The regression covered the default DXF and DWG saves only. It now also saves with each Version::ALL entry as ASCII DXF, binary DXF and DWG. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
9b7149676b |
fix(io): MTEXT legacy column groups no longer leak into the entity (#2247) (#2416)
* test(io): MTEXT legacy column groups stay in the AcDbMText subclass (#2247)
`legacy_column_groups_stay_in_the_mtext_subclass` (red: the column width 48 is read as the
entity's ltscale, 12.5; the height count 50 as a column height).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix(io): MTEXT legacy column groups no longer leak into the entity (#2247)
`common()` read the linetype scale (48) and the other AcDbEntity groups from the whole record,
so the column width 48 of an MTEXT's legacy column groups became its ltscale. They are now read
from the AcDbEntity subclass only. `read_columns` took the height count (the first 50) for a
column height and `column_tags` did not write it; both follow the DXF layout now.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* test(engine): the MTEXT entmake column heights carry their count (#2247)
Group 50 after the column type is the height count, then the heights. Thanks to austin62jake for the report and the fix.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* test(io): a marker-less MTEXT with an embedded object keeps its own ltscale (#2247)
Case from #2276 (Zaxaerith): without subclass markers, the 48 of an embedded object (101) was read as Common.ltscale.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix(io): stop the entity's own groups at an embedded object (#2247)
Without subclass markers, an embedded object's 48 was read as Common.ltscale. Suggested by austin62jake; case and test from #2276 (Zaxaerith).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* style(io): rustfmt the new MTEXT test
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix(io): keep layer and colour that follow a subclass marker in a list with no AcDbEntity marker
entity_groups ended the common region at the first subclass marker other than
AcDbEntity, so an entmake list such as (0 . "LINE") (100 . "AcDbLine") (8 . "Walls")
was read on layer 0. The region now ends at a marker only when the record has an
AcDbEntity marker (files from R13 on always do); other records are read as a
whole up to an embedded object (101), as before the column change.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
* fix(io): markers inside an application-defined group do not end the entity's groups
A `102 {...102 }` group before AcDbEntity may hold any code, 100 and 101 included: `entity_groups` stopped there and the layer and colour that followed fell back to defaults. The scan now skips the contents of such groups when looking for the AcDbEntity marker and for the end of its groups. Review of #2416.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* fix(io): keep every column height of files written before the height count
CADCraft up to
|
||
|
|
1ecc2a130b |
DXF: no CLASS instance counts in R2000 files (AutoCAD LT 2026 hung opening them) (#1060)
* DXF: no CLASS instance counts in R2000 files (AutoCAD LT 2026 hung on them) Since #635 every CLASS record carries group 91, the instance count, at every version. The count came with the 2004 format: R2000 CLASS records are 1, 2, 3, 90, 280, 281. AutoCAD LT 2026 stops responding when it opens an R2000 DXF whose CLASS records have a 91, so every R2000 file CADCraft saved locked it up (a drawing opened from an R2000 file is saved as R2000 again). Isolated black-box in AutoCAD LT 2026 with synthetic files: the same R2000 file without the 91 groups opens, as does the same content declared AC1032. The counts are now written only when the file (or the DWG the bridge writes) is 2004 or later; R2000 output drops the group from every CLASS record, classes kept from a newer file included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Test: binary R2000 drops group 91 from a kept foreign CLASS too Review follow-up: the kept-class check covered R2000 only through ASCII saves; it now also saves the fixture as binary R2000 and checks that the ACME_OBJECT CLASS record is 1, 2, 3, 90, 280, 281. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Test: binary 2018 keeps a kept foreign CLASS's instance count Review follow-up: the kept-class check now saves the fixture as binary at both R2000 (no group 91) and 2018 (group 91 after the proxy flags, with the class's count), through one helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Slopapalooza <307952167+Slopapalooza@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0ab812c12a |
fix(io): write $PSTYLEMODE as read, in DXF and DWG (#2400)
* test(io): `$PSTYLEMODE` round-trips through DXF and DWG (#2332) Red test: a drawing read from a DXF with `$PSTYLEMODE` 0 (named plot styles) is written back without the variable, so readers default to colour-dependent plot styles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(io): write `$PSTYLEMODE` as read, in DXF and DWG (#2332) `HEADER_VARS` did not list `$PSTYLEMODE`, so a drawing read from a named-plot-style file (0) was saved without it; the DWG bridge then defaulted to colour-dependent plot styles (1) and the plot came out with thicker edges. One more entry in the list; a drawing that never had the variable still writes nothing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: assamaral <217119886+assamaral@users.noreply.github.com> |
||
|
|
8038de04e4 |
fix(io): an MTEXT with columns takes its width from the column groups
ZWCAD and AutoCAD write the total width of the columns in the entity's group 41 and the column width in the embedded object's 44 (48 of the legacy groups). `mtext_from` took 41 whenever it was positive, so a three-column MTEXT of 50 came back 175 wide and the R2018 object was written with 44 = 175, 42 = 550. With columns and a positive column width, that width is the MTEXT's (it is one column's throughout). Review of #2467. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
189bfcbf08 | Draw annotative text with Match orientation to layout upright, ignoring its stored rotation (#2498) (#2504) | ||
|
|
0ae424c771 |
fix(io): derive the column count of a dynamic auto-height MTEXT from its widths
An R2018 dynamic auto-height embedded object stores 0 in group 72 even with several columns, and the clamp turned it into one. With 72 at zero the count is now (42 + 45) / (44 + 45), the inverse of the total width the writer emits. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
b883d94bf7 | Merge upstream/main into fix/mtext-embedded-columns-2248 | ||
|
|
d6de2db6db |
Update prompt shows the app icon and accent color instead of a letter (#2479)
UPDATE_APP (native builds; craft-update is a native-only dependency) carries our 128 px icon and accent (#3ea6e8, its colour in ArtCraft Launcher). The updater, the self-update helper and craft-update's startup prompt all get them through crate::UPDATE_APP; the prompt draws the icon, the accent and "by ArtCraft" (craft-update's default developer). craft-update is pinned to storytold/craft-libs main at 1065653e7 (#434). Clippy fixes for Rust 1.99 in untouched code (same logic): - crates/constraints/src/auto.rs - crates/engine/src/audit.rs - crates/engine/src/cmd/inquiry.rs - crates/engine/src/mtext_edit.rs - crates/geom/src/nurbs.rs - crates/io/src/dxf_raw.rs - crates/io/src/dxf_read/document.rs - crates/render/src/text.rs - crates/ui-egui/src/cmdline.rs - xtask/src/layers.rs |
||
|
|
2d2be155dd |
fix(engine): refresh attribute baselines after value changes (#2214)
* xtask: the test suite and clippy pass on Windows
Two Windows-only failures stopped `cargo xtask ci` before it got going on
a Windows checkout (CI runs the gate on Linux only, so neither showed):
- parity::tests::civil_dates built a SystemTime 115,740,740 days after
the epoch (year 318857). Windows' SystemTime ends in the year 30828, so
the addition panicked ("overflow when adding duration to `SystemTime`").
That case now checks `civil_from_days` on the day count, which is what
it was about, on every platform.
- stats.rs imported `walk` for a test that only exists on Unix, so the
import was unused on Windows and `clippy -D warnings` refused it. The
Unix test calls `super::walk`, as its neighbour calls `super::walk_inner`.
Checked on Windows 11 x64: `cargo test --workspace` and
`cargo clippy --workspace --all-targets -- -D warnings` both pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(engine): refresh attribute baselines after value changes
CC-046: invalidate the derived XY baseline for changed justified attribute
values, including small changes inside the writer's imported-font tolerance.
Preserve no-op placement, alignment anchors and Aligned/Fit endpoints.
Regression reproduced on current upstream; all three focused tests pass.
Full cargo xtask ci passed all seven stages on Windows (2558 passing test
executions, zero failures, one ignored). Release Trunk web build passed.
Browser interaction verification is pending user dismissal of a Windows
Security prompt; do not treat the build as a runtime pass.
Windows validation prerequisite: original upstream PR #2198 commit
|
||
|
|
912558635e |
DWG: keep block draw-order sort handles through the DXF bridge (#2410) (#2439)
* DWG: keep block draw-order sort handles through the DXF bridge (#2410) acadrust's DXF writer renumbers SORTENTSTABLE sort handles past every entity handle, so an entity left out of a table (sorted by its own handle) drew below every listed one. The table now carries its codes verbatim before writing. Tests in io/tests/it/sortents.rs; the bridge test fails without the fix. * Parity checklist: regenerated after merging main * DXF: a block/space sort handle of 0 draws last (#2439) A SORTENTSTABLE sort handle of 0 means the entity is drawn after every other (ezdxf reorder.py, which notes AutoCAD defines it). apply_sortents sorted it first; key it after all nonzero handles. Test: a_zero_sort_handle_draws_last (DXF and DWG bridge). * Parity checklist: regenerated after merging main * Draw order: test two block entities left out of a SORTENTSTABLE (#2439) Each unlisted entity must sort by its own handle, landing between the listed ones. A single fallback key for all of them would put them side by side. Checked in a DXF and across the DWG bridge; test-only. --------- Co-authored-by: Brandon Thomas <echelon@gmail.com> |
||
|
|
dcbcb6ab32 |
fix: keep WIPEOUT closure coherent across grips and outlines (#2284)
* fix: keep WIPEOUT closure coherent across grips and outlines Treat WIPEOUT as a closed polygon with an optional exact terminal closure marker, not as an open polyline. Centralize logical vertices, explicit outlines and closure-preserving vertex edits in the document type. Reuse this contract in grips, geometric primitives, rendering and DXF export without changing the stored schema or writer closure convention. Add six-version DXF ASCII/binary and DWG regressions for implicit/explicit closure, both windings, all corners, API/interactive edits, undo/redo and repeated saves. Keep open/closed polylines and their coincident endpoints distinct. Cover multiple hot grips, hostile inputs and equivalent mask/frame output. Validation: cargo xtask ci, all seven stages passed (2571 tests passed, one pre-existing skip). Two unrelated network tests failed transiently in earlier runs; each passed in isolation and the complete final run passed without exclusions. Direct and reopened grip edits produce byte-identical CLI PNG output. Fixes #2256; related test-only matrix PR #2237 and tracker #2238 B3. * fix(doc): keep coincident WIPEOUT endpoints separately editable When an edit makes the endpoints of an implicit boundary coincide, add a separate closing marker rather than reclassifying the edited corner as that marker. Retain the logical vertex count and allow either coincident corner to move independently afterwards. The document regression fails before the fix. Add API/interactive coverage for both endpoint directions and both closure forms, undo/redo, and subsequent separate edits across all six DXF/DWG versions including binary DXF and save-after-edit. Update the documented editing contract. Validation: cargo xtask ci passed all seven stages; 2573 tests passed, one pre-existing skip. Addresses the coincident-endpoint review on PR #2284; related #2256. --------- Co-authored-by: cloudj <jonbahnes@gmail.com> Co-authored-by: Brandon Thomas <echelon@gmail.com> |
||
|
|
bcf0dbc5e8 |
DWG: keep the current layer (CLAYER) through a save and reopen (#2252) (#2407)
* DWG: keep the current layer (CLAYER) through a save and reopen (#2252) The DWG header stores the current layer as a handle, and the one read from the DXF needn't be the layer's in the document, so the drawing reopened on layer 0. The bridge now resolves CLAYER by name to the layer's handle before writing, like the current text and dimension styles. Test: the_current_layer_round_trips_through_dwg. * Parity checklist: regenerated after merging main * DWG: resolve $CLAYER through the layer table's Unicode-aware lookup (#2252) eq_ignore_ascii_case missed non-ASCII case differences such as Survey_Ä / Survey_ä, leaving layer 0 current. acadrust's Table::get normalises names with to_uppercase. * DWG: test a current layer named in other letter case (#2252) |
||
|
|
c5d186ae92 |
fix(io): the embedded column object carries the column height like AutoCAD's (#2248)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
9ff37ba262 |
fix(io): an MTEXT's R2018 embedded column object is kept and its groups stay out of the entity (#2248)
The reader took the embedded object's 44 (column width) as the MTEXT's line spacing factor and dropped its columns; the writer wrote no embedded object, the legacy column groups (which R2018 ignores) and a drawing direction of 1 instead of 5 (by style). Now the embedded object is read (type, count, width, gutter, heights), written for R2018 and later, and the MTEXT's own groups are the ones before it. AutoLISP entget keeps the legacy groups. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
4226a2610a |
test(io): an MTEXT's R2018 embedded column object is read and written (#2248)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
5654240729 |
refactor(cli): parse cadcraft-cli arguments with clap, following RFC-0012 (#2268)
* test(cli): pin today's command-line behaviour
The later commits change these tests on purpose, so each behaviour change shows in their diff.
* refactor(cli): split main.rs into modules, move only
- output: outln!, stdout state, atomic write, export helpers, view/window helpers
- args: USAGE, option validation, framing options, MCP argument parsing and its tests
- info, convert, sample, mcp: one subcommand each
- perf: synthetic drawing, Rng, perf subcommands
- run: run subcommand and {last} handle chaining
- main: crate docs, mod lines, install_io, open, main, cli, unit tests
No behaviour change.
* refactor(cli): typed errors and run(args, out, err)
cadcraft-cli is now a library plus a thin binary. `cadcraft_cli::run(args, out, err)
-> i32` is the whole program; main.rs only passes `args_os()` and the process
streams. Handlers write through a `Streams` wrapper (output.rs) instead of the
process streams; it keeps the closed-stdout semantics (drop later output, carry
on, a closed pipe is not an error, other write errors are reported once and make
the exit code 1). `mcp` still speaks MCP on the real stdin/stdout.
Errors are typed (thiserror): CliError (error.rs) wraps EngineError, DocError,
IoError, io::Error and the per-module WindowError, ArgsError, RunError,
OutputError and PerfError. `run` prints `error: {e}` and exits 1.
The usage text and the "unknown option/argument" messages stay as one
transitional CliError::Usage(String), printed without the `error: ` prefix.
USAGE stays a const; step 4 (clap) removes both. The engine's IoHooks take
`Result<_, String>`, so the three `.map_err(|e| e.to_string())` in install_io
remain. The hooks are set-once (OnceLock), so installing them on every `run`
call is harmless.
tests/it/usage.rs calls `run` in-process with Vec<u8> writers; the headless mcp
case runs through the binary (it reads the real stdin) and a non-Unicode
argument test is new.
Behaviour changes (old -> new):
- Every error line other than the usage-class ones gains the prefix `error: `
(e.g. `--view needs ...` -> `error: --view needs ...`, `unknown command
`x`` -> `error: unknown command `x``, `invalid parameters for `open`: ...`
-> `error: invalid parameters ...`, `unsupported file type` likewise).
- `cadcraft-cli: cannot connect to HOST:PORT: e` -> `error: cannot connect to
HOST:PORT: e` (the old prefix is replaced).
- A non-Unicode argument: panic, exit 101 -> `error: argument "..." is not
valid Unicode`, exit 1.
- Unchanged: usage text, `X: unknown option --y`, `unknown option --y`,
`mcp: unknown argument ...` (no prefix); warnings and `wrote ...` lines;
the `cadcraft-cli: can't write to stdout: e` report; exit codes.
* refactor(cli): parse arguments with clap
Replace the hand-written parser (USAGE, validate_options, OptionSpec,
framing_option, parse_mcp_args, CliError::Usage) with clap derive types
in args.rs: a Cli parser and one Args struct per subcommand, with the
framing flags (--window, --view) in a FramingArgs struct flattened into
convert and run. USAGE's framing and --cmd chaining text moves into the
subcommands' and flags' doc comments and run's long help, so --help
carries it. `commands` moves from an inline closure to commands.rs.
`command()` exposes the clap definition for man pages and completions.
clap reads the arguments as OsStrings. Help and --version go to stdout
with exit 0; usage errors are clap's, on stderr with exit 2. A bare
--help or -h before `--` shows the subcommand's help even after a
mistake on the line (`run --script --help`). run opens its drawings
(FILEs, --sample, --metric) and runs its steps (--script, --script-file,
--cmd) in command-line order, from ArgMatches::indices_of. Values stay
strings checked by the handlers, with their messages and exit 1
(--window, --view, --cmd JSON, sample names, perf counts). The last of a
repeated flag wins (args_override_self on every subcommand but mcp).
Behaviour changes:
Help and version
- --help, -h, help: the USAGE page -> clap's help, first line
"cadcraft-cli: headless CADCraft".
- bare cadcraft-cli: USAGE on stderr, exit 1 -> clap's help on stderr,
exit 2.
- <subcommand> --help / -h, help <subcommand>: "unknown option --help"
(exit 1), the USAGE page (convert, help <subcommand>) or a file named
-h (info -h, run -h) -> that subcommand's help, stdout, exit 0.
- <subcommand> --version: "unknown option --version", exit 1 -> clap's
unexpected argument, exit 2.
Usage errors (exit 1 -> exit 2, clap's messages)
- Unknown subcommand, empty subcommand, unknown top-level flag: USAGE ->
"error: unrecognized subcommand 'foo'" / "error: unexpected argument
'--bogus' found".
- Unknown flag on any subcommand: "info: unknown option --bogus",
"unknown option --bogus", "mcp: unknown argument --bogus" or USAGE
(convert) -> "error: unexpected argument '--bogus' found".
- A short flag where a file is expected (info -x): opened as a file ->
unexpected argument; `--` before it keeps it a file name.
- A value flag at the end or followed by a flag (--window, --view,
--script, --script-file, --cmd, --save, --export, --connect): "error:
--script needs text" and the like, or the next flag taken as the
value (--window --view, --script --sample, --cmd --sample,
--script-file --sample) -> "error: a value is required for '--script
<TEXT>' but none was supplied". --connect followed by an unknown flag
(--connect --foo, --connect -v) names that flag instead (clap reports
the unknown argument, not the missing value).
- mcp --connect with an empty value: "error: --connect needs HOST:PORT
..." -> "error: invalid value ' ' for '--connect <HOST:PORT>':
expected HOST:PORT (...)"; --connect=-v likewise.
- mcp --connect twice: "error: --connect given more than once" ->
"error: the argument '--connect <HOST:PORT>' cannot be used multiple
times".
- mcp --lazy / --launch without --connect: "error: --lazy and --launch
need --connect HOST:PORT" -> "error: the following required arguments
were not provided: --connect <HOST:PORT>".
- Missing positionals (info, convert with 0 or 1 files, sample with 0
or 1 arguments): USAGE -> "error: the following required arguments
were not provided".
- Extra positionals: convert with three files (USAGE), and info,
commands, perf, sample, which ignored the extra argument -> "error:
unexpected argument 'extra' found".
- perf -5: opened as a file -> unexpected argument '-5'.
- A non-Unicode argument where text is expected: "error: argument ... is
not valid Unicode", exit 1 -> "error: invalid UTF-8 was detected in
one or more arguments", exit 2.
Accepted where they were errors
- --x=v is a spelling of --x v for every value flag (--window, --view,
--script, --script-file, --cmd, --save, --export, --connect); before
it was an unknown option or USAGE. A value starting with - needs the
= form (--cmd=-x).
- commands --: "unknown option --" -> `--` ends the options (all
commands listed).
- run --view extents --view current: "use only one of --window and
--view" -> the last wins, like every other repeat.
Other
- run --sample --sample opens one sample drawing (was two): repeated
flags are last-wins.
- run checks --window/--view values before opening any drawing, so a
bad framing value is reported ahead of a missing file.
- `-h` after a mistake shows the long help (`--help`): the retry asks
for --help.
Unchanged: --window with --view, framing without an image output,
--view's case-insensitivity, all value messages (--window numbers,
--view values, --cmd JSON, {last}, sample names, --script-file read
errors), multiple FILEs, --sample with --metric or a FILE, last-wins
for --save, --export, --window, --script/--cmd order, and `\n` in
--script.
clap forced: exit 2 for usage errors, its message wording, and the
unknown-flag-over-missing-value precedence above.
* refactor(cli): reject repeated flags, long version (photocraft#7071 decisions)
Behaviour changes, old -> new:
- --save, --export, --window, --view, --sample, --metric, --lazy, --launch given twice:
last one won -> usage error, exit 2 ("the argument ... cannot be used multiple times").
--connect was already rejected. --script, --script-file, --cmd and run's FILEs still repeat.
- --version / -V: "cadcraft-cli <version>" -> "cadcraft-cli <version> (<sha>)", sha from
CADCRAFT_BUILD_SHA or "dev", as the desktop app prints it.
- "cadcraft-cli version" is an unrecognized-subcommand usage error (as before; now tested).
- A value starting with "-" needs the = form for every value flag (as before, tested).
--window -10,-10,10,10 stays a usage error ("unexpected argument -1"); write
--window=-10,-10,10,10. clap's allow_negative_numbers does not accept a comma list, and
allow_hyphen_values would let --window swallow the next flag, so neither is set. The
--window help text names the = form.
* refactor(cli): typed values and flag relations
Step 6 of #2228: values are parsed into their types and flag relations
are checked at parse time, so a bad value or combination is a usage
error (exit 2) naming the flag, before any work starts. The handlers
receive typed values only. Runtime failures (files, the engine, a
`{last}` with no earlier handle) stay exit 1.
- --window parses to a Bounds2 (parse_window plus cadcraft_io's
check_window); its WindowError is the value parser's error.
- --view is a ValueEnum (extents, current), case-insensitive; the long
help lists what each value does.
- --window conflicts_with --view. In run, --window/--view require
--export (an ArgGroup "framing" with requires). A framing flag with
an output that isn't an image (convert's OUT, run's --export) is a
UsageError turned into a clap error by into_clap (ArgumentConflict).
- sample's name is a ValueEnum (bracket, floorplan); `floor` stays a
hidden alias.
- perf's N|FILE is one typed positional: a value that parses as a
count is one, clamped to 1..=20000000 as before (so `perf 0` still
times one entity); anything else is a drawing.
- --cmd 'id {json}' parses to an id and a serde_json::Value (default
{}); `{last}` is still filled in when the command runs.
- Paths are PathBufs (info FILE, convert IN/OUT, run FILEs,
--script-file, --save, --export, sample OUT, perf FILE). The engine
and io crates take file names as text, so a path that isn't valid
Unicode is refused by the handler, naming the file (exit 1).
- Deleted: check_framed_output, the --view match, ArgsError,
CliError::Window/Args/UnknownSample, RunError::CmdJson,
PerfError::BadCount.
- run's FILEs, --sample and --metric still combine (each opens another
drawing, the last is current): neither photocraft#7071 nor RFC-0012 requires
otherwise.
Behaviour changes (old -> new):
- --window with a bad value (wrong count, not a number, NaN/inf,
reversed corners, beyond 1e12): exit 1 `error: --window ...` ->
exit 2 `error: invalid value 'V' for '--window <x0,y0,x1,y1>':
<reason>`. The reasons no longer repeat the flag or the value.
- --view with a bad value: exit 1 `error: --view needs `extents` or
`current`` -> exit 2 `error: invalid value 'V' for '--view
<extents|current>'` plus clap's possible-values line.
- --window with --view: exit 1 `error: use only one of --window and
--view` -> exit 2 `error: the argument '--window <x0,y0,x1,y1>'
cannot be used with '--view <extents|current>'`.
- run --window/--view without --export: exit 1 `error: --window/--view
need an image output ...` -> exit 2 `error: the following required
arguments were not provided: --export <OUT.png>`.
- A framing flag with a non-image output: exit 1 `error:
--window/--view only apply to image output (png, svg, pdf), not
`OUT`` -> exit 2 `error: --window only applies to image output (png,
svg, pdf), not `OUT`` (or --view: the message names the flag given).
- sample with an unknown name: exit 1 `error: unknown sample `X`
(bracket, floorplan)` -> exit 2 `error: invalid value 'X' for
'<bracket|floorplan>'` plus the possible values. sample's help lists
the possible values.
- --cmd with JSON that doesn't parse: exit 1 `error: --cmd ID:
<serde error>`, after the earlier steps ran -> exit 2 `error: invalid
value 'V' for '--cmd <id {json}>': <serde error>`, before anything
runs.
- --cmd with an empty id (`--cmd=` or `--cmd ' {}'`): exit 1 `error:
unknown command `` ` -> exit 2 `... expected a command id, then
optionally its JSON parameters`.
- An empty path argument (info "", sample bracket "", perf "", ...):
exit 1 from the engine or io -> exit 2 `error: a value is required
for '<FILE>' but none was supplied` (clap's PathBuf parser).
- A path that isn't valid Unicode: exit 2 `error: invalid UTF-8 was
detected ...` -> exit 1 `error: PATH: the file name is not valid
Unicode` (text values that aren't Unicode stay exit 2). A non-Unicode
--save or --export is refused before any drawing opens.
- perf's help gives the count range.
Tests: usage.rs rows above moved to exit 2 with clap's messages; new
rows for --view with a non-image output, run's framing with a dxf
--export, an empty --cmd id, bad --cmd JSON after a good step, a
`{last}` with no earlier handle, --window beyond 1e12, case-sensitive
sample names and empty paths. The non-Unicode test covers both a path
(exit 1) and text (exit 2). Unit tests: the --window parser tests moved
to args.rs; new ones for --cmd values and perf targets; framing_options
checks the clap error kinds.
* refactor(cadcraft): move launch-argument parsing into launch_args
Moves the hand-written parser (the argument loop, control_port_from, control_flag and their tests) from main.rs into launch_args.rs, which returns LaunchArgs. No behaviour change.
* refactor(cadcraft): parse launch flags with clap (RFC-0012)
Replaces the hand-written loop in launch_args.rs with clap derive types, as photocraft's launch_args.rs does. --help is generated from the doc comments and lists the other CADCRAFT_* variables.
Behaviour changes (old -> new):
- An unknown flag (--sampel) was opened as a file; it is now a usage error on stderr, exit 2, before the window opens. A file starting with "-" goes after "--".
- A repeated --control or --sample was accepted (last wins); it is now exit 2.
- A bad port (--control abc, 70000, -1) was logged and the control channel left off; it is now exit 2. The same for CADCRAFT_CONTROL_PORT, and the error names the variable when the value came from it.
- A bare --control (no value) kept CADCRAFT_CONTROL_PORT's port with a warning; it is now exit 2 ("a value is required"). A following flag is never taken as the value.
- An empty or blank CADCRAFT_CONTROL_PORT was logged as a bad port; it is now unset.
- --control=7979 is accepted (the equals form was opened as a file before).
- --version / -V and --help stop parsing at once and exit 0; version text is unchanged ("cadcraft <version> (<sha>)").
- -psn_* (Finder process serial number) is dropped instead of opened as a file.
- A file name that is not valid Unicode used to panic in std::env::args(); it is now read from args_os and reported with a log warning, not opened, because CadApp::open_path takes text.
Copied from photocraft's crates/automation/src/args.rs: blank_env_is_unset and name_env_vars unchanged (name_env_vars gets a local use for ContextKind/ContextValue); control_port and NotAPort unchanged. allow_negative_numbers is set on --control as in photocraft, so -1 is a bad value rather than a missing one.
* feat(cli): shell completions and man pages
Adds examples/man-and-completions.rs, which writes cadcraft-cli's bash, zsh, fish, elvish and
PowerShell completions (clap_complete) and man pages (clap_mangen: cadcraft-cli.1 and one per
subcommand) into a directory. clap_complete and clap_mangen are dev-dependencies, so the binary
is unchanged.
packaging/linux/package.sh builds the example in its own cargo run, runs it (through $EMULATOR
for cross builds; warns and leaves the files out without one) and installs the man pages and the
bash, zsh and fish completions into the staged tree. nfpm.yaml already ships the whole
usr/share tree, so it needs no change.
CADCraft has no FreeBSD packaging, so there is no FreeBSD script to update. macOS and Windows
packaging are untouched.
tests/man_and_completions.rs checks the generated file names.
* ci(cli): check the command-line code with ast-grep (RFC-0012)
Adds ast-grep rules from RFC-0012, run by craft-common-actions'
reusable ast-grep workflow (Linux, no Rust build, path-filtered):
- clap-error-message: a string literal, format!, .to_string() or
SCREAMING_CASE const passed to Command::error / Error::raw
- clap-error-message-variable: the same message built into a variable
first, in the same function
- string-error: Result<_, String>, Err(format!(..)), Err(".."),
Err(x.to_string())
- args-os: std::env::args(), which panics on non-Unicode arguments
Scan paths: apps/cadcraft-cli/src, apps/cadcraft/src/launch_args.rs,
apps/cadcraft/src/main.rs. Rule tests run first in CI.
Source: photocraft#9750 at d16686cd. Only the scan paths and the
workflow path filters differ from it.
Fixes: none needed. The rule tests pass (4 passed) and the scan finds
nothing in the scanned paths.
* docs(cli): cadcraft-cli page, following RFC-0012
docs/cli.md: --help is the reference; exit codes, streams, usage
errors, values starting with -, paths, completions and man pages; the
environment variables (none for cadcraft-cli, CADCRAFT_CONTROL_PORT for
the desktop app's --control); and the rules not followed yet, with the
reason. The README links it.
* feat(cli): refuse an output that replaces an input
RFC-0012 rule 1.6: nothing destructive by default.
Behaviour change: `convert a.dxf a.dxf`, `run a.dxf … --save a.dxf` and
`run a.dxf … --export a.dxf` used to overwrite the input. They are now a
usage error (exit 2, `error: …` on stderr, nothing opened or written)
unless `--in-place` is given. "Same file" is file identity (same-file
crate), so `dir/./a.dxf` and a symlink to the input count. An output
that does not exist, or a failed identity check, is not refused; the
open or write reports the real error. Replacing an existing file that
is not an input is still allowed.
Scope: `--save` and `--export` only. A save that a --cmd or script runs
(for example `saveas`) is the engine's and is not checked.
Every write the CLI makes (convert OUT, --save, --export, sample OUT) resolves
an existing output first, so writing through a symlink updates the file it
points to and the link stays a link; the atomic rename used to replace the
link with a regular file, leaving the target (with --in-place, the input)
unchanged.
* feat(cli): --compact for JSON output
RFC-0012 rule 1.3: info and commands pretty-print their JSON by
default; --compact prints it on one line. run prints one JSON line per
--cmd result (JSON lines, one result per step), as its help and the
README document, so it takes no --compact. mcp's stdout is the MCP
protocol and is unchanged.
Behaviour change: info and commands accept --compact (it was an
unknown flag, exit 2). Their default output is unchanged.
docs/cli.md says which subcommand prints which form, and lists perf's
text table (no --json) and saves a --cmd or script runs (not checked
by --in-place) under "Not followed yet".
* fix(cadcraft): one Switch parser for boolean environment switches
CADCRAFT_VSYNC, CADCRAFT_SYSTEM_CURSOR, CADCRAFT_WAYLAND and
CADCRAFT_NO_NATIVE_MENU each had their own idea of "on". They now share
cadcraft_ui_egui::switch::Switch: 1/on/true/yes is On, 0/off/false/no is
Off (case- and space-insensitive), unset or blank is Default, and any
other value is Default and logged with the variable name. The ENVIRONMENT
help text says the same for all four.
Behaviour changes (old -> new):
- CADCRAFT_WAYLAND=0 counted as on (any value did); now only On keeps
native Wayland.
- CADCRAFT_NO_NATIVE_MENU=0 counted as on (any value did); now only On
keeps the menus inside the window.
- CADCRAFT_SYSTEM_CURSOR treated every value except ""/0/false/off as on;
now only the On spellings do, and an unknown value is logged.
- CADCRAFT_VSYNC is unchanged except that an unknown value is logged.
* fix(cli): keep paths as paths until a file is opened
A path is now text only where text is needed.
- cadcraft: FileNames.unreadable is Vec<PathBuf>, logged with {:?}
(escaped bytes) instead of a lossy rendering.
- cadcraft-cli: unicode() is called only inside open(), the one place
that sends a path to the engine as JSON. convert, sample and run
--save/--export pass the output as &Path. write_atomic, export,
export_framed and OutputError::Write take or hold a Path/PathBuf;
errors use .display(), and the `wrote ...` line uses .display().
- Dropped the dead find_subcommand lookup in launch_args (LaunchArgs has
no subcommands).
- docs/cli.md: non-Unicode names are refused only where a drawing is
opened.
Behaviour change: an output name that is not valid Unicode used to be
refused (exit 1); it is now written under that exact name. Opening such
a drawing is still refused.
Lossy strings that remain (all feed APIs that take text and only look at
the extension, never at the path the bytes are written to):
- cadcraft_io::write / write_framed (name picks the format) in sample.rs
and output.rs::export_framed;
- cadcraft_io::is_image in convert.rs, run.rs and args.rs (framing flag
check);
- cadcraft_engine::cmd::file::drops_unknown in export_framed.
These go away when cadcraft_io and the engine take impl AsRef<Path>
(the A1 follow-up). A non-Unicode extension is not a known format either
way, so it is rejected as an unsupported type, as before.
* refactor(cadcraft): read the environment once into Env
The desktop app reads its CADCRAFT_* variables once at startup into
apps/cadcraft/src/env.rs `Env` and passes the values on; no library crate
reads a CADCRAFT_* variable at run time any more.
- One `VARS` table (name, help line) feeds both the reader and the
Environment section of `cadcraft --help`. A test checks that every
variable the reader asks for is in the table, that every table entry
sets a field, and that the help lists every entry.
- vsync goes to `gpu::surface_config`, the system cursor to
`CadApp::set_system_cursor_default` (Options reset and Reset Palettes go
back to it), FONTALT/FONTFALLBACK to the `cadcraft_fonts::ttf` setters
(re-exported as `cadcraft_engine::fonts`), the settings directory to the
new `cadcraft_engine::settings_dir::set`, and to `Workspace::load`.
- The three copies of the settings-directory rule (main.rs, workspace.rs,
the engine's plotter folder) are one: `settings_dir::platform`.
- `Switch::from_env` is gone; `Switch::parse` stays.
- The child-process tests for CADCRAFT_CONTROL_PORT are replaced by tests
that inject the variable lookup (`blank_env_is_unset`) or point
`--control`'s fallback at PATH.
cadcraft-cli: plotter configurations matter to its output (`run --cmd plot`
or a script's PLOT with a user device, and the same through `mcp`), and the
font variables change how convert/run/sample draw text. So, following
RFC-0012 rule 1.7, the variables become fallbacks of flags declared with
`env =`: --config-dir (CADCRAFT_CONFIG_DIR), --fontalt (CADCRAFT_FONTALT)
and --fontfallback (CADCRAFT_FONTFALLBACK) on convert, run, mcp and sample.
Behaviour changes:
- CADCRAFT_CONFIG_DIR set but empty counts as unset everywhere: the
workspace file and the plotter folder use the platform folder (was:
workspace persistence and the plotter folder off). Logs and autosave
already treated it so.
- The workspace file and the plotter folder ignore a relative
XDG_CONFIG_HOME, as logs and autosave did (was: used it).
- A blank CADCRAFT_LOCALE means the system's languages (was: [""]).
- cadcraft-cli: the three variables apply only to convert, run, mcp and
sample, as flag fallbacks (was: read by the engine and fonts in every
subcommand, perf included). A font variable that isn't valid Unicode is
a usage error naming the flag (was: ignored).
* refactor(io): one Format enum for file extensions
`cadcraft_doc::Format` (re-exported as `cadcraft_io::Format`) is the one
place that maps a file name's extension to a format: Dxf, Dwg, Dwt, Svg,
Svgz, Png, Pdf. `from_path` is ASCII case-insensitive; no extension (or a
trailing dot) is Dxf; an unknown extension is None. `READ` and `WRITE`
list the formats `read` and `write` accept. It lives in cadcraft-doc
because the engine depends on cadcraft-io only for tests.
Each place used to match on its own lower-cased extension string and now
matches on Format, with the same results:
- io::read: svg/svgz -> SVG reader, dxf/none -> DXF reader, other ->
try DXF, else Unsupported(ext).
- io::write_with: dxf/none -> DXF, dwg -> DWG bridge, other with binary
-> error, rest -> write_framed.
- io::write_framed: dwt -> DWG; dxf/none/dwg -> write_with; svg, png,
pdf -> image writers; other -> Unsupported(ext).
- io::is_image: svg, png, pdf (not svgz, which is read only).
- engine file.rs is_dxf, drops_unknown (dwg, dwt), is_drawing_file
(dxf, dwg, dwt, none).
Behaviour change (help text only): the CLI help lists the formats from
Format::READ / Format::WRITE instead of hand-written lists. `info` and
`convert IN` now name svg and svgz as readable, and `convert`, `sample`,
`run --save` and `run --export` name dwt (and `sample` pdf) as writable.
A test checks each file argument's help names every format of its list.
* refactor: one version string for the app and the CLI
cadcraft_engine::build_version() builds "<version> (<commit>)" once; the
desktop app's --version, its start-up log line and cadcraft-cli --version
all use it. No change in output.
* refactor(cli): share the environment helpers with the CLI
Move blank_env_is_unset and name_env_vars from the desktop app into
cadcraft_mcp::args and apply them in the CLI parser.
Behaviour changes (old -> new):
- Empty or blank CADCRAFT_FONTALT / CADCRAFT_FONTFALLBACK: reached clap as
Some("") -> counts as unset.
- A bad value from an environment variable: the error named the flag ->
names the variable.
- CADCRAFT_CONFIG_DIR is unchanged: empty still means no settings folder.
- Desktop app: unchanged; it uses the shared helpers.
* refactor: pass paths, not text, through io, engine and open_path
cadcraft_io::{read, write, write_with, write_framed, is_image}, the engine's
drops_unknown/is_drawing_file/read_text_file and CadApp::open_path take
paths (impl AsRef<Path> / &Path). The desktop launch arguments and the CLI
no longer convert paths to text to call them.
Behaviour changes (old -> new):
- A dropped file whose name is not valid Unicode opened with a "can't
read" error naming a mangled path; it now opens natively. (Its path is
not remembered for QSAVE, which then asks where to save.)
- A launch argument that is not valid Unicode was logged and skipped; it
now opens like any other.
- A .dwt export builds the .dwg name as a path, not formatted text.
- On the web, a non-Unicode path passed to open_path reports "the path
is not valid Unicode" instead of a lossy name.
- Opening errors print path.display().
FileNames and LaunchArgs::file_names are removed; the launch tests assert
the parsed PathBufs. New io test: non-Unicode names pick the format by
extension.
* docs(cli): CADCRAFT_CONFIG_DIR is the one flag fallback where empty isn't unset
* fix(engine): refuse a drawing path that isn't valid Unicode
read_file opened such a path with no saved path, so QSAVE could not save back to it.
It now returns an open error naming the file before reading it. The ui-egui opener
already reports read_file errors like any other failed open.
* fix(cli): report a failed write of help or version
A write error on help or version output (other than a closed pipe) now exits 1 and
tries to say so on stderr; it was ignored and exited with the clap code. A closed pipe
keeps the clap exit code.
* fix(cli): --connect needs HOST:PORT
--connect example.com was accepted and failed later. It is now a usage error (exit 2)
unless the value is a non-empty host (or a bracketed IPv6 address) and a u16 port.
The host is not resolved.
* docs(cli): run prints no line for a command with no result
* refactor(cli): explicit imports and smaller functions for the stricter lints
Lints: clippy::wildcard_imports, too_many_arguments, cognitive_complexity (30).
Replaced the non-test `use super::*;` in args, commands, convert, info,
output, perf and run with explicit imports; lib.rs keeps only the imports
its non-test code uses, and its test module imports the rest itself. The
`super::*` in the test modules stays.
A clippy run with all three lints and threshold 30 reports nothing in
apps/cadcraft-cli or in code this branch added, so no function needed
splitting.
|
||
|
|
2721aa8982 |
Enforce Rust coding standards via Clippy (#2239)
* chore(clippy): enforce workspace Rust quality gates * refactor(doc): use explicit entity imports * refactor(constraints): split residual evaluation * refactor(fonts): split mtext layout * refactor(render): use explicit entity imports * fix(fonts): retain height for empty paragraphs * fix(doc): repair dimension and dynamic block links * refactor(render): split entity drawing helpers * docs: document workspace lint inheritance * refactor(render): isolate dimension geometry * refactor(engine): use explicit imports * refactor(engine): split complex edit paths into helpers * refactor(io): split DXF read and write helpers * refactor(ui): split canvas interaction and drawing * refactor(ui): split command and drawing helpers * test(i18n): split locale preference checks * fix(ui): use current egui scope id API * fix(dim): preserve text offset and ellipse grip behavior |
||
|
|
850dd94f3c |
Stroke runs of hairline polylines as one path in the rasteriser
PNG export (and everything else drawn by raster::render) stroked every polyline primitive with its own tiny-skia stroke_path call: a new path and a newly built paint pipeline per primitive. Hatch patterns, linetype dashes and text strokes produce long runs of short polylines in one colour, so that per-call setup dominated the render. Consecutive hairline polylines (zero width, or at most one pixel when anti-aliased; the default for PNG export) with the same colour, alpha and width are now collected into one path and stroked once. tiny-skia draws hairlines segment by segment straight onto the pixmap with the same per-contour round caps, so the pixels and their blending order are unchanged. Thicker strokes (filled outlines), fills, points, infinite lines and polylines with non-finite or far-out screen coordinates break the run and are drawn exactly as before. Adds crates/io/examples/export_bench.rs, which exports examples/ apartment.dxf repeated on a grid (10x10: 5,800 entities) and reports median/min wall time per format. PNG export, 10x10 grid, 11 interleaved runs (Ryzen, 16 threads, Linux): before: median 1790.7 ms, min 1703.3 ms after: median 1037.6 ms, min 926.0 ms (-42.1 %) A/A noise on the same setup: 1.1 %. Output PNGs are byte-identical (bench at 10x10 and 20x20, CLI export of apartment.dxf and a 23,200- entity drawing). New tests compare render() against stroking each primitive on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8b8e921f6a |
Merge upstream main into fix/dxf-codepage-text
main split dxf_write.rs into dxf_write/ (
|
||
|
|
970e6bb9d4 | refactor(io): move dxf_read.rs items to dxf_read/ | ||
|
|
736a83464a | refactor(io): move dxf_write.rs items to dxf_write/ | ||
|
|
069d276fe5 |
Merge upstream main into fix/dxf-codepage-text
crates/dxf/src/lib.rs: #2050's rule (a backslash that would start \U+ or \M+ is written as \U+005C) goes into push_string, so it holds for UTF-8, code page and pure ASCII output, the UTF-8 fallback included. A test checks literal escapes next to code page text in ASCII and binary. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
53080b1748 |
refactor: split complex matchers, scanners and solver setup into helpers (#2186)
Pure extraction, no behaviour change: same order of side effects, same budget charges, same early returns and error values. Clears cognitive-complexity findings on glob_inner, the PDF test ops scanner, snap_ends, the loops inquiry run and build_budgeted (S3776). |
||
|
|
21c48cc05b |
refactor(io): split complex PDF marks and DXF readers into helpers (#2185)
Pure extraction, no behaviour change: same order of side effects, same early returns and error values. Clears cognitive-complexity findings on pdf::marks, dxf_read::read_budgeted, parse_entities, entity_with_table_budget and Objects::apply (S3776). |
||
|
|
1b6861698c | refactor: cut test helper and two DXF writer closures to 7 parameters (S107) (#2048) | ||
|
|
2528671106 | Cap HATCH spline edge degree at 10 like the SPLINE reader (#923) (#978) | ||
|
|
cddf09beb2 |
DXF/DWG: read the drawing's WIPEOUTFRAME from its WIPEOUTVARIABLES object (#908)
AutoCAD stores the wipeout frame setting in the drawing's WIPEOUTVARIABLES object (group 70: 0 = frames hidden). CADCraft ignored it and always showed the frames (the default of 1), so masks such as the diamond inside a numbered circle were outlined. The flag is now read into the WIPEOUTFRAME setting. Co-authored-by: simanov <asimfali@mail.ru> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
8171c9be17 | DIMTFILL and DIMTFILLCLR are written in DIMSTYLE only when set; COMPAREEXPORT redraws dimensions instead of copying their blocks, and gaps.md notes its groups | ||
|
|
8a64e42100 |
DIMTFILL: dimension text gets a background in the drawing's background color or in DIMTFILLCLR
DIMTFILL and DIMTFILLCLR were not modeled, so a dimension's text never had a background and lines under it stayed visible. Dimension styles now carry both variables. DIMTFILL 1 hides what is drawn under the text in the drawing's background color, and DIMTFILL 2 fills the box in DIMTFILLCLR. The box is the text box widened by DIMGAP on every side. The arc length symbol over the text and the DIMINSPECT frame are drawn over the background. The variables work with SETVAR, DIMOVERRIDE and the style fields. DXF stores them as DIMSTYLE groups 69 and 70 from R2007 and in the style's CADCRAFT xdata in older files; the reader skips the record's flags, which also use 70. For DIMTFILL 2, the dimension's *D block and EXPLODE add a SOLID in DIMTFILLCLR under the text. A dimension drawn from the *D block it was read with gets a background around each of the block's texts, before the block's first text or first segment of the text's marks, except for a text that a SOLID of the block already covers. The background stays after the drawing is saved and reopened. |
||
|
|
ea02e45099 |
Merge upstream main into fix/dxf-codepage-text
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
41d9b5e957 |
PDF: plot with craft-pdf's krilla writer (#2029)
* Depend on craft-pdf (krilla writer, reader for tests) at craft-libs 9f75d3dc The root patches pin the patched krilla and hayro-syntax/hayro-jbig2 to the same revision, as craft-pdf requires. * Plot PDFs with craft-pdf's krilla writer The hand-written object, xref, stream and font writer goes. Each sheet's display list is built, written as its page and dropped before the next. Strokes with the same colour, width and transparency stay one path, and each filled primitive is one path of its triangles. Text in embeddable TrueType fonts is drawn as glyphs; krilla subsets the fonts and writes their ToUnicode maps, so the hand-written subsetter goes too and cadcraft-fonts keeps only the fsType embedding check. Primitives with a point that is not finite or beyond 1e7 pt are left out. A font krilla cannot embed after all makes the export retry with text as outlines. Optional content (PDF layers) is not written until craft-libs' writer supports it: the layer transitions go through one empty function, layers that are off are not plotted, and the layer tests are ignored. The tests read the PDF back with craft-pdf's reader. * Pin craft-pdf and its krilla and hayro patches to craft-libs cd160e73 cd160e73 adds optional content groups to the patched krilla. * Write drawing layers as PDF optional content groups Each drawing layer a page draws on gets one group, named after the layer and shared by all pages, created before the first page that uses it. A group starts hidden when its layer is off in the drawing, so `offLayers` again plots layers that are off on hidden PDF layers. At most 4096 groups per file; objects on further layers print unmarked. A single sheet with groups opens with the viewer's layer panel (/PageMode /UseOC). Layer changes end and start the marked content, and the last mark ends before the page finishes. The layer and text tests that check the groups run again, and a test covers the group cap. * Plot a zero-length line as a round dot in PDFs krilla leaves out a path without extent, so a lone zero-length line drew nothing. It is filled as the dot its round-capped stroke would make, as wide as the stroke, with 0.25 pt for a hairline. * PDF: retry as outlines when the writer fails inside a font; cap layer names; restore two test checks * Tests: read plotted PDFs back through the shared reader in plot_layout_scale and plot_styles * Pin craft-pdf, krilla, hayro-syntax and hayro-jbig2 to craft-libs main (7895f5e) * PDF tests: read path coordinates in page space; cover the font retry and out-of-range points - pdf_read maps path operands through the CTM (`page_ops`, used by `drawn` and `clip_rect`) and checks that the plot area is drawn in page space. - The 1:1 layout test finds the viewport corner at (72, 72) in page space, so a mirrored page fails it. - A font with a short hmtx passes the writer's font checks but fails subsetting; the plot retries and draws its text as outlines. - A primitive with a point past 1e7 pt is left out, and the rest still plots. * PDF: clip a primitive with a far vertex to the plot area instead of leaving it out A polyline or fill with a point past the writer's f32 range now keeps the parts inside the plot area (polylines with the area widened by the stroke width), each piece its own subpath. Primitives in range are written as before. The test reader requires a decodable content stream. |
||
|
|
63394e872d |
chore: resolve SonarCloud maintainability issues (#2025)
* chore: resolve SonarCloud maintainability issues * style: format with rustfmt * fix(engine): reference DocState instead of DrawingState * fix: restore cmd wildcard imports and remove unused Arc import * Unit tests for the extracted mleader alignment steps and spacemouse filter * test: fix assertions flagged in review and apply rustfmt Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * test: initialise drift filter in struct literal for clippy Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Dylan Taylor <dylan@craftmaker.dev> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
7aa952b8da |
DWG: write AutoCAD's drawing variable dictionary (AC1018 output) (#1872)
* DWG: write AutoCAD's drawing variable dictionary (fixes #1813) A 2004 (AC1018) DWG of a drawing without an AcDbVariableDictionary is read as empty by Vectric Aspire 10.5, though the same drawing as DXF imports. AutoCAD always writes the dictionary; CADCraft's and ezdxf's DXF writers don't. The DWG bridge now adds it, with AutoCAD's usual variables, when the drawing has none, for DWG versions before 2018 (AC1032 output reads fine without it). A dictionary the drawing already has keeps its entries and values. * docs: document the functions touched by #1813 * DWG: keep the drawing's DIMASSOC and HIDETEXT in the variable dictionary --------- Co-authored-by: Brandon Thomas <echelon@gmail.com> |