Skip to content

Commit c0e50f3

Browse files
InnocentusLimenot-fl3
authored andcommitted
Fix glyph cache crash
1 parent 134a0ba commit c0e50f3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/text.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ impl Font {
7777
self.atlas = atlas;
7878
}
7979

80+
pub(crate) fn set_characters(
81+
&mut self,
82+
characters: Arc<Mutex<HashMap<(char, u16), CharacterInfo>>>,
83+
) {
84+
self.characters = characters;
85+
}
86+
8087
pub(crate) fn ascent(&self, font_size: f32) -> f32 {
8188
self.font.horizontal_line_metrics(font_size).unwrap().ascent
8289
}

src/ui/style.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ use crate::{
1010
Error,
1111
};
1212

13-
use std::sync::{Arc, Mutex};
13+
use std::{
14+
collections::HashMap,
15+
sync::{Arc, Mutex},
16+
};
1417

1518
pub struct StyleBuilder {
1619
atlas: Arc<Mutex<Atlas>>,
@@ -60,6 +63,7 @@ impl StyleBuilder {
6063
pub fn with_font(self, font: &Font) -> Result<StyleBuilder, Error> {
6164
let mut font = font.clone();
6265
font.set_atlas(self.atlas.clone());
66+
font.set_characters(Arc::new(Mutex::new(HashMap::new())));
6367
Ok(StyleBuilder {
6468
font: Arc::new(Mutex::new(font)),
6569
..self

0 commit comments

Comments
 (0)