Skip to content

examples: add font-info example#278

Closed
leonardcosta-hub wants to merge 1 commit into
servo:mainfrom
leonardcosta-hub:add-font-info-example
Closed

examples: add font-info example#278
leonardcosta-hub wants to merge 1 commit into
servo:mainfrom
leonardcosta-hub:add-font-info-example

Conversation

@leonardcosta-hub
Copy link
Copy Markdown

Summary

Adds a new font-info example that demonstrates the core font-kit API in a single self-contained program.

What it covers

  • Font Metadata — loads the system sans-serif via SystemSource and CSS matching, then prints full name, PostScript name, monospace flag, and glyph count
  • CSS Properties — reads style, weight, and stretch from the matched font
  • Font Metrics — dumps all OS/2-table metrics (ascent, descent, line gap, cap height, x-height, underline, bounding box) in font units
  • Glyph Inspection — iterates a sample set of characters (A, g, @, ) and reports glyph ID, advance, origin, and a breakdown of Bézier path commands using a custom OutlineSink implementation
  • CSS Font Matching — re-runs select_best_match requesting bold italic to demonstrate the matching algorithm
  • Raster Bounds — calculates the pixel bounding box for a glyph at a given point size

Testing

Compiles and runs cleanly on macOS (Core Text backend) with Rust 1.95:

cargo run --example font-info

Co-Authored-By: Oz oz-agent@warp.dev

Adds a new example that loads the system's best-matching sans-serif
font and prints its metadata, CSS properties, font metrics, per-glyph
inspection (with an OutlineSink that counts path commands), a CSS
bold-italic match demo, and raster bounds for 'H' at 24 pt.

Co-Authored-By: Oz <oz-agent@warp.dev>
@leonardcosta-hub leonardcosta-hub closed this by deleting the head repository Apr 29, 2026
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.

1 participant