Skip to content

Publication sheets scale their legend, scale bar and graticule labels with the sheet (#2581, part 3) - #2725

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/2581-publication-text-size
Nov 23, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/2581-publication-text-size

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Publication Layout sizes its title, subtitle and footer by the sheet's short side (A4 = 1), but its legend, scale bar labels and graticule labels stayed at their A4 sizes, and the strips kept for the graticule's labels stayed fixed in mm. On A2, A1 and A0 they came out tiny next to the title; on A5 portrait a long legend took so much of the page that the map was fitted at a smaller scale and veiled. Parts 1 (#2590) and 2 (#2660) gave the three elements a text size; this is part 3 of #2581: Publication Layout sets them with the sheet.

  • One rule, in layout.publication (crates/engine/src/cmd/layout.rs): next to the sheet's factor k (short side / 210 mm, 1 for a figure) that its titles already use, the legend's textSize is 9 × k, the scale bar's textSize 8 × k and the graticule's labelSize 8 × k, and the label strips (LABEL_ROOM_SIDE 9 mm, LABEL_ROOM_END 6 mm) are scaled by k. Every page size a sheet takes gives k from 0.70 (A5) to 4.0 (A0), so the sizes stay within the 4 to 100 points a text size takes; no clamp is needed.
  • Measured at those sizes: the legend's rows (at the scale tried, and at each moved frame when no shape fits) through legend_sizes_with_no_data_mm with the sheet's size, and the scale bar's box through the bar it will add. The strips set the fitted scale, the surrounds' margins, the panel and editorial frame's target height and the portrait or landscape choice.
  • They are values like any other: the Format pane shows them and they can be changed by hand; null gives an element its own default, 9, 8 or 8 points, as it always has. A reset to the sheet's size would need the element to know its sheet, which it doesn't.
  • A4 sheets and figures stay as they are: k is 1 there, so every size is the default and nothing new is written.
  • Saved projects: a sheet other than A4 (Letter, Legal and Tabloid too, at about 1.03 to 1.33 times) now carries non-default sizes, so it requires the layout-text-size capability from parts 1 and 2, and a RustGIS release older than that capability refuses it rather than drawing it at A4's sizes. No new capability, as no field is new; cargo xtask schema --check passes unchanged.
  • Docs: docs/user-guide/layouts.md.

Reach every surface

  • Desktop, browser, command line, Python, Assistant and MCP, task steps and scripts: all build a publication through the one layout.publication command, so all get the new sizes; no parameter is added, so no tool description changes.
  • Ribbon and menus: Publication Layout's existing entries; no new control. The sizes it sets show in the Format pane's Text size and Label size rows (parts 1 and 2), where they can be changed by hand. Phone: the touch interface has no layouts. Plugins: nothing new.
  • The way back: undo removes the layout, as before.

Not in this PR (noted for follow-ups): a publication's colorbar and the 2 mm padding of its legend box keep their A4 sizes; a thesis-half figure's reference line crosses the page edge on main already (found by the new test's text-loss check, which here checks the legend and the scale bar only).

Testing

  • checks.sh on this branch (based on main at 17773dd): fmt, doctests and cargo xtask layers passed; nextest ran 8879 tests, 8878 passed. The one failure, portable_projects::reload::reload_reconverts_duckdb_table_and_keeps_only_its_original_geometry_branch, is the DuckDB test that fails on this machine's DuckDB, as noted in feat(layout): a legend takes a text size, its rows and swatches following (#2581 part 1) #2590 and Layout scale bars and grids take a label size (#2581, part 2) #2660; it touches no layout code. Clippy on the workspace with -D warnings and cargo xtask schema --check passed after a lint fix in the new test. hostile_params_never_panic passed.
  • Tests (the first two written before the code and seen failing for their reason; the range check and the A0 zoom's size check added after review):
    • engine::tests::a_publication_sheets_surround_texts_follow_its_short_side (new): on A4 portrait and landscape, a journal and a thesis figure, Letter, A5 and A0 (classic and panel), the legend is 9 × k, the scale bar 8 × k and the grid labels 8 × k; the saved project requires layout-text-size exactly when k ≠ 1 and reads back identical; the legend and the scale bar lose no text when the page is drawn; after the A0 frame's scale is tripled, its scale bar keeps its size and loses no text. Before the change it failed at Letter: "a 9 pt legend".
    • engine::tests::publication_layouts_fit_their_pages (updated helper piaui_fits): the fitted scale is checked against strips scaled with the sheet; before the change it failed on A3 (1:4,300,000 for 1:4,403,636).
    • engine::tests::publication_sheets_follow_the_page_sizes: every sheet size gives its surrounds a size within 4 to 100 points.
    • engine::tests::a_publication_on_a5_portrait_keeps_its_legend_at_the_scale_that_fits (was …_at_a_smaller_scale): with the smaller A5 legend, Piauí's map is no longer drawn at a smaller scale and veiled; it is fitted at its own scale (1:8,900,000) and moved in its frame for the legend's room.
  • Headless ui_shot runs of the same script on this branch and on main (A0 and A5 portrait sheets of Piauí, exported): the pages differ where the surrounds are, as below.

UI evidence

The exported A0 portrait sheet of Piauí: main (left), with the legend, scale bar and graticule labels at A4's sizes, and this branch (right), at four times those, next to the title.

2581-publication-a0-before-after.png

The A5 portrait sheet: main (left) at 1:9,300,000, and this branch (right), with the surrounds at 0.7 times A4's and the map at 1:8,900,000.

2581-publication-a5-before-after.png

Related issue

Closes #2581

Summary by CodeRabbit

  • Improvements
    • Publication-sheet labels, legends, scale bars, and graticule margins now scale with the sheet size. Figure layouts retain their existing fixed sizes.
  • Documentation
    • Updated the layout guide with publication text-size scaling and A4 reference sizes.

…aticule labels with its short side (opengeos#2581)

On a sheet, layout.publication sets the legend's text size, the scale bar's and the
graticule's label sizes to their A4 sizes times the sheet's factor (its short side over
210 mm, as its titles already take), measures the legend and the scale bar's box at those
sizes, and scales the strips the graticule's labels take inside the frame with them.
A4 sheets and figures stay as they are.
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Publication layouts now scale graticule-label margins, legend text, scale-bar text, and grid-label text with the sheet’s short side. Figures retain fixed sizes. Tests cover text sizing, fitting, serialization, and A5 layout behavior.

Changes: Publication sheet scaling

Layer / File(s) Summary
Sheet-scaled sizes and frame geometry
crates/engine/src/cmd/layout.rs, crates/engine/src/tests.rs, docs/user-guide/layouts.md
Publication layouts scale graticule-label margins and text sizes by the sheet’s short-side factor. Frame calculations use the scaled margins. Tests and documentation cover these sizes.
Legend and scale-bar measurement and rendering
crates/engine/src/cmd/layout.rs, crates/engine/src/tests.rs
Legend measurements and rendering use the scaled legend text size. The scale bar uses its scaled text size for measurement and rendering. Tests check text fit and the updated A5 layout result.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Possibly related PRs

  • opengeos/RustGIS#2333: Adds publication sheet profiles and identifies fixed legend, scale-bar, and map-label sizes as a known limit.
  • opengeos/RustGIS#2660: Adds the text-size controls that this change scales by sheet size.
  • opengeos/RustGIS#1867: Defines a scale-bar remeasurement path used when its text size changes.

Suggested reviewers: giswqs

Merge Risk: Minimal · up to a4ef9

Publication sheets other than A4 now scale legend, scale bar and graticule label text with the sheet, and A4 sheets and figures are unchanged. No concrete merge-blocking risk was found. The one reported test failure is attributed to the local DuckDB version and is unrelated to layout code.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: publication sheets now scale their legend, scale bar, and graticule labels with the sheet. It also identifies the PR as part 3 of #2581. The changeset matches this. Th…
Description check Passed The description follows the template's Summary, Testing, UI evidence, and Related issue sections. The Summary explains the change, the rule, the A4 and figure behavior, and the saved-project capabilit…
Linked Issues check Passed [#2581] Part 3 requires Publication Layout to set legend textSize, scale bar textSize and graticule labelSize from the sheet factor k (short side / 210 mm; 1 for figures), to scale the graticule label…
Out of Scope Changes check Passed The changes fall within #2581 part 3. They are limited to crates/engine/src/cmd/layout.rs (publication sizing and strip scaling), crates/engine/src/tests.rs (new and updated tests for the same sizing …
Full details: Title check

Explanation

The title names the main change: publication sheets now scale their legend, scale bar, and graticule labels with the sheet. It also identifies the PR as part 3 of #2581. The changeset matches this. The sheet factor k sets these sizes, and the graticule label strips scale too. The title does not mention the strip scaling or the fitted-scale effect, but those are secondary.

Full details: Description check

Explanation

The description follows the template's Summary, Testing, UI evidence, and Related issue sections. The Summary explains the change, the rule, the A4 and figure behavior, and the saved-project capability impact. Testing lists the checks run and the new and updated tests, with one unrelated DuckDB failure noted. UI evidence includes before and after screenshots for A0 and A5 sheets, which the template requires for visible changes. Related issue says Closes #2581. The template's HTML comments were replaced with real content in each section.

Full details: Linked Issues check

Explanation

[#2581] Part 3 requires Publication Layout to set legend textSize, scale bar textSize and graticule labelSize from the sheet factor k (short side / 210 mm; 1 for figures), to scale the graticule label strips by k, and to leave A4 sheets and figures unchanged. The PR description and the AI-generated summary of crates/engine/src/cmd/layout.rs state that these changes are made in layout.publication. The head's layout.addElement parameter text already documents legend textSize (default 9) and scale bar textSize (default 8), so parts 1 and 2 are present at head. The new test a_publication_sheets_surround_texts_follow_its_short_side and the updated publication_layouts_fit_their_pages cover the sizes and fitted scale. Limitation: the diff of layout.rs could not be read (changed blobs unavailable), and the file read was truncated before the publication code. The verdict rests on the PR description, the summary and the test descriptions, not on a direct read of the changed code.

Full details: Out of Scope Changes check

Explanation

The changes fall within #2581 part 3. They are limited to crates/engine/src/cmd/layout.rs (publication sizing and strip scaling), crates/engine/src/tests.rs (new and updated tests for the same sizing and the A5 fit), and docs/user-guide/layouts.md (documents the new sizes). The PR states no new command parameter, capability or tool-description change, and cargo xtask schema --check passes unchanged. The unrelated DuckDB test failure is reported as environmental and not caused by this PR. The colorbar and legend-box padding remain A4-sized, which the PR lists as a deliberate follow-up, not as an out-of-scope change. The diff could not be read to confirm this directly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the sheets by moonlit light,
The labels grow as pages rise in height.
The legend and scale bar find their size,
While graticule strips stretch before our eyes.
Across the page, neat lines now hop just right.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d6a78c1f-8192-42e0-a53c-e2c038f23204
Commits

Reviewing files that changed from the base of the PR and between 437e112 and a4ef989.

Files selected for processing: 3

  • crates/engine/src/cmd/layout.rs
  • crates/engine/src/tests.rs
  • docs/user-guide/layouts.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Reviewed PR #2725 (sheets scale their legend, scale bar and graticule label text by the sheet's short side). I read the full diff, the base-branch AGENTS.md, and the surrounding code. I could not build or run the tests (no shell here), so the findings below come from reading the code. No prior review threads exist, so none were skipped. No inline comments were posted because nothing rose to a specific defect.

Bugs

None found. What I checked:

  • k is computed (cmd/layout.rs:1359) after the landscape profile rebinds page_w/page_h (:1309), so it uses the profile actually drawn.
  • landscape_suits (:1303) only runs for auto-sized sheets, so figures keep k = 1 and their output is unchanged. Confidence: high.
  • Every legend measurement inside publication now uses legend_pt (:2136, :2399, :2492). No default-size legend_sizes_mm call is left in the function. The publication legend has an empty title, so the omitted title height does not matter here.
  • The scale bar's text size is set before its box is measured and before it is added (:2169, :2952).
  • Saved-project capability is derived from element content (project_capabilities.rs:106), so layout-text-size is required exactly when a sheet has non-default sizes.
  • Sizes for every sheet size stay inside LAYOUT_TEXT_SIZE (4–100 pt), and the publication_sheets_follow_the_page_sizes test covers this.

Security

None found. No new parameters, no new input parsing, no new file or network access.

Performance

None found. The changed measurement calls run the same number of times as before, with a different font size.

Quality (nits, not posted inline; may wait for the release quality pass)

  • piaui_fits in tests.rs (~line 11832) infers whether a layout is a sheet by matching its dimensions against PUBLICATION_PROFILES. Reading the sheet flag and k from the publication result would be clearer. Confidence: medium.
  • The new text_losses check covers only Legend and Scale Bar, not the graticule labels, whose strips and label sizes both scale now. The strip and label sizes are scaled consistently, so this is a coverage gap rather than a defect. Confidence: medium.
  • The comment at cmd/layout.rs:1359–1363 states the 4–100 pt guarantee for every sheet. It could point at the test that enforces it. Confidence: high.

AGENTS.md

None found. The diff adds no unwraps or panics in non-test code, adds no new strings needing translation, and changes no saved field shape, so no schema or fixture update is needed. The cargo xtask schema --check result the PR reports is not something I could re-run.

Change size

Compared: the whole PR against main (merge base 17773dd to PR head a4ef989).

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 3.82 MB
Size after 3.83 MB
Total size change +5.9 KB
Path Before After Change
crates/engine/src/tests.rs 3,485.0 KB 3,489.9 KB +5.0 KB
crates/engine/src/cmd/layout.rs 366.7 KB 367.5 KB +847 B
docs/user-guide/layouts.md 64.1 KB 64.2 KB +161 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2725/
Web app https://preview.rustgis.app/pr-2725/app/
Commit a4ef989

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

Thanks. No change in this PR for the three quality notes:

  1. piaui_fits takes the issue's rule (short side / 210 mm) as the test's own reference; reading k from the result would check the command against itself.
  2. text_losses measures texts and scale bars, not grid labels; a check for those belongs with the text-loss check, not here.
  3. The 4–100 pt range is pinned by publication_sheets_follow_the_page_sizes.

@jgregoriorincon
jgregoriorincon marked this pull request as ready for review November 23, 2026 00:06
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Checked the 3-file diff (layout.rs, tests.rs, layouts.md) against the base AGENTS.md, including the call sites of legend_sizes_with_no_data_mm, landscape_suits (its k is defined at line 1201), the scale-bar box and its Scale Bar element, the requires capability logic in project_capabilities.rs, and the range constants in map/src/layout.rs. The sizes stay within 4–100 pt on every sheet, and at A4 and for figures k is exactly 1.0, so existing output is unchanged. Nothing I found rises to a bug.

Bugs: None found. The measured legend and scale-bar boxes use the same text sizes as the drawn elements (the search loops and the final element both pass legend_pt / bar_pt), and the strip constants are scaled identically in landscape_suits, the frame target height, the fit, and the warning check.

Security: None found. No input parsing or external data handling is changed.

Performance: None found. Measurement count per scale try is unchanged; the only added work is a clone() in a test.

Quality (nit, confidence high):

  • crates/engine/src/cmd/layout.rs around lines 2169–2176: a ScaleBar is built and then mutated through if let to set text_size, and bar_kind is then derived from it. A small constructor or helper that takes the text size would avoid the temporary mutation. Not worth a push on its own.
  • crates/engine/src/tests.rs, a_publication_sheets_surround_texts_follow_its_short_side: the text-loss check covers only the legend and scale bar, as the PR body says. That is a known gap, not a defect in this change.

AGENTS.md: No violations found. The changed files need no xtask schema update (no new saved field), the tests use unwrap only inside the #[cfg(test)] module, and there are no timer waits or identical-side assert_eq!s. The PR body covers the surfaces, the way back, and the saved-file capability.

Known and noted in the PR, not raised here: the colorbar and the 2 mm legend-box padding keep A4 sizes on sheets other than A4.

Earlier review threads: none exist on this PR, so there were no earlier concerns to leave alone.

Coverage: I did not run the test suite (no shell in this review). The PR reports checks.sh passing, except for one unrelated DuckDB test.

Change size

Compared: the whole PR against main (merge base 17773dd to PR head a4ef989).

Measure Value
Files changed 3 (added 0, modified 3, removed 0, renamed 0)
Size before 3.82 MB
Size after 3.83 MB
Total size change +5.9 KB
Path Before After Change
crates/engine/src/tests.rs 3.40 MB 3.41 MB +5.0 KB
crates/engine/src/cmd/layout.rs 366.7 KB 367.5 KB +0.8 KB
docs/user-guide/layouts.md 64.1 KB 64.2 KB +161 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 23, 2026
Merged via the queue into opengeos:main with commit 4217c0b Nov 23, 2026
27 checks passed
@jgregoriorincon
jgregoriorincon deleted the feat/2581-publication-text-size branch November 23, 2026 02:16
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.

[Feature]: Layout legend, scale bar and graticule labels take a text size, and Publication Layout scales them with the sheet

1 participant