DWG writer: text styles get the text-style table as their xref block handle

Open Beginner friendly
#1,401 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@menes97 is already working on this.

Since Nov 18, 2026.

  • #1412 by @menes97 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
81/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend

Research direction

Start by reading DwgObjectWriter.writeTextStyle and compare its final handle reference with the corresponding writes for other table entries. The report gives a minimal reproduction using an empty CadDocument and says BricsCAD V22 AUDIT flags the text-style xref block handle; confirm the output handle is null for a style without an xref. Done when that audit finding is gone for the reproduced file.

Written by the indexing model from the issue text.

Description

Version: 3.8.30. The same line is on master today.

What happens: DwgObjectWriter.writeTextStyle writes the text-style table handle in the slot where the DWG format has the entry's xref block handle. That handle should be null for a style that does not come from an xref. The method ends with:

this._writer.HandleReference(DwgReferenceType.HardPointer, this._document.TextStyles);

The other table entries write a null handle there. Layers, line types and the others use HandleReference(DwgReferenceType.HardPointer, 0) or null.

BricsCAD V22's AUDIT reports it for every text style, including the Standard style of an empty new CadDocument(ACadVersion.AC1024):

Name: AcDbTextStyleTableRecord(2D)
Value: Is not externally dependent on an Xref, but XRefBlockId ((4)) is not Null
Validation: Invalid
Default value: Set to Null

Here (4) is the handle of the text-style table in that file.

Suggested fix:

this._writer.HandleReference(DwgReferenceType.HardPointer, 0);

To reproduce:

var doc = new CadDocument(ACadVersion.AC1024);
using (var w = new DwgWriter("empty.dwg", doc)) w.Write();

Open empty.dwg in BricsCAD, then run AUDIT and answer N.

For context: BricsCAD's AUDIT of that empty document reports 16 findings in all. Besides this one and TILEMODELIGHTSYNCH, the others are default values:

  • TEXTSIZE, PSOLWIDTH, LENSLENGTH and 3DDWFPREC are 0;
  • the Standard style's last height is 0;
  • the active viewport's snap spacing is 0;
  • the model layout lacks the ModelType plot flag;
  • the TABLESTYLE has a null text style;
  • there are two invalid named-object dictionary entries, one of them ACAD_FIELDLIST.

These may be related to #834 and #1327. Every file opens and displays correctly; BricsCAD repairs all of them when it opens the file.

Dominant language
C#
Stars
873
Forks
223
Avg merge
1d 15h
Merged PRs (30d)
28

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DomCR/ACadSharp

All issues in DomCR/ACadSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.