desktop: Support device font with a non-zero index

This commit is contained in:
Tom Schuster 2024-01-19 18:42:20 +01:00
parent 5f123c3c01
commit e0f5b8906d
4 changed files with 7 additions and 1 deletions

View File

@ -22,6 +22,7 @@ pub enum FontDefinition<'a> {
is_bold: bool,
is_italic: bool,
data: Vec<u8>,
index: u32,
},
}

View File

@ -562,9 +562,11 @@ impl<'gc> Library<'gc> {
is_bold,
is_italic,
data,
index,
} => {
let descriptor = FontDescriptor::from_parts(&name, is_bold, is_italic);
if let Ok(font) = Font::from_font_file(gc_context, descriptor, Cow::Owned(data), 0)
if let Ok(font) =
Font::from_font_file(gc_context, descriptor, Cow::Owned(data), index)
{
let name = font.descriptor().name().to_owned();
info!("Loaded new device font \"{name}\" from file");

View File

@ -288,6 +288,7 @@ impl UiBackend for DesktopUiBackend {
is_bold,
is_italic,
data: bytes,
index: face.index,
}),
Err(e) => error!("Couldn't read font file at {path:?}: {e}"),
},
@ -297,6 +298,7 @@ impl UiBackend for DesktopUiBackend {
is_bold,
is_italic,
data: bin.as_ref().as_ref().to_vec(),
index: face.index,
})
}
};

View File

@ -142,6 +142,7 @@ impl UiBackend for TestUiBackend {
is_bold,
is_italic,
data: font.bytes.clone(),
index: 0,
});
break;
}