Fixing set_font_family to not be sticky

This commit is contained in:
Jonathan Johnson 2024-01-13 05:52:27 -08:00
parent f8cb7e7f32
commit c242009cb8
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
2 changed files with 8 additions and 0 deletions

View file

@ -86,6 +86,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
that was incorrectly being applied to the lightness contrast calculation. In
short, this function should be much more accurate in perceived contrast
evaluation.
- `Graphics::set_font_family` now clears the cached font family list, ensuring
that the next call to apply_current_font_settings works correctly.
### Changed

View file

@ -66,6 +66,12 @@ impl<'clip, 'gfx, 'pass> Graphics<'clip, 'gfx, 'pass> {
)
}
/// Sets the current font family.
pub fn set_font_family(&mut self, family: cosmic_text::FamilyOwned) {
self.font_state.current_font_family = None;
self.renderer.set_font_family(family);
}
/// Returns the first font family in `list` that is currently in the font
/// system, or None if no font families match.
pub fn find_available_font_family(&mut self, list: &FontFamilyList) -> Option<FamilyOwned> {