1use std::sync::Arc;
2
3use reflexo::hash::{item_hash128, Fingerprint};
4pub use reflexo::vector::ir::*;
5use ttf_parser::GlyphId;
6use typst::text::Font;
7
8#[derive(Debug, Clone, Hash, PartialEq, Eq)]
10pub enum GlyphItem {
11 None,
13
14 Raw(Font, GlyphId),
17
18 Image(Arc<ImageGlyphItem>),
20
21 Outline(Arc<OutlineGlyphItem>),
24}
25
26impl From<FlatGlyphItem> for GlyphItem {
27 fn from(item: FlatGlyphItem) -> Self {
28 match item {
29 FlatGlyphItem::Image(item) => GlyphItem::Image(item),
30 FlatGlyphItem::Outline(item) => GlyphItem::Outline(item),
31 FlatGlyphItem::None => GlyphItem::None,
32 }
33 }
34}
35
36impl GlyphItem {
37 #[comemo::memoize]
38 pub fn get_fingerprint(&self) -> Fingerprint {
39 Fingerprint::from_u128(item_hash128(self))
40 }
41}