Add custom metadata to Attrs, copied to ShapeGlyph and LayoutGlyph

This commit is contained in:
Jeremy Soller 2022-12-14 09:19:03 -07:00
parent cdf36db03d
commit 8bf0032974
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
3 changed files with 19 additions and 8 deletions

View file

@ -101,6 +101,7 @@ pub struct Attrs<'a> {
pub stretch: Stretch,
pub style: Style,
pub weight: Weight,
pub metadata: usize,
}
impl<'a> Attrs<'a> {
@ -115,6 +116,7 @@ impl<'a> Attrs<'a> {
stretch: Stretch::Normal,
style: Style::Normal,
weight: Weight::NORMAL,
metadata: 0,
}
}
@ -154,6 +156,12 @@ impl<'a> Attrs<'a> {
self
}
/// Set metadata
pub fn metadata(mut self, metadata: usize) -> Self {
self.metadata = metadata;
self
}
/// Check if font matches
pub fn matches(&self, face: &fontdb::FaceInfo) -> bool {
//TODO: smarter way of including emoji
@ -185,6 +193,7 @@ pub struct AttrsOwned {
pub stretch: Stretch,
pub style: Style,
pub weight: Weight,
pub metadata: usize,
}
impl AttrsOwned {
@ -196,6 +205,7 @@ impl AttrsOwned {
stretch: attrs.stretch,
style: attrs.style,
weight: attrs.weight,
metadata: attrs.metadata,
}
}
@ -207,6 +217,7 @@ impl AttrsOwned {
stretch: self.stretch,
style: self.style,
weight: self.weight,
metadata: self.metadata,
}
}
}