Skip to content

test(render): compare extent number centres across fonts - #3614

Merged
Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/layout-label-windows
Dec 2, 2026
Merged

Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/layout-label-windows

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Five extent-number placement tests fail with the default Windows and macOS fonts because their shared helper records each number's pen start while the assertions compare centres. Digits with different advances have different pen starts even when the renderer centres them at the same place.

Measure the horizontal centre from the recorded glyph advances before applying the page transform. Compare coincident positions within 0.001 page pixels to allow f32 round-off; the original font-dependent errors are about 0.8–1 pixel. This changes only test measurements and assertions, with no rendering or application behaviour change.

Testing

  • All 27 extent-indicator tests pass locally with installed fonts and with RUSTGIS_BUILTIN_FONTS=1 (0.11 s and 0.19 s).
  • Fork CI passed Linux, Windows x64 and Windows ARM, including the affected tests, lint, wasm, GDAL/DuckDB and memory checks: https://github.com/Mavrick-F/RustGIS/actions/runs/46901086282
  • macOS and iOS jobs were cancelled before acquiring a hosted runner. GitHub reports macOS ARM capacity constraints; a macOS retry was also cancelled before testing. These results remain unverified.
  • Formatting, contribution preflight and publication hooks passed.

UI evidence

No visible UI change.

Related issue

Follow-up to #3571. The same failures block #2931, #3016 and the nightly build.

Summary by CodeRabbit

  • Tests
    • Updated layout extent tests to account for glyph advances and nested transforms.
    • Added a small position tolerance when checking that unplaceable or clipped rows share a centre.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The extent layout tests now measure glyph runs by horizontal centre. Assertions for coincident number positions use a 0.001-pixel tolerance instead of exact coordinate equality.

Changes: Extent number centre tests

Layer / File(s) Summary
Centre measurement and placement assertions
crates/render/src/layout/extent_tests.rs
The test helper measures the final glyph’s horizontal centre after applying existing transforms. Placement tests use a 0.001-pixel tolerance when comparing positions.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Possibly related PRs

Suggested reviewers: jgregoriorincon

Merge Risk: Minimal · up to 24b81

This change only adjusts how tests measure and compare extent-number positions, with no change to rendering or application behavior. The affected tests passed on Linux and Windows, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "test(render): compare extent number centres across fonts" states the main change: the extent-number tests now compare glyph run centres instead of pen starts, so they pass across fonts. It …
Description check Passed The description follows the template. It has a Summary that explains the cause (pen start vs. centre comparison), the change (centre measurement and 0.001 tolerance), and the lack of behaviour change.…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test(render): compare extent number centres across fonts" states the main change: the extent-number tests now compare glyph run centres instead of pen starts, so they pass across fonts. It is specific, concise, and matches the raw summary and objectives. It is a conventional commit-style title with a clear scope.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the cause (pen start vs. centre comparison), the change (centre measurement and 0.001 tolerance), and the lack of behaviour change. The Testing section gives local and fork CI results, and it states that macOS and iOS results remain unverified. The UI evidence section states 'No visible UI change.' as the template requires. The Related issue section lists a follow-up to #3571 and blocked issues, so it is filled in. Minor gap: the Related issue wording does not use the template's 'Closes' or 'Part of' form.

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 each number’s place,
And measures glyphs at their centre.
A tiny rounding gap is fine,
The tests now keep that margin in line.
Then hops away, content with the sign.

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: 65e74a80-1d98-45ed-a371-b0f376a19219
Commits

Reviewing files that changed from the base of the PR and between 87d3e50 and 24b81c2.

Files selected for processing: 1

  • crates/render/src/layout/extent_tests.rs

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

@Mavrick-F Mavrick-F added ci:macos Run the macOS CI jobs on this pull request ci:windows Run the Windows CI jobs on this pull request labels Dec 2, 2026
let mut p = tiny_skia::Point::zero();
// Different digits need not have the same advance (notably in Windows'
// default font). Their pen starts differ even when their centres coincide.
let last = run.glyphs.last().unwrap();

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.

