gpui: Validate font contents at load time.

During layout of EditorElement we use 'm' character from current font to calculate sizes, panicking with fonts that do not have that character (e.g. Arabic fonts). It's not really EditorElement's fault, as it assumes that the font it's dealing with is gonna have that character available.
To prevent a crash, I added validation while loading a family that a given font contains the glyphs we're gonna use down the line.
This commit is contained in:
Piotr Osiewicz 2024-01-11 22:58:36 +01:00
parent 8478ddb6d2
commit a1049546a2

View file

@ -190,6 +190,9 @@ impl MacTextSystemState {
for font in family.fonts() {
let mut font = font.load()?;
open_type::apply_features(&mut font, features);
let Some(_) = font.glyph_for_char('m') else {
continue;
};
let font_id = FontId(self.fonts.len());
font_ids.push(font_id);
let postscript_name = font.postscript_name().unwrap();