Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pmnxis
Copy link

@pmnxis pmnxis commented Dec 18, 2025

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

Todo

  • Apply preferred font weight when loading variable fonts
  • Add small size variable fonts for docs and egui (need discussion)

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.
@github-actions
Copy link

Preview is being built...

Preview will be available at https://egui-pr-preview.github.io/pr/7790-feature/font-weight-0.33.3

View snapshot changes at kitdiff

pmnxis added a commit to pmnxis/chama-optics that referenced this pull request Dec 18, 2025
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
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