Skip to content

fix(entities): read TEXT, ATTRIB and ATTDEF as §20.4.3-§20.4.5 print them on every release (#226, #62) - #258

Merged
DrunkOnJava merged 4 commits into
mainfrom
fix/226-text-family
Oct 26, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
fix/226-text-family

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Read TEXT, ATTRIB and ATTDEF as §20.4.3, §20.4.4 and §20.4.5 print them on every release. The R2000-R2004 reader had the data flags inverted. R13/R14 had no branch of their own. Oblique, rotation and width factor were BD on every release where the spec has RD (#62). The ATTDEF prompt was read before the tag. Fixing all four makes all 118 erroring text records close (114 R14-R2004 records, 4 R2018), and every value read agrees with the DXF twin.

Closes #62. Part of #226: MTEXT and TOLERANCE follow in their own PRs.

Spec reference

Defect Was Spec says
R2000+ data flags (§20.4.3) a field read when its bit is set "present if !(DataFlags & bit)"
R13-R14 (§20.4.3) the R2000+ reader its own branch: no flags, BD elevation and angles, 2RD points, 3BD extrusion
oblique, rotation, width factor (§20.4.3, #62) BD (R2000-R2004 also read the height as BD) RD
ATTDEF prompt (§20.4.5) before the tag after "Common ATTRIB Entity Data"

text::decode (R13-R2004, inline TV) and text::read_modern_fields (R2007+, TV from the string stream) now share one §20.4.3 reader. Only the TV source differs between them.

#62: the file that writes the three fields

export_sample.dwg (R2018, pinned by #225) has four TEXT records that write the optional fields, and their text states the values. The RD reading recovers those values exactly; a BD reading ends 62 bits short or 2 bits long, or hits the reserved 11 code:

Handle Flags Field RD value The record's text
0x44A 0xFB oblique 0.17453292519943295 (10°) "Text obliquing = 10"
0x44B 0xF7 rotation 0.5235987755982988 (30°) "Rotated text angle = 30"
0x454 0xEF width factor 2.0 "Text width = 2.0"
0x465 0xAD alignment, width factor, h-align "Justification fit"
C=~/Library/Caches/dwg-corpus/acadsharp
cargo run --release --example probe_entity_field_list -- $C/export_sample.dwg 0x44A RC,2RD,B,B,RD,RD   # → 0.17453292519943295, delta 0

Records it was measured on

examples/probe_text.rs (new) reports closure for every TEXT, ATTRIB and ATTDEF and compares each value with the DXF twin by handle. Groups the DXF omits are counted, not compared against defaults. Angles are compared in degrees modulo 360. The groups of a multi-line attribute's embedded MTEXT (after 101) are kept apart from the attribute's own.

Type Records (52-file corpus) Close Values compared with the twin (R2000-R2018) Differ
TEXT 224 224 870 0
ATTRIB 28 28 189 0
ATTDEF 35 35 276 0
cargo run --release --example probe_text -- $C/sample_AC1014.dwg      # R14: no twin, close only
for v in 1015 1018 1021 1024 1027 1032; do cargo run --release --example probe_text -- $C/sample_AC$v.dwg $C/sample_AC${v}_ascii.dxf; done
cargo run --release --example probe_text -- $C/export_sample.dwg      # no twin: 21 TEXT, 21 close

Not measured: every TEXT the twins cover leaves rotation, oblique and width factor at their defaults, so the RD reading rests on export_sample.dwg, which has no twin. The R14 save's 38 records close but have no twin.

Coverage, ../../samples

cargo run --release --example coverage_report -- ../../samples: unchanged, TOTAL 3911 / 525 / 9. Every text record of the 19-file corpus already closed on the R2007+ path, which elides the three RD fields, and the R14-R2004 files hold no text.

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

measure.py run then measure.py check (exit 0 after measure.py baseline):

-export_sample.dwg   acadsharp AC1032  453  11  14 ...
+export_sample.dwg   acadsharp AC1032  457  11  10 ...
-sample_AC1014.dwg   acadsharp AC1014  676 461 105 ...
+sample_AC1014.dwg   acadsharp AC1014  714 461  67 ...
-sample_AC1015.dwg   acadsharp AC1015  914  82  51 ...
+sample_AC1015.dwg   acadsharp AC1015  952  82  13 ...
-sample_AC1018.dwg   acadsharp AC1018  850  74  90 ...
+sample_AC1018.dwg   acadsharp AC1018  888  74  52 ...

52-file total: 13781 / 1985 / 308 → 13899 / 1985 / 190. No other column moves.

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, and the census/closure columns of the 52-row baseline are unchanged.

Docs

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
  • Adds no unit tests. Five existing tests built R2000 TEXT payloads in the old, inverted layout, and their payloads now follow §20.4.3. They write 0xFF for "no optional fields" instead of 0x00, and write the height and the three optional fields as RD. The full-fields test also writes its alignment point as 2DD, and the ATTDEF roundtrip writes the prompt after the flags. The five are text::tests::{roundtrip_minimal_text, roundtrip_full_text_fields}, attrib::tests::roundtrip_invisible_constant_attrib, attdef::tests::roundtrip_attdef_r2000 and integration_entity_regression::build_text_payload. Their assertions are unchanged.

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.3, §20.4.4 and §20.4.5 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1), on the corpus bytes, and on AutoCAD's DXF exports of the same drawings, read as data files (ACadSharp samples/ at c30a97ce, MIT, pinned by #225). The probe's group-to-field pairing uses the DXF codes §20.4.3 to §20.4.5 print, and group 74 for an attribute's vertical alignment; the twins corroborate it, since the decoded value equals group 74 wherever the DXF writes it. 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.

…them on every release (#226, #62)

The R2000-R2004 TEXT reader read a field when its data-flag bit was set,
where §20.4.3 says a set bit means the field is absent; R13/R14 had no
branch of their own; oblique, rotation and width factor were BD on
every release where the spec prints RD; and ATTDEF read its prompt
before the tag instead of after the ATTRIB fields. All 118 text
records that errored on the public corpus (114 on ACadSharp's R14 to
R2004 saves, 4 on export_sample.dwg) now close, and every value read
equals AutoCAD's DXF export of the same drawing on R2000 to R2018.

The four R2018 records state their own values in their text (obliquing
10, rotation 30, width 2.0), and the RD reading recovers them exactly.
That is the file #62 asked for.

examples/probe_text.rs reproduces it; ARCHITECTURE.md §7n records it;
tools/corpus/baseline.tsv records the four 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 ✅ Completed 2026-10-26T17:04:11.693453Z 784146e 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.

# Conflicts:
#	ARCHITECTURE.md
#	docs/data/spec-coverage.tsv
#	docs/spec-coverage.md
#	tools/corpus/baseline.tsv
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Merge-train note for da7baaf: main had changed these docs/data/spec-coverage.tsv notes since this PR's base, and this PR rewrote them too. The PR's free text was kept and main's was dropped. Tool-written sentences (DXF oracle, spec examples) were kept and regenerated. Check that nothing below still needs saying:

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 16:37

@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: da7baaf493

ℹ️ 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_text.rs Resolved
AC1021 and later DXF is UTF-8, as src/dxf_reader.rs reads it; taking each
byte as a character turned a non-ASCII value such as U+2205 into mojibake
before the comparison. Earlier releases stay byte per character.
@DrunkOnJava
DrunkOnJava merged commit 8c071e4 into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/226-text-family branch October 26, 2026 17:10
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
* fix(ci): land.sh hands a PR back when a review thread opens after auto-merge

The ruleset holds a PR with an unresolved thread, and land.sh's wait loop
only watched for merge, DIRTY, a moved main and failing checks, so a thread
the reviewer opened after auto-merge went on (#258, 2026-10-26) stalled the
train until the deadline. The loop now turns auto-merge off and exits 2 on a
positive unresolved count; a failed query counts as none.

* fix(ci): land.sh treats any positive thread count as open, not just 1-99

* fix(ci): land.sh turns auto-merge off on every failed exit after enabling it

A timeout or a failing check left auto-merge on, so the abandoned PR could
merge while the train refreshed the next one (#298 review). A branch that
strict up-to-date reports BEHIND now exits 8 for a real refresh instead of
waiting out the deadline.
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.

TEXT oblique_angle / rotation_angle / width_factor read as BD where §20.4.3 types them RD — latent divergence no sample exercises

1 participant