fix: font load error panic

This commit is contained in:
galister
2024-05-04 00:50:53 +09:00
parent 9a693862ba
commit 6ee0cb4fd1

View File

@@ -179,7 +179,10 @@ impl FontCache {
) -> anyhow::Result<Rc<Glyph>> { ) -> anyhow::Result<Rc<Glyph>> {
let key = self.get_font_for_cp(cp, size); let key = self.get_font_for_cp(cp, size);
let font = &mut self.collections[size].fonts[key]; let Some(font) = &mut self.collections[size].fonts.get_mut(key) else {
log::warn!("No font found for codepoint: {}", cp);
return Ok(self.collections[size].fonts[0].glyphs[0].clone());
};
if let Some(glyph) = font.glyphs.get(cp) { if let Some(glyph) = font.glyphs.get(cp) {
return Ok(glyph.clone()); return Ok(glyph.clone());