-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Apply preferred font weight when loading variable fonts #7790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously, the `FontData::weight()` method stored the preferred weight but it was never applied to the actual font rendering. This change uses the weight value to configure skrifa's Location for the 'wght' axis, enabling proper variable font weight control in text rendering.
|
Preview available at https://egui-pr-preview.github.io/pr/7790-featurefont-weight-0333 View snapshot changes at kitdiff |
When loading variable fonts in egui, the first available weight was selected instead of the font’s default weight, making it impossible to control the rendered weight. This change applies the preferred weight (or the font’s default value) to the `wght` axis, ensuring variable fonts are rendered with the intended weight. Related PR: emilk/egui#7790
emilk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - thanks!
|
@emilk https://github.com/emilk/egui/pull/7790/files#diff-476cc9a474dfda61ceeb981bd3ea229a1ab4eb65330e74c0128ce257236938c9R177-R187 Ideally, it would be better to include a variable font directly in the source tree and add That said, adding variable fonts would significantly increase the source tree size, |
Previously, when loading a variable font (e.g. via `egui::FontData::from_static`), the font was rendered using the default (often the lightest) weight, ignoring any preferred weight configuration. This change applies the specified weight to skrifa's `Location` for the `wght` axis, ensuring that variable fonts are rendered with the intended font weight. ## Summary Fixes variable font weight not being applied during rendering. The `FontData::weight()` method now properly configures the font variation axis. ## Changes - Add `location: Location` field to `FontFace` to store variation coordinates - Pass `location` parameter through to glyph rendering functions - Apply weight to skrifa's `LocationRef` in `DrawSettings` and `HintingInstance` ## Weight Priority 1. `preferred_weight` from `FontData::weight()` 2. OS/2 table's `us_weight_class` 3. Variable font's fvar default value 4. `Location::default()` ## Related Issue - emilk#3218 : Not follow font id, but goal would be same ## Todo * [x] Apply preferred font weight when loading variable fonts * [ ] Add small size variable fonts for docs and egui (need discussion)
Previously, when loading a variable font (e.g. via
egui::FontData::from_static),the font was rendered using the default (often the lightest) weight,
ignoring any preferred weight configuration.
This change applies the specified weight to skrifa's
Locationfor thewghtaxis,ensuring that variable fonts are rendered with the intended font weight.
Summary
Fixes variable font weight not being applied during rendering. The
FontData::weight()method now properly configures the font variation axis.Changes
location: Locationfield toFontFaceto store variation coordinateslocationparameter through to glyph rendering functionsLocationRefinDrawSettingsandHintingInstanceWeight Priority
preferred_weightfromFontData::weight()us_weight_classLocation::default()Related Issue
Todo