From c242009cb821e4c73bb98481562031e5cd20c4f8 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Sat, 13 Jan 2024 05:52:27 -0800 Subject: [PATCH] Fixing set_font_family to not be sticky --- CHANGELOG.md | 2 ++ src/graphics.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46feeb6..6a16f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/graphics.rs b/src/graphics.rs index 28c0968..994dec8 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -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 {