Skip to content

Ribbon: the Font list offers the installed fonts, theme fonts first (builds on #961, #974) - #1179

Open
richard1912 wants to merge 10 commits into
storytold:mainfrom
richard1912:ui/installed-font-list
Open

richard1912 wants to merge 10 commits into
storytold:mainfrom
richard1912:ui/installed-font-list

Conversation

@richard1912

@richard1912 richard1912 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #961 (and #952 under it) and #974, for the rest of #933: the Font list offers the installed fonts. Marco suggested this go up as its own PR rather than into his branch (marcoarnulfo#2). Until those PRs land, the diff here includes their commits; the new work is the last three commits.

What changes

  • The Font list offers the installed fonts (crates/ui-egui/src/ribbon.rs): the workbook theme's heading and body fonts first ("Calibri (Headings)", "Calibri (Body)"), then every font, standard and installed (fonts::families()), A to Z, as in Excel.
  • Typed names autocomplete from the same list: an exact name first, then the first font it begins (comic gives Comic Sans MS, wingd Wingdings, Aptos stays Aptos); anything else is applied as typed, as before.
  • List width: the font list drops 280 pt wide (wider than the box, like Excel's) so long family names stay on one line. The size list keeps the box width.
  • Highlight: starts on the font's own row in the A to Z list, not its theme entry, so Down from Calibri still moves to Cambria (the_arrow_opens_the_list_of_fonts). combo_popup uses rposition for this.
  • Built once: the list is built after the background scan and borrowed afterwards, since the ribbon draws every frame.
  • Font race fix (also on Fonts: start the installed-font scan in the app (installed fonts were never listed or rendered) #974): cell_family only names families the context's own fonts have, and a font rebind no longer skips a frame (a skipped frame dropped that frame's input). Without it, starting the scan made header_autofit and page_layout_view flaky on Windows; details in the Fonts: start the installed-font scan in the app (installed fonts were never listed or rendered) #974 comment.

Validation (Windows 11, 150%)

  • Real key presses: Arial, Ari, Aptos, comic, Segoe UI S, wingd + Enter give Arial, Arial, Aptos, Comic Sans MS, Segoe UI Symbol, Wingdings; Zzz Fake is applied as typed; Esc reverts.
  • The list shows the theme fonts then ~190 installed families, scrolls, and long names fit.
  • Full ui-egui suite three times in a row, workspace tests, cargo fmt, cargo clippy --workspace --all-targets -- -D warnings and cargo xtask wasm pass. header_autofit 0/10, page_layout_view 0/12 and keytips 0/3 failures on repeated runs (on Ribbon: the Font name box applies a typed name on Enter #961's head keytips failed 4/4 here).

Not included: drawing each name in its own face in the list (optional in #933).

Refs #933

Summary by CodeRabbit

  • New Features

    • Font and font-size controls now support inline editing, dropdown selection, filtering, keyboard navigation, and cancellation.
    • Font names can be matched exactly or by prefix, while custom font entries are preserved when no match is found.
    • Font-size entry supports validated values from 1 to 409.
  • Bug Fixes

    • Improved font scanning and loading so workbook fonts are available more reliably.
    • Fixed font rendering during font updates to prevent skipped UI frames.
    • Improved handling of theme and installed fonts across cells, charts, and editing controls.

marcoarnulfo and others added 9 commits October 13, 2026 10:35
The size box is one frame with the Font name box's fill, border, height and
corners, with the text field and the dropdown arrow inside it (focus shows
the selection stroke). The size list drops directly below the box and is as
wide as it, instead of opening 220 pt wide under the arrow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ut3hr3a13szpQdQ7gbYbfc
…torytold#933)

The font name had the Enter bug Font Size had in storytold#932: Enter applied the
highlighted row of the substring-filtered list, so Aptos gave Aptos Narrow,
and a name outside the list was dropped. The font name is now the same box
as Font Size, sharing its code: Enter applies the first list font the typed
name begins (case-insensitive, so arial and Ari give Arial), otherwise the
name as typed; Escape or clicking away reverts; the arrow opens the fonts.
The keytip tests that used the font dropdown to exercise the filter combo
now use the number format dropdown.
The desktop and web apps call setup_context_for_language directly, not
setup_context, so fonts::start_scan never ran: the font catalog stayed
empty, the Format Cells font list showed only the standard names and cells
formatted with an installed font couldn't render in it. Start the scan
there too (once; later calls and wasm are no-ops).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wasm)

Contributed by @scottcampbelldata in #1.

Co-authored-by: scottcampbelldata <251750033+scottcampbelldata@users.noreply.github.com>
The Font box listed only the 22 standard names. It now shows the workbook
theme's heading and body fonts, then every font (standard and installed,
from fonts::families) A to Z, as in Excel. Typed names autocomplete from
the same list: an exact name first, then the first font it begins. The list
is built once after the background scan and borrowed afterwards, and drops
wider than the box (280 pt) so long family names stay on one line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Font list repeats the theme fonts at the top, so the highlight now
starts on the last row with the current value: Down from Calibri moves to
Cambria, as font_name_box::the_arrow_opens_the_list_of_fonts expects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on rebind

Once the installed-font scan runs, set_bound updates a process-wide registry as
soon as new definitions are built, but egui applies them only at the next pass,
and every context (each test harness) has its own fonts. cell_family could then
name a family egui doesn't have, which panics in epaint ("FontFamily ... is not
bound to any fonts"); parallel UI tests on Windows hit this in header_autofit.

cell_family takes the context and, for an installed family, also checks that
context's font definitions (after its first pass). With that, the frame in which
a rebound font set is pending can paint, so the rebind no longer skips a frame:
a skipped frame dropped that frame's input, which made page_layout_view's ruler
drags miss now and then.

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

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3eabc88-8a93-4435-bae8-c30c16f3d94e
📥 Commits

Reviewing files that changed from the base of the PR and between 23829d8 and 9a1f392.

📒 Files selected for processing: 10
  • contributors/people.toml
  • crates/ui-egui/src/chartview.rs
  • crates/ui-egui/src/grid.rs
  • crates/ui-egui/src/lib.rs
  • crates/ui-egui/src/ribbon.rs
  • crates/ui-egui/src/theme.rs
  • crates/ui-egui/tests/font_name_box.rs
  • crates/ui-egui/tests/font_scan_starts.rs
  • crates/ui-egui/tests/font_size_box.rs
  • crates/ui-egui/tests/keytips.rs

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

📝 Walkthrough

The ribbon now has editable font and font-size controls. Font scanning and font-family resolution use the egui context, and painting continues while replacement fonts await activation. Tests cover the controls and context-dependent font selection. The contributor registry adds Marco Arnulfo.

Changes: Font controls and rendering

Layer / File(s) Summary
Font scan and frame lifecycle
crates/ui-egui/src/lib.rs, crates/ui-egui/tests/font_scan_starts.rs
Language-specific context setup starts font scanning. The UI continues painting while replacement fonts await activation.
Context-aware font resolution
crates/ui-egui/src/theme.rs, crates/ui-egui/src/chartview.rs, crates/ui-egui/src/grid.rs, crates/ui-egui/src/ribbon.rs
cell_family checks the egui context before selecting a bound workbook font. Rendering call sites pass the context, and tests cover font availability and fallback roles.
Editable font and size controls
crates/ui-egui/src/ribbon.rs, crates/ui-egui/tests/font_name_box.rs, crates/ui-egui/tests/font_size_box.rs, crates/ui-egui/tests/keytips.rs
The ribbon uses editable text boxes and dropdowns for font names and sizes. Tests cover matching, selection, cancellation, validation, and number-format popup interactions.

Contributor registry

Layer / File(s) Summary
Add contributor entry
contributors/people.toml
The registry adds Marco Arnulfo’s real name and disables GitHub-name synchronization.

Priority: ⬇️ Low

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

Change: Feature

Suggested reviewers: echelon, justinjohn0306, vangel76

Merge Risk: ⚪ Minimal · up to 9a1f3

The change adds editable font and size boxes and keeps painting while fonts rebind. No actionable merge-blocking issue was identified.

Security architecture risk: 🔵 Low · up to 9a1f3

Desktop startup now discovers installed fonts through an additional initialization path. Existing filtering and font validation constrain that exposure, and rendering checks the active context before selecting an installed family. No introduced security defect was established, but deployment privileges and failure behavior were not verified at runtime.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly reachable native processing runs inside the desktop application: filesystem-controlled font metadata enters the shared catalog, and workbook-selected installed families supply local rendering data. The inspected path does not establish a remote tenant boundary, outbound disclosure channel, or additional privilege grant. Effective OS privileges and sandbox containment remain unknown.

Trust Boundaries and Controls

  • observed — At the filesystem-to-catalog boundary, discovery filters font extensions, skips files whose metadata exceeds 64 MiB, deduplicates canonicalized directories, and skips unreadable files or rejected font faces. Rendering also checks family availability in the active context. These are concrete controls, not proof that parser behavior or all filesystem races are safe.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 63.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 9 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: adding installed fonts to the Ribbon Font list and placing theme fonts first. The issue references add minor noise but do not make the title unclear.
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: Docstring Coverage

Explanation

Docstring coverage is 63.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 9 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@musaad-sharikh

Copy link
Copy Markdown

A small improvement suggestion, from reading the code and not measured: font_list() already caches the families in a OnceLock once the scan finishes, but font_combo still builds items on every frame the ribbon draws, cloning each family name into a new String whether or not the list is open. combo_popup reads items only on the frame the popup opens (anchor.clicked()) and while it stays open (Popup::is_id_open(ctx, anchor.id.with("popup"))), so items could be built only then:

let listing = arrow.clicked() || egui::Popup::is_id_open(ui.ctx(), arrow.id.with("popup"));
let mut items: Vec<(&str, String)> = Vec::new();
if listing {
    // theme fonts, then `fonts`
}

I have not checked whether the per-frame clones are noticeable, so this is a suggestion rather than a reported slowdown.

This branch has not been deployed

No deployments
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.

4 participants