summaryrefslogtreecommitdiffstats
path: root/graphics/src/renderer.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-09-09 11:21:32 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-09-09 11:21:32 +0200
commit3450987355be7fe029db112474d06613929b54c7 (patch)
tree1d2186d822add1becdd5c942cc6a6c67e5437b57 /graphics/src/renderer.rs
parent837529bc995a728300c61fc102474cc31f7a6500 (diff)
downloadiced-3450987355be7fe029db112474d06613929b54c7.tar.gz
iced-3450987355be7fe029db112474d06613929b54c7.tar.bz2
iced-3450987355be7fe029db112474d06613929b54c7.zip
Invalidate existing paragraphs when new fonts are loaded
Diffstat (limited to 'graphics/src/renderer.rs')
-rw-r--r--graphics/src/renderer.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index f93f4a6d..d4df29a5 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -162,6 +162,29 @@ where
text::Paragraph::with_text(text, self.backend.font_system())
}
+ fn update_paragraph(
+ &self,
+ paragraph: &mut Self::Paragraph,
+ text: Text<'_, Self::Font>,
+ ) {
+ let font_system = self.backend.font_system();
+
+ if paragraph.version() != font_system.version() {
+ // The font system has changed, paragraph fonts may be outdated
+ *paragraph = self.create_paragraph(text);
+ } else {
+ match core::text::compare(paragraph, text) {
+ core::text::Difference::None => {}
+ core::text::Difference::Bounds => {
+ self.resize_paragraph(paragraph, text.bounds);
+ }
+ core::text::Difference::Shape => {
+ *paragraph = self.create_paragraph(text);
+ }
+ }
+ }
+ }
+
fn resize_paragraph(
&self,
paragraph: &mut Self::Paragraph,