use super::buffer::MARK_ATTACH;
use crate::text::cluster::{ClusterInfo, SourceRange, UserData};
use crate::GlyphId;
#[derive(Copy, Clone, Default, Debug)]
pub struct GlyphInfo(pub u16);
impl GlyphInfo {
pub fn is_mark(self) -> bool {
self.0 & MARK_ATTACH != 0
}
}
#[derive(Copy, Clone, Default, Debug)]
pub struct Glyph {
pub id: GlyphId,
pub info: GlyphInfo,
pub x: f32,
pub y: f32,
pub advance: f32,
pub data: UserData,
}
#[derive(Copy, Clone, Debug)]
pub struct GlyphCluster<'a> {
pub source: SourceRange,
pub info: ClusterInfo,
pub glyphs: &'a [Glyph],
pub components: &'a [SourceRange],
pub data: UserData,
}
impl<'a> GlyphCluster<'a> {
pub fn is_empty(&self) -> bool {
self.glyphs.is_empty()
}
pub fn is_simple(&self) -> bool {
self.glyphs.len() == 1
}
pub fn is_ligature(&self) -> bool {
!self.components.is_empty()
}
pub fn is_complex(&self) -> bool {
self.glyphs.len() > 1
}
pub fn advance(&self) -> f32 {
let mut advance = 0.;
for g in self.glyphs {
advance += g.advance;
}
advance
}
}