use crate::{ Bounds, DevicePixels, Font, FontId, FontMetrics, FontRun, GlyphId, LineLayout, Pixels, PlatformTextSystem, RenderGlyphParams, SharedString, Size, }; use anyhow::Result; use collections::HashMap; use font_kit::{ font::Font as FontKitFont, handle::Handle, hinting::HintingOptions, metrics::Metrics, properties::{Style as FontkitStyle, Weight as FontkitWeight}, source::SystemSource, sources::mem::MemSource, }; use parking_lot::RwLock; use smallvec::SmallVec; use std::borrow::Cow; pub(crate) struct LinuxTextSystem(RwLock); struct LinuxTextSystemState { memory_source: MemSource, system_source: SystemSource, fonts: Vec, font_selections: HashMap, font_ids_by_postscript_name: HashMap, font_ids_by_family_name: HashMap>, postscript_names_by_font_id: HashMap, } unsafe impl Send for LinuxTextSystemState {} unsafe impl Sync for LinuxTextSystemState {} impl LinuxTextSystem { pub(crate) fn new() -> Self { Self(RwLock::new(LinuxTextSystemState { memory_source: MemSource::empty(), system_source: SystemSource::new(), fonts: Vec::new(), font_selections: HashMap::default(), font_ids_by_postscript_name: HashMap::default(), font_ids_by_family_name: HashMap::default(), postscript_names_by_font_id: HashMap::default(), })) } } impl Default for LinuxTextSystem { fn default() -> Self { Self::new() } } #[allow(unused)] impl PlatformTextSystem for LinuxTextSystem { fn add_fonts(&self, fonts: Vec>) -> Result<()> { Ok(()) //TODO } fn all_font_names(&self) -> Vec { Vec::new() } fn all_font_families(&self) -> Vec { Vec::new() } fn font_id(&self, descriptor: &Font) -> Result { Ok(FontId(0)) //TODO } fn font_metrics(&self, font_id: FontId) -> FontMetrics { unimplemented!() } fn typographic_bounds(&self, font_id: FontId, glyph_id: GlyphId) -> Result> { unimplemented!() } fn advance(&self, font_id: FontId, glyph_id: GlyphId) -> Result> { unimplemented!() } fn glyph_for_char(&self, font_id: FontId, ch: char) -> Option { None } fn glyph_raster_bounds(&self, params: &RenderGlyphParams) -> Result> { unimplemented!() } fn rasterize_glyph( &self, params: &RenderGlyphParams, raster_bounds: Bounds, ) -> Result<(Size, Vec)> { unimplemented!() } fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout { LineLayout::default() //TODO } fn wrap_line( &self, text: &str, font_id: FontId, font_size: Pixels, width: Pixels, ) -> Vec { unimplemented!() } }