#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
pub enum Direction {
#[default]
Ltr,
Rtl,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
pub enum Affinity {
#[default]
Downstream,
Upstream,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RunSpan {
pub byte_range: std::ops::Range<usize>,
pub level: u8,
pub direction: Direction,
}
#[derive(Clone, Debug)]
pub struct ShapedLine {
pub glyphs: Vec<ShapedGlyph>,
pub width_lpx: f32,
pub ascent_lpx: f32,
pub descent_lpx: f32,
pub y_offset_lpx: f32,
pub base_direction: Direction,
pub runs: Vec<RunSpan>,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub enum TextAlignment {
#[default]
Left,
Center,
Right,
}
#[derive(Copy, Clone, Debug)]
pub struct ShapedGlyph {
pub glyph_id: u32,
pub font_id: FontId,
pub font_handle: crate::FontHandle,
pub x_advance_lpx: f32,
pub position_lpx: [f32; 2],
pub cluster: u32,
pub direction: Direction,
}
#[derive(Clone, Debug)]
pub struct GlyphBitmap {
pub width: u32,
pub height: u32,
pub bearing_x_lpx: f32,
pub bearing_y_lpx: f32,
pub advance_x_lpx: f32,
pub alpha: Vec<u8>,
}
#[derive(Copy, Clone, Debug)]
pub struct FontMetrics {
pub ascent_lpx: f32,
pub descent_lpx: f32,
pub line_gap_lpx: f32,
pub x_height_lpx: f32,
pub cap_height_lpx: f32,
pub units_per_em: u32,
}
#[derive(Copy, Clone, Debug)]
pub struct GlyphMetrics {
pub width: u32,
pub height: u32,
pub bearing_x_lpx: f32,
pub bearing_y_lpx: f32,
pub advance_x_lpx: f32,
}
#[derive(Copy, Clone, Debug)]
pub struct CachedGlyph {
pub alloc: slate_renderer::atlas::AtlasAllocation,
pub metrics: GlyphMetrics,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct GlyphBounds {
pub width: u32,
pub height: u32,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct FontId(pub u32);
impl FontId {
pub const PRIMARY: Self = Self(0);
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
pub enum FontStyle {
#[default]
Regular,
Italic,
Bold,
BoldItalic,
}
#[derive(Clone, Debug)]
pub struct FontDescriptor {
pub family: String,
pub postscript_name: String,
pub weight: u16,
pub style: FontStyle,
pub path: Option<std::path::PathBuf>,
}
impl GlyphBounds {
pub const ZERO: Self = Self {
width: 0,
height: 0,
};
#[inline]
pub fn is_whitespace(&self) -> bool {
self.width == 0 || self.height == 0
}
}