Skip to content

Drawing text: the paper scene counts a font's records, measures a run, and its reply schema allows text - #12113

Closed
CamWight wants to merge 2 commits into
tangency-labs:drawingsfrom
CamWight:drawing-font-table-4890
Closed

CamWight wants to merge 2 commits into
tangency-labs:drawingsfrom
CamWight:drawing-font-table-4890

Conversation

@CamWight

@CamWight CamWight commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The next drawing pieces that put text on a sheet (a dimension's number first) need three small things from the paper scene:

  • a count of what a font would add to the scene's table;
  • how far a run of text reaches along its line;
  • a drawing.scene reply schema that allows text.

This adds those three and nothing that draws. It is drawing data only, with no kernel geometry.

For #4890, into drawings. Two commits: the change, then one more check on the font lookup.

Merge order: this PR first, then #12356 and #12357, which hold its commits below their own.

Changes a default: no

What it does

  • Scene::font_records_beyond(fonts): the records fonts would add to the scene's font table. A new font counts in full; a font the table already holds counts only the glyphs it doesn't have yet. One rule for every piece that puts text on a sheet, so each one counts against the scene's record limit the same way, before it joins.
  • TextRun::reach(): how far a run's glyphs go along its baseline, in millimetres. A dimension needs it to know whether its text fits between the arrows.
  • One font lookup: text::font_in finds a font by id in a table in id order. Prepared::font uses it, and so will the pieces that follow.
  • drawing.scene's output schema lists text items (a run's font, glyphs, clusters, origin, angle, slant, direction) and the scene's fonts (metrics, flags, glyph outlines). A font's bytes never appear. Until now, a reply with text in it wouldn't have matched its own schema.

Options considered: (1) each text piece counts its own font records; (2) one count on the scene, as here. (1) would write the "only the glyphs it doesn't hold" rule once per caller. (2) was chosen.

Tests

New, in the area's existing test files:

  • a_tables_new_records_and_a_runs_reach (geom/src/paper/text_tests.rs): a font new to the table counts all 12 of its records; held in full, 0; with glyph 2 missing, 5 (the glyph, its loop and its 3 pieces). A run's reach is where its last glyph ends (5.5).
  • a_replys_text_and_fonts_keep_to_its_schema (engine/src/drawing_scene_tests.rs): a sheet reply holding text set by the drawing font matches drawing.scene's schema. Its item is text, its font's id matches the run's, and no font has bytes.

Planted faults, 8, each caught by the tests above, then a clean run: held glyphs counted again; a held font counted as new; the table ignored; a run's reach taken to its last glyph's start; the font lookup taking the first font (caught once the test had a second font, which is the second commit); the font schema refusing a subset font; the schema without the text item; the schema without the fonts.

Overlaps

@0xlillith's #7608 (sheet sketch scenes, draft) and @armin0411's #9421 and #9463 (centre marks) also change schema/drawing_view.rs and geom/src/paper.rs. None of them touches text or fonts. This PR adds the text item to the whole sheet's item list beside pictures, and leaves the rest of those files as they are.

Validation

Local, Windows, --profile ci: the paper tests in solidcraft-geom (68) and drawing_scene in solidcraft-engine pass; cargo fmt --check; cargo check --workspace --all-targets on drawings ca6a09579 (after #12087), no warnings.

Replayed on 6 Nov onto drawings f50edc1, after #12423 (a view draws again only when what it shows changes), #12449 (a deferred drawing keeps its lines until it is updated), #12516 (a view's lines come in line groups) and #11126 (a view's dimensions are worked out beside the window) merged. They change the same scene files, and each merge keeps both sides. The sheet scene's step keeps #12423's check for views that still show the same thing and #12449's hold for a deferred drawing, then sets the dimensions in the drawing's lettering. #11126's job carries that lettering in its ticket in place of the units alone, so a dimension worked out beside the window is set in the same font and language as one set in the step. Dimensions keep #12516's line groups and add their text. The scene and inspect command descriptions keep #12449's and #12516's words beside this stack's. #12449 added out_of_date to the scene reply, so the schema test that builds one sets it (out_of_date: Vec::new()). The replay of 5 Nov onto 41dcdd1 needed one change too: #12396 gave a view's drawn state an owners field, set to None in the dimension text test. Checks (Windows, --profile ci): cargo check --all-targets and cargo fmt --check of geom, sketch, doc, io and engine at each commit. At the head of the title block text PR (#12357), which holds all three, on drawings f50edc1: clippy with warnings denied; engine drawing 365, title_block_text 6 and schema 191 passed, with #11126's two job tests (a_job_beside_the_window_draws_as_a_step_does, seeded_edits_steps_and_jobs_always_end_at_the_built_scene). On drawings 1b069e1, the same code before these merges also passed sketch paper_text 47, io paper 45, geom paper 72, doc drawing 90 and engine hostile 72, and the wasm check of the engine.

Earlier, replayed on 5 Nov onto drawings 69709bd (the line groups of #12232 touched the scene's files; both commits applied cleanly): cargo check --all-targets of geom, sketch, doc, io and engine at each commit, then the paper and drawing tests again with the dimension text PR on top (geom paper 72, engine drawing 337, schema 191). Nothing is drawn yet, so there is no picture.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CamWight and others added 2 commits November 6, 2026 07:31
…the sheet reply's schema (tangency-labs#4890)

One rule for everything that puts text on a sheet: `Scene::font_records_beyond`
counts only what a scene's font table doesn't hold yet, `TextRun::reach` says
how far a run's glyphs go along its baseline, and `drawing.scene`'s schema has
text runs and fonts, never a font's bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CamWight
CamWight force-pushed the drawing-font-table-4890 branch from 046a6da to 7e56a4a Compare November 6, 2026 08:12
@CamWight
CamWight marked this pull request as ready for review November 6, 2026 08:13

@theironchef theironchef left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Read at 7e56a4a5 (source only; not built locally).

I found no defects. What I checked:

  • records_beyond(None) gives the old records() count exactly (1 for the font, plus every glyph), so the existing record budget is unchanged.
  • reach(): PlacedGlyph::x and advance are already in millimetres, and an RTL run keeps its glyphs in visual order along the baseline, so taking the maximum of x + advance is the right extent in both directions. Starting the fold at 0.0 gives an empty run a reach of 0, which seems right.
  • font_in keeps the binary search that Prepared::font had, and the second commit's test with a font 9 next to a font 7 would catch a lookup that took the first font.

Small, optional points:

  • font_records_beyond counts a font twice if more holds the same id twice (or two partial copies with glyphs in common). It over-counts, so it errs toward refusing, and the doc says "each font once". A debug assertion or a line in the doc about what callers must pass might save the next caller a surprise.
  • In the schema, a glyph id is minimum: 0 with no maximum: 65535, though it's a u16. The keys of a font's glyphs map aren't constrained either (propertyNames with a digits pattern). face, num_glyphs and units_per_em could take minimum: 0 as well. None of this affects the reply's validity, only how tight the schema is.

@CamWight

CamWight commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Landed in drawings with #12778 (2a25449), which carried this commit

@CamWight CamWight closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:kernel B-rep kernel, booleans, blends, STEP/IGES

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants