Print font name when selecting character

This commit is contained in:
Jeremy Soller 2022-10-12 17:35:23 -06:00
parent 210622d084
commit a50294676d
3 changed files with 14 additions and 3 deletions

View file

@ -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<Self> {
pub fn new(name: &'a str, data: &'a [u8], index: u32) -> Option<Self> {
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()?,

View file

@ -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()

View file

@ -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],
);
}
}