googlefonts / googlefonts/fontations
[Skrifa] Low overhead retrieval of adjusted metrics
- Dominant language
- Rust
- Stars
- 826
- Forks
- 75
- Avg merge
- 22h 33m
- Merged PRs (30d)
- 75
Description
In Skia, metrics retrieval is a first stage of glyph cache entry initialisation. There are two methods called on a Skia typeface backend: `generateMetrics()` and depending on glyph format then `generateImage()`, `generateDrawable()` or `generatePath()`.
Depending on hinting configuration or if the font is variable without variable mvar, in the `generateMetrics()` stage, the adjusted metrics from `Scaler::outline` may be needed without an actual draw call to draw the glyph.
Currently, the `Scaler` call signature is:
`pub fn outline(&mut self, glyph_id: GlyphId, pen: &mut impl Pen) -> Result `
One way to retrieve the metrics only is then to perform a call with a `Pen` performing only no-ops, but on the Skrifa side the path would be traversed.
For efficiency, it would be useful to have access to only the `ScalerMetrics`/`AdjustedMetrics` and the hinting or phantom point placement based on var-coords would only execute on phantom points and not the whole contour.
This could be done by wrapping the `Pen` argument in `Option<>` or providing a separate function.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at Skrifa's Scaler::outline API and trace how generateMetrics() obtains adjusted metrics before glyph drawing. Define an API that retrieves ScalerMetrics and phantom-point adjustments without traversing the contour, then verify that existing generateImage(), generateDrawable(), and generatePath() behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100