Skip to content

fix(ui-egui): scale list markers with effective body font size - #243

Merged
DWAA1660 merged 2 commits into
AlienTechSoftware:mainfrom
Zaxaerith:fix/241-list-marker-font-size
Nov 14, 2026
Merged

DWAA1660 merged 2 commits into
AlienTechSoftware:mainfrom
Zaxaerith:fix/241-list-marker-font-size

Conversation

@Zaxaerith

Copy link
Copy Markdown
Contributor

Summary

This PR fixes #241 where unordered list bullets (•) and ordered list numbers ({number}.) did not scale with the body text font size.

Root Cause

In crates/ui-egui/src/preview.rs, body text in Block::Item uses draw_spans(..., 14.5 * zoom, ...), where individual spans scale via format_of using 14.5 * zoom * points / 11.0. In contrast, list markers were rendered using ui.label(RichText::new(...).color(tokens.muted)) without .size(...), causing egui to fall back to default body text size (14.0 pt) and ignore both custom font sizes and zoom level.

Fix

  • Introduced item_marker_size(spans: &[Span], zoom: f32) -> f32 to resolve the effective font size from item spans (matching draw_spans scale calculation: 14.5 * zoom * points / 11.0, or 14.5 * zoom if unspecified).
  • Applied .size(marker_size) to the marker RichText in Block::Item while preserving existing color (tokens.muted), nested indentation, RTL layout, and task checkbox behavior.

Verification

  • Added regression tests in crates/ui-egui/src/preview.rs:
    • list_marker_size_follows_effective_body_font_size_and_zoom: verifies default size (14.5), larger font sizes (18pt, 24pt), zoom factors (1.5x, 2.0x), and image span handling.
    • list_items_render_with_marker_scaled_for_ordered_and_unordered: tests rendering layout heights under egui for ordered/unordered lists with default vs larger font sizes, zoom scaling, and nested RTL items.
  • Ran targeted tests and linters:
    • cargo test -p notecraft-ui-egui --lib preview: passed (20 passed)
    • cargo test -p notecraft-ui-egui --lib: passed (347 passed)
    • cargo fmt --check -p notecraft-ui-egui: clean
    • cargo clippy -p notecraft-ui-egui --all-targets: clean (0 warnings)
    • cargo xtask text: 0 problems
    • cargo xtask i18n-audit: 0 source findings
    • git diff --check: clean

Fixes #241

@DWAA1660
DWAA1660 merged commit 5354183 into AlienTechSoftware:main Nov 14, 2026
10 checks passed
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.

BUG: Lists Dont Follow Font Size

2 participants