mod font_metrics;
mod font_select;
mod glyph_renderer;
mod shape;
pub use font_metrics::FontMetrics;
pub use font_select::find_font_for_text;
pub use glyph_renderer::GlyphRenderer;
pub use shape::{shape_text, shape_text_cached, shape_text_with_style};
#[cfg(feature = "nostd")]
use alloc::vec::Vec;
#[cfg(not(feature = "nostd"))]
use std::vec::Vec;
#[derive(Debug, Clone)]
pub struct ShapedGlyph {
pub glyph_id: u32,
pub x_position: f32,
pub y_position: f32,
pub x_offset: f32,
pub y_offset: f32,
pub x_advance: f32,
pub y_advance: f32,
pub cluster: u32,
}
#[derive(Debug, Clone)]
pub struct ShapedText {
pub glyphs: Vec<ShapedGlyph>,
pub width: f32,
pub height: f32,
pub baseline: f32,
pub font_size: f32,
pub ascent: f32,
pub descent: f32,
pub ink_min: f32,
pub ink_max: f32,
}
impl ShapedText {
pub fn total_advance(&self) -> Option<f32> {
if self.glyphs.is_empty() {
return Some(0.0);
}
let mut total = 0.0;
for glyph in &self.glyphs {
total += glyph.x_advance;
}
Some(total)
}
}