Skip to content

fix(entities): read MTEXT's §20.4.46 version branches on R13 to R2004 (#226) - #261

Merged
DrunkOnJava merged 6 commits into
mainfrom
fix/226-mtext
Oct 26, 2026
Merged

DrunkOnJava merged 6 commits into
mainfrom
fix/226-mtext

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Read MTEXT with §20.4.46's version branches on R13 to R2004. Line spacing is R2000+, and R2004+ adds the background flags and block. All 72 MTEXT records that errored on ACadSharp's R14 and R2004 saves now close. Every one of the 257 MTEXT records of the public corpus closes, and the values agree with the DXF twins, the R2004+ backgrounds included. Part of #226: TEXT/ATTRIB/ATTDEF is #258, and TOLERANCE follows.

Spec reference

§20.4.46 MTEXT (44): after the TV, R2000+ BS line spacing style, BD line spacing factor and an unknown B; R2004+ BL background flags, then, when bit 0x01 is set (or 0x10 on R2018), BD scale, CMC colour and BL transparency.

Release Before What the inline reader missed After
R14 36 errors (delta +21 / +69 / +77) read the R2000+ line spacing, which R14 does not write 36 close
R2000 36 close nothing; R2000 ends at the unknown bit 36 close
R2004 36 errors (delta −2 / −122) the BL background flags, and for two records the background block 36 close

One field reader now serves every release. The TV is inline before R2007 and from the string stream after. MText gains background_flags and background: Option<MTextBackground> (scale, CMC colour, transparency) so the block can be checked, not just skipped. A colour byte announcing a colour or book name is refused (Unsupported), since no corpus record has one. R13/R14 store no line spacing, so those two fields read 0 there rather than a default the record does not hold.

Records it was measured on

examples/probe_mtext.rs (new) reports closure and compares each MTEXT with the DXF twin by handle. It covers insertion point, extrusion, x-axis direction, reference width and height, text height, attachment, drawing direction, line spacing, the R2004+ background (90, 45, 421, 441) and the text. The R2007+ DXF is read as UTF-8, and its ^J caret escapes are undone.

Release Records Close Values compared Differ
R14 36 36 no twin
R2000 36 36 368 0
R2004 36 36 376 0
R2007 / R2010 / R2013 / R2018 36 each 36 each 411 each 0
export_sample.dwg (R2018) 5 5 no twin

The two backgrounds agree on R2004 and later: flags 1, scale 1.25, true colour 0x367542 (421 = 3568962), transparency 0. One MTEXT per save (0x1032) has no entity with its handle in the DXF; it is counted, not compared.

C=~/Library/Caches/dwg-corpus/acadsharp
cargo run --release --example probe_mtext -- $C/sample_AC1014.dwg      # R14: no twin, close only
for v in 1015 1018 1021 1024 1027 1032; do cargo run --release --example probe_mtext -- $C/sample_AC$v.dwg $C/sample_AC${v}_ascii.dxf; done

Coverage, ../../samples

cargo run --release --example coverage_report -- ../../samples: unchanged, TOTAL 3911 / 525 / 9. The 19-file corpus holds MTEXT only on R2018, which already closed.

Public corpus: tools/corpus/baseline.tsv (regenerated, committed)

-sample_AC1014.dwg   acadsharp AC1014  676 461 105 ...
+sample_AC1014.dwg   acadsharp AC1014  712 461  69 ...
-sample_AC1018.dwg   acadsharp AC1018  850  74  90 ...
+sample_AC1018.dwg   acadsharp AC1018  886  74  54 ...

52-file total: 13781 / 1985 / 308 → 13853 / 1985 / 236. measure.py check passes against the committed baseline.

Class census and reference closure

probe_class_census and probe_reference_closure on all 19 files of ../../samples give output identical to the run before the change. The census and closure columns of the 52-row baseline are unchanged.

Docs

  • docs/data/spec-coverage.tsv: the §20.4.46 note states the measurement (state closes). docs/spec-coverage.md is regenerated.
  • ARCHITECTURE.md: new §7o.
  • src/entities/mtext.rs: module doc cites §20.4.46 (was "§19.4.23") and records the measurement.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test --release --all-features (real-file tests ran against ../../samples)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • tools/corpus/measure.py check passes against the committed baseline
  • No unit tests added or changed.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

My contribution is based on §20.4.46 (field list, branches and DXF codes) and §20.4.75 (group 421 pairs with a CMC's BL RGB word) of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1). It also uses the corpus bytes and AutoCAD's DXF exports of the same drawings, read as data files (ACadSharp samples/ at c30a97ce, MIT, pinned by #225). The caret escape the probe undoes is the one the twins show: ^J where the record holds a line feed. No third-party code or comments were read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.

…#226)

The inline MTEXT reader read the R2000+ line spacing on every release
and stopped before the R2004+ background flags, so all 36 MTEXT records
of ACadSharp's R14 save and all 36 of its R2004 save errored. One field
reader now serves every release, with the line spacing R2000+ and the
background flags and block R2004+ as §20.4.46 prints them; all 257
MTEXT records of the public corpus close, and every value, the two
R2004+ backgrounds included, equals AutoCAD's DXF export of the same
drawing on R2000 to R2018.

MText keeps the background flags and block it used to skip.
examples/probe_mtext.rs reproduces it; ARCHITECTURE.md §7o records it;
tools/corpus/baseline.tsv records the two files' new counts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T15:24:20.242574Z 952e245 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1b47e2a08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/probe_mtext.rs Resolved
# Conflicts:
#	ARCHITECTURE.md
#	docs/data/spec-coverage.tsv
#	docs/spec-coverage.md
#	tools/corpus/baseline.tsv
Group 1 went through the numeric same(), so "001" matched "1" and an
identical "NaN" differed. Text is now compared exactly after the caret
escapes are undone; the numeric tolerance stays for numeric groups.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 15:28
@DrunkOnJava
DrunkOnJava merged commit 9de1f0f into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/226-mtext branch October 26, 2026 15:32
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…d say what measured them (#140, #147, #148, #133, #127) (#398)

Seven rows leave partial for closes because no record of any kind errors on the
52 drawings of run 40532346172 and the errors their notes still quote were
fixed: TEXT, ATTRIB, ATTDEF (#258), MTEXT (#261), VIEW (#263, #284), DIMSTYLE
(#293) and HATCH (#264, the R14 records routed). §22 AcDb:Template goes from
missing to partial: dxf_header reads $MEASUREMENT from it (#320). §9 stays
closes, now tracked by #127 (R13) and carrying the per-release evidence behind
closing #128, #129 and #130. The page's Last measured line and the paragraph
that said closes came from a local 19-file corpus are updated.
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…ain run (#195) (#401)

* docs(spec-coverage): move the rows the 2026-10-27 main run proves, and say what measured them (#140, #147, #148, #133, #127)

Seven rows leave partial for closes because no record of any kind errors on the
52 drawings of run 40532346172 and the errors their notes still quote were
fixed: TEXT, ATTRIB, ATTDEF (#258), MTEXT (#261), VIEW (#263, #284), DIMSTYLE
(#293) and HATCH (#264, the R14 records routed). §22 AcDb:Template goes from
missing to partial: dxf_header reads $MEASUREMENT from it (#320). §9 stays
closes, now tracked by #127 (R13) and carrying the per-release evidence behind
closing #128, #129 and #130. The page's Last measured line and the paragraph
that said closes came from a local 19-file corpus are updated.

* docs(criteria): re-measure the 1.0 requirements from the 2026-10-27 main run (#195)

Header, R2, R3, R4, R8, X1 and S3 now carry what run 40542129639 (main 61255e9)
and docs/data/spec-coverage.tsv say: 52 drawings with 0 errored records and 533
skipped, 53 sections scored by the DXF oracle with 22 values disagreeing, 90
closes, 13 partial, 6 decoder and 29 missing rows, a wasm32 compile of the
library in the Clippy job. X1 (DXF) moves from not measured to failed: the HEADER,
TABLES, ENTITIES and BLOCKS probes pair the written records with AutoCAD's export
and find 0 groups disagreeing, and 342 entity records of 18 kinds and the OBJECTS
section are not written. No other status changes.

* docs(criteria): R3 counts the rows #398 moves: 97 closes, 7 partial, 6 decoder, 28 missing (#195)

The counts are those of docs/data/spec-coverage.tsv with #398, whose moves run
40532346172 proves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant