diff --git a/examples/text/src/font/mod.rs b/examples/text/src/font/mod.rs index 846a0001..c8dfaeae 100644 --- a/examples/text/src/font/mod.rs +++ b/examples/text/src/font/mod.rs @@ -38,7 +38,9 @@ impl FontLineIndex { } pub struct Font<'a> { - data: &'a [u8], + pub name: &'a str, + pub data: &'a [u8], + pub index: u32, pub rustybuzz: rustybuzz::Face<'a>, #[cfg(feature = "ab_glyph")] pub ab_glyph: ab_glyph::FontRef<'a>, @@ -52,9 +54,11 @@ pub struct Font<'a> { } impl<'a> Font<'a> { - pub fn new(data: &'a [u8], index: u32) -> Option { + pub fn new(name: &'a str, data: &'a [u8], index: u32) -> Option { Some(Self { + name, data, + index, rustybuzz: rustybuzz::Face::from_slice(data, index)?, #[cfg(feature = "ab_glyph")] ab_glyph: ab_glyph::FontRef::try_from_slice_and_index(data, index).ok()?, diff --git a/examples/text/src/font/system.rs b/examples/text/src/font/system.rs index 2d88c014..98044e47 100644 --- a/examples/text/src/font/system.rs +++ b/examples/text/src/font/system.rs @@ -43,6 +43,7 @@ impl FontSystem { } let font_opt = Font::new( + &face.post_script_name, match &face.source { fontdb::Source::Binary(data) => { data.deref().as_ref() diff --git a/examples/text/src/main.rs b/examples/text/src/main.rs index e6993ab9..db7b5eaf 100644 --- a/examples/text/src/main.rs +++ b/examples/text/src/main.rs @@ -201,7 +201,13 @@ fn main() { ); let text_line = &buffer.text_lines()[line.line_i.get()]; - eprintln!("{}, {}: '{}'", glyph.start, glyph.end, &text_line[glyph.start..glyph.end]); + eprintln!( + "{}, {}: '{}': '{}'", + glyph.start, + glyph.end, + glyph.font.name, + &text_line[glyph.start..glyph.end], + ); } }