зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1649676 - use fallback font if loading WR mac font descriptor fails. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D84625
This commit is contained in:
Родитель
b5254a1e31
Коммит
da45058f08
|
@ -2139,7 +2139,18 @@ fn read_font_descriptor(bytes: &mut WrVecU8, index: u32) -> NativeFontHandle {
|
|||
fn read_font_descriptor(bytes: &mut WrVecU8, _index: u32) -> NativeFontHandle {
|
||||
let chars = bytes.flush_into_vec();
|
||||
let name = String::from_utf8(chars).unwrap();
|
||||
let font = CGFont::from_name(&CFString::new(&*name)).unwrap();
|
||||
let font = match CGFont::from_name(&CFString::new(&*name)) {
|
||||
Ok(font) => font,
|
||||
Err(_) => {
|
||||
// If for some reason we failed to load a font descriptor, then our
|
||||
// only options are to either abort or substitute a fallback font.
|
||||
// It is preferable to use a fallback font instead so that rendering
|
||||
// can at least still proceed in some fashion without erroring.
|
||||
// Lucida Grande is the fallback font in Gecko, so use that here.
|
||||
CGFont::from_name(&CFString::from_static_string("Lucida Grande"))
|
||||
.expect("Failed reading font descriptor and could not load fallback font")
|
||||
}
|
||||
};
|
||||
NativeFontHandle(font)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче