Skip to content

warn and auto-select weight when font_name has no Normal(400) face#810

Open
romanstingler wants to merge 1 commit into
MalpenZibo:mainfrom
romanstingler:fix/font-name-validation
Open

warn and auto-select weight when font_name has no Normal(400) face#810
romanstingler wants to merge 1 commit into
MalpenZibo:mainfrom
romanstingler:fix/font-name-validation

Conversation

@romanstingler

Copy link
Copy Markdown
Collaborator

ashell silently falls back to a different font when the configured font_name exists in the system font database but has no face with weight=Normal(400) (e.g. Terminus TTF, whose Regular face reports weight=500/Medium in its OS/2 table). This happens because cosmic-text's font matcher re-scores all faces and prefers the one whose weight is closest to the requested Normal(400), even if that means picking a font from a different family.

https://docs.rs/fontdb/0.23.0/src/fontdb/lib.rs.html#986
https://docs.rs/iced_core/0.14.0/src/iced_core/font.rs.html#74

Changes:
Add fontdb as a direct dependency (same version already used transitively by iced_layershell)(@MalpenZibo no idea i am really weighing if it is OK to keep it here or to put it into iced_layershell, but I think maybe you want to keep iced_layershell as slim as possible).

Add resolve_font() which:

  • Finds all faces matching the configured font name.
  • Picks the closest match to Normal style/stretch and weight 400.
  • Builds an iced::Font with that face's actual weight and style, so cosmic-text's matcher stays on the right font.
  • Warns clearly when no Normal(400) face is available.
  • Warn when the font name isn't found at all (with a suggestion to use fc-list).
Image image

Fixes #768
Image

@github-actions github-actions Bot added the bug Something isn't working label Jun 11, 2026
@romanstingler romanstingler force-pushed the fix/font-name-validation branch from 529accb to e58e83e Compare June 11, 2026 21:23
@MalpenZibo

Copy link
Copy Markdown
Owner

Yep, it's something a little bit borderline and maybe could be placed in iced_layershell. I need to think about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminus fonts not working

2 participants