fix(arch, table): what the 1.6.0 README renders showed

- The exterior dimension chains follow the plot scale. DIMSCALE is the
  plan's scale while they are drawn and is put back afterwards; a 1:50
  chain's 2.5 text had been 2.5 drawing units, 0.05 mm on the sheet.
- A headless TABLE merges its title row, as AutoCAD's TABLE does; a long
  title no longer wraps inside the first column over the header row.
- A headless TABLE's cell margin scales with the lettering. A flat 1.0 was
  0.02 mm on a 1:50 schedule; tables at the default 2.5 text are unchanged.
- drawing_new writes the Standard text style in arial.ttf, as AutoCAD
  2026's acadiso.dwt ships it: txt has no superscript two, so 'm²' read
  'm?' live and rendered as a box headlessly. The five bundled templates
  are rebuilt and build_templates --check reproduces them.

Each fix has a test that fails on the old code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-25 00:17:10 +03:00
co-authored by Claude Opus 5.5
parent 554daff8d0
commit 7e7fe11a71
13 changed files with 182 additions and 370 deletions
+21
View File
@@ -197,6 +197,27 @@ async def test_draw_chains_puts_real_dimensions_on_the_dimension_layer(backend):
}
async def test_draw_chains_text_follows_the_plot_scale_and_dimscale_is_put_back(backend):
# At the style's DIMSCALE 1 a 1:50 chain's 2.5 text was 2.5 drawing units -
# 0.05 mm on the sheet - and the README plan render showed empty boxes where
# the numbers belong. The chain carries the scale; the drawing keeps its own.
shell = Wall(
id="shell",
axis=((0.0, 0.0), (8200.0, 0.0), (8200.0, 6200.0), (0.0, 6200.0)),
thickness=200.0,
closed=True,
)
before = await backend.system_get_variable("DIMSCALE")
result = await draw_chains(backend, [shell], [], sides=("bottom",), scale=50)
assert result["dimscale"] == 50.0
heights = set()
for handle in result["handles"]:
block = backend._doc.entitydb[handle].get_geometry_block()
heights |= {round(e.dxf.char_height, 6) for e in block if e.dxftype() == "MTEXT"}
assert heights == {125.0} # 2.5 mm on paper x 50
assert await backend.system_get_variable("DIMSCALE") == before
async def test_assign_tags_numbers_each_kind_in_the_chosen_language():
ops = [
Opening(id="1", wall="a", kind="door", offset=0.0, width=900.0),
+8
View File
@@ -46,6 +46,14 @@ def _rendered(backend, handle):
# ── headless engine ─────────────────────────────────────────────────────────
async def test_a_new_drawing_writes_standard_in_arial_like_acadiso(backend):
# AutoCAD 2026's acadiso.dwt ships Standard as Arial. ezdxf's own default is
# txt.shx, which has no superscript two: an architectural area label 'm²'
# read 'm?' in AutoCAD and rendered as a box headlessly.
rows = {row["name"]: row["font"] for row in await backend.textstyle_list()}
assert rows["Standard"] == "arial.ttf"
async def test_dimstyle_list_reports_standard_current_with_the_seventeen_values(backend):
rows = await backend.dimstyle_list()
assert [r["name"] for r in rows] == ["Standard"]
+43
View File
@@ -28,6 +28,49 @@ async def test_ezdxf_table_returns_composite_contract(backend):
assert result.properties["bounds"] == {"min": [10.0, 72.0], "max": [30.0, 100.0]}
async def test_ezdxf_table_title_row_is_merged_across_the_table(backend):
# AutoCAD's TABLE merges its title row. Drawn as one column's cell, a title
# such as 'DOOR SCHEDULE' wrapped inside the first column and ran over the
# header row below it. The title spans the table, and only the table's outer
# edges cross its row.
result = await backend.entity_create_table(
0,
100,
rows=[["D1", "900"]],
headers=["TAG", "WIDTH"],
column_widths=[20, 30],
row_height=10,
text_height=2.5,
title="DOOR SCHEDULE",
)
children = [backend._doc.entitydb[h] for h in result.properties["child_handles"]]
(title,) = [e for e in children if e.dxftype() == "MTEXT" and e.text == "DOOR SCHEDULE"]
assert title.dxf.width == pytest.approx(50.0 - 2 * 1.0) # padding min(1.0, 10 x 0.15)
verticals = [e for e in children if e.dxftype() == "LINE" and e.dxf.start.x == e.dxf.end.x]
inner = [v for v in verticals if 0.0 < v.dxf.start.x < 50.0]
assert inner and all(max(v.dxf.start.y, v.dxf.end.y) == pytest.approx(90.0) for v in inner)
outer = [v for v in verticals if v.dxf.start.x in (0.0, 50.0)]
assert len(outer) == 2 and all(max(v.dxf.start.y, v.dxf.end.y) == 100.0 for v in outer)
async def test_ezdxf_table_cell_margin_scales_with_the_lettering(backend):
# A 1:50 schedule letters at 125 in rows of 350. A flat 1.0 margin is 0.02 mm
# on that sheet: the text sat on the cell line, and 'LEFT' read as 'FT'.
result = await backend.entity_create_table(
0,
0,
rows=[["D1", "LEFT"]],
column_widths=[750, 1000],
row_height=350,
text_height=125,
)
children = [backend._doc.entitydb[h] for h in result.properties["child_handles"]]
(left,) = [e for e in children if e.dxftype() == "MTEXT" and e.text == "LEFT"]
assert left.dxf.insert.x == pytest.approx(750 + 50.0) # 0.4 x 125
assert left.dxf.insert.y == pytest.approx(-50.0)
assert left.dxf.width == pytest.approx(1000 - 2 * 50.0)
async def test_ezdxf_table_survives_save_and_reopen(backend, tmp_path):
result = await backend.entity_create_table(0, 30, rows=[["A", "1"]], headers=["Name", "Qty"])
path = tmp_path / "table.dxf"