web engine - experimental web browser

Font discovery: enumerate and load system fonts #28

open opened by pierrelf.com

Phase 2: Pure Rust Font Engine#

Improve font loading to enumerate available system fonts and support loading by family name, rather than hardcoding paths to Geneva/Monaco.

Font discovery#

  • Scan /System/Library/Fonts/ and /Library/Fonts/ directories
  • Read font files and extract name table metadata (family name, subfamily)
  • Build a font registry mapping family names to file paths
  • Support .ttf and .otf file extensions
  • Handle font collections (.ttc files) — parse the TTC header to extract individual font offsets

Font selection API#

  • FontRegistry::new() -> FontRegistry — scans system font directories
  • FontRegistry::find_font(family: &str) -> Option<Font> — load by family name
  • FontRegistry::find_font_with_style(family: &str, bold: bool, italic: bool) -> Option<Font> — load with style preference
  • FontRegistry::list_families() -> Vec<String> — list available font families

Fallback#

  • Default fallback font if requested family not found
  • Maintain a prioritized list: requested font -> system default -> any available font

Acceptance criteria#

  • System font directories are scanned on initialization
  • Fonts can be loaded by family name (e.g., "Helvetica", "Times New Roman")
  • TTC collections are handled (extract individual fonts)
  • Font registry lists available families
  • Fallback works when requested font is not found
  • All existing tests continue to pass
  • cargo clippy --workspace -- -D warnings passes
  • cargo fmt --all --check passes
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mflhl3nj5b2l