Skip to content

Drawings: title block and dimension text share one rule for waiting on fonts - #12846

Merged
bherbruck merged 1 commit into
tangency-labs:drawingsfrom
CamWight:sheet-text-one-rule-4890
Nov 7, 2026
Merged

bherbruck merged 1 commit into
tangency-labs:drawingsfrom
CamWight:sheet-text-one-rule-4890

Conversation

@CamWight

@CamWight CamWight commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Change

A drawing sheet sets its text, such as a title block's labels and values or a dimension's number, in the drawing's font. When a character needs another font, an export waits for the font search, and the window asks the search and shows the text once it answers. Before this PR, the title block and the dimensions each made that choice themselves, and each turned the answer into set, pending or refused. Now one small piece in crates/sketch/src/paper_text.rs does both, and the title block and the dimensions use it. Parts lists and revision tables on the sheet will use it too, in a later PR.

Part of #4890, into drawings. One commit on drawings, not stacked.

Changes a default: no
The same text is set in the same fonts, and pending or refused in the same cases. Nothing on screen changes.

What it does

  • PaperFonts holds the drawing's font family and language, and the font folders, listed once. PaperFonts::new(family, language, wait) chooses the way in: waiting for the font search (export, drawing.inspect) or asking it (the window's sheet). lines measures and text sets, by that choice.
  • Outcome is the one mapping of an answer: set; pending (only the window asks, so only it sees this); or refused, with why.
  • title_block_text::lay and drawing_dimension_paper::paper_group take a &PaperFonts instead of the family, the language and a wait flag. The title block's own measuring closure and the dimension text's choice of function are gone.
  • The sheet scene makes one PaperFonts for each title block and each read of dimensions, and drawing.inspect makes one.

Cost: the list of font folders is made once for each block and each read of dimensions. Before, the window's sheet made it once per dimension, and an export once per text. Making it reads no disk (it comes from a few environment variables), so the gain is small: the reason for the change is one rule in one place.

Validation

Local, Windows, --profile ci. The run was on drawings f1153f4. The commit was then replayed onto d506dd6 (the same patch; #12839, merged since, touches none of these files) and checked again there:

  • cargo fmt: no diffs; cargo check and cargo clippy -- -D warnings over geom, sketch, doc, io and engine, all targets: clean; sketch builds for wasm32-unknown-unknown. On d506dd6: cargo check --all-targets of sketch, doc and engine clean, and the sketch paper_text tests pass.
  • Tests: sketch paper_text 50 of 50; engine title_block, drawing_scene, drawing_dimension, drawing_export and cmd::drawing 191 of 191.
  • New test, written first and failing before the change: crates/sketch/src/paper_text_tests.rs, a_sheets_text_is_set_pending_or_refused. Asking is pending until the search answers, then sets what waiting sets; waiting is never pending; a character no font has is refused with why, either way.
  • The title block's and the dimensions' own tests are the proof that their behaviour is unchanged, including the window's pending ones.
  • Planted faults: 3 of 3 caught, each by the new test and by the callers' own tests, then a clean run that passed. The faults:
    • pending read as refused;
    • the waiting way in dropped (always asks);
    • the asking way in dropped (always waits).
  • A caller going back to its own copy can't fail a behaviour test, so the run counts the engine's own calls of sketch's waiting and asking text functions: 0, where drawings had 5 before this PR.

What the tests don't reach:

  • how often the font folders are listed: checked by reading the code;
  • the web app's own route, where text waits while a web font loads: it sits under these functions and is unchanged, and no browser test runs here.

Screenshots of the behavior

None. Nothing on screen changes: the same text is drawn the same way.

Integration status

On drawings d506dd6, checked 2026-11-07 02:58 UTC. @0xlillith's #12039 changes paper_text.rs and sketch's lib.rs too. It already needs a small join with drawings there. This PR adds no conflict to it: the same two places in paper_text.rs and one in lib.rs, with or without this PR. #12039 adds another pair of waiting and asking functions (paper_text_with_flow and paper_text_with_flow_now), which could later become one PaperFonts method. Four open PRs (#9421, #9463, #7608, #10761) change drawing_scene.rs or cmd/drawing.rs. This PR changes a few lines in those two files (two imports, a new line that makes the dimensions' PaperFonts, and three calls) and adds no conflict to any of the four.

…ng or refused (tangency-labs#4890)

The title block's text and a dimension's text each chose for themselves between waiting for the
search for fonts to fall back to (an export, drawing.inspect) and asking it (the window's sheet),
then each mapped the answer to set, pending or refused. That rule is now in one place, in sketch
beside the fonts: PaperFonts holds the drawing's family and language with the font folders listed
once, and sets lines or text the waiting or the asking way; Outcome is the one mapping of its
answer. The title block's lay and the dimensions' paper_group take a PaperFonts, made once for
each block and each read of dimensions. Nothing else changes: the same text in the same fonts,
pending and refused in the same cases. A parts list's words on paper will use it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 7, 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

@github-actions github-actions Bot added the area:sketch sketcher and constraint solver label Nov 7, 2026
@bherbruck
bherbruck merged commit e50e7e1 into tangency-labs:drawings Nov 7, 2026
31 checks passed
@CamWight
CamWight deleted the sheet-text-one-rule-4890 branch November 7, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:sketch sketcher and constraint solver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants