Do not store reference to font in shape or layout glyphs

This commit is contained in:
Jeremy Soller 2022-10-25 10:13:44 -06:00
parent 3c573df261
commit 42de42d59e
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
5 changed files with 68 additions and 47 deletions

View file

@ -57,7 +57,6 @@ impl<'a> FontMatches<'a> {
missing.push(start_word + info.cluster as usize);
}
let inner = info.glyph_id as swash::GlyphId;
glyphs.push(FontShapeGlyph {
start: start_word + info.cluster as usize,
end: end_word, // Set later
@ -65,8 +64,8 @@ impl<'a> FontMatches<'a> {
y_advance,
x_offset,
y_offset,
font,
inner,
font_id: font.info.id,
glyph_id: info.glyph_id.try_into().unwrap(),
});
}
@ -325,4 +324,13 @@ impl<'a> FontMatches<'a> {
FontShapeLine { rtl, spans }
}
pub fn get_font(&self, id: &fontdb::ID) -> Option<&Font> {
for font in self.fonts.iter() {
if &font.info.id == id {
return Some(font);
}
}
None
}
}