use std::path::Path;
use crate::types::options::TextOptions;
use crate::primitives::shaped_buffer::ShapedBuffer;
pub trait FontProvider: Send + Sync {
fn shape(&mut self, text: &str, options: &TextOptions) -> ShapedBuffer;
fn load_font(&mut self, data: Vec<u8>);
fn load_font_path(&mut self, path: &Path) -> std::io::Result<()>;
fn metrics(&self, options: &TextOptions) -> FontMetrics;
fn set_layout_size(&mut self, width: f32, height: f32);
fn font_system(&self) -> std::sync::Arc<std::sync::Mutex<cosmic_text::FontSystem>>;
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FontMetrics {
pub ascent: f32,
pub descent: f32,
pub line_gap: f32,
}
impl FontMetrics {
pub fn line_height(&self) -> f32 {
self.ascent - self.descent + self.line_gap
}
}