mod error; mod recently_used; mod text_atlas; mod text_render; pub use error::{PrepareError, RenderError}; use recently_used::RecentlyUsedMap; pub use text_atlas::TextAtlas; use text_render::ContentType; pub use text_render::TextRenderer; pub use cosmic_text; use etagere::AllocId; pub(crate) enum GpuCacheStatus { InAtlas { x: u16, y: u16, content_type: ContentType, }, SkipRasterization, } pub(crate) struct GlyphDetails { width: u16, height: u16, gpu_cache: GpuCacheStatus, atlas_id: Option, top: i16, left: i16, } #[repr(C)] #[derive(Clone, Copy, Debug)] pub(crate) struct GlyphToRender { pos: [i32; 2], dim: [u16; 2], uv: [u16; 2], color: u32, content_type: u32, } /// The screen resolution to use when rendering text. #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct Resolution { /// The width of the screen in pixels. pub width: u32, /// The height of the screen in pixels. pub height: u32, } #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) struct Params { screen_resolution: Resolution, _pad: [u32; 2], } /// Controls the visible area of the text. Any text outside of the visible area will be clipped. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct TextBounds { /// The position of the left edge of the visible area. pub left: i32, /// The position of the top edge of the visible area. pub top: i32, /// The position of the right edge of the visible area. pub right: i32, /// The position of the bottom edge of the visible area. pub bottom: i32, } /// The default visible area doesn't clip any text. impl Default for TextBounds { fn default() -> Self { Self { left: i32::MIN, top: i32::MIN, right: i32::MAX, bottom: i32::MAX, } } } /// A text area containing text to be rendered along with its overflow behavior. pub struct TextArea<'a> { /// The buffer containing the text to be rendered. pub buffer: &'a cosmic_text::Buffer<'a>, /// The left edge of the buffer. pub left: i32, /// The top edge of the buffer. pub top: i32, /// The visible bounds of the text area. This is used to clip the text and doesn't have to /// match the `left` and `top` values. pub bounds: TextBounds, }