run.glyphs.last().unwrap() panics without saying which run was empty. Test code may unwrap (clippy.toml allows it), so this is not a rule break. Skipping an empty run keeps the failure in the assertion instead:

Suggested change
let last = run.glyphs.last().unwrap();
let Some(last) = run.glyphs.last() else { continue };
let width = last.x + run.font.h_advance_unscaled(last.id) * run.size / run.font.units_per_em().unwrap();

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Left for the release quality pass: this improves the diagnostic for an unexpected empty glyph run in the test helper. It does not affect the centre measurement fix.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

Scope: one test-only file, crates/render/src/layout/extent_tests.rs. The change moves the written helper from measuring each number's pen start to measuring its horizontal centre (pen x plus half the run's advance width), and replaces five exact assert_eq! checks on positions with a centred(…, SAME_CENTRE) tolerance of 0.001. I have no shell here, so I did not build or run the tests. The findings below come from reading the code.

Bugs

  • None found. The centre formula matches the glyph units used elsewhere: svg/vectors.rs scales glyph x by run.size / units_per_em, and pdf/content.rs does the same. The glyph x values include letter spacing, so last.x + advance gives the run's full width. Confidence: medium-high.

Security

  • None. The change is test-only.

Performance

  • None.

Quality

  • Inline comment on extent_tests.rs:62: run.glyphs.last().unwrap() panics on an empty run with no hint about which one. Test code may unwrap, so this is not a rule break. The suggestion skips empty runs instead. Confidence: high that it is a nit.
  • Unverified assumption: the five tests still use 8.0 px tolerances (for example lines 107, 131, 166, 242, 323, 351). Those tolerances were set when the helper measured pen starts, which sit about half a digit width left of centre. The helper now measures centres, so the margins have shifted. The PR says all 27 extent tests pass on Linux and Windows, which is the evidence I would check, but the 8.0 values may no longer mean what they did. Confidence: medium, a question rather than a defect.
  • Wording: SAME_CENTRE's doc says "page pixel", but the helper's own doc says layout points at 96 dpi. Align the two. Confidence: high, nit.
  • The centred doc was rewritten, which is fine, but it no longer says where the old half-width offset came from. Nit.

AGENTS.md

  • No rule break found. The new unwrap calls sit in a #[cfg(test)] module, which clippy.toml allows. The PR touches font-dependent test code, but the author ran Linux and Windows CI. The macOS jobs were cancelled and are unverified. Consider adding the ci:macos label so the platform is tested before merge. This is a process note, not a code finding.

Already raised: none. prior-reviews.json has no threads, so I left nothing out as a repeat.

Change size

Compared with main (merge base 46bcb21 to PR head 24b81c2), the whole PR.

Measure Value
Files changed 1 (0 added, 1 modified, 0 removed, 0 renamed)
Size before 22.6 KB
Size after 23.5 KB
Total size change +910 B
Path Before After Change
crates/render/src/layout/extent_tests.rs 22.6 KB 23.5 KB +910 B

@Mavrick-F

Copy link
Copy Markdown
Member Author

The ci:macos and ci:windows labels are already set. The 8-pixel checks remain approximate placement checks and include the baseline's vertical offset; the coincidence checks use the separate 0.001-pixel tolerance. All 27 extent tests passed locally with both font configurations, and the fork's Windows x64/ARM suites passed.

Tightening the broader placement bounds and aligning the remaining terminology are left for the release quality pass, along with the inline diagnostic suggestion.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3614/
Web app https://preview.rustgis.app/pr-3614/app/
Commit 24b81c2

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).

@Mavrick-F
Mavrick-F added this pull request to the merge queue Dec 2, 2026
Merged via the queue into opengeos:main with commit d75248d Dec 2, 2026
64 checks passed
@Mavrick-F
Mavrick-F deleted the fix/layout-label-windows branch December 2, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:macos Run the macOS CI jobs on this pull request ci:windows Run the Windows CI jobs on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant