#![allow(unused, dead_code)]
pub mod atlas;
pub mod emoji;
pub mod font;
pub mod layout;
pub mod rasterizer;
pub mod registry;
pub mod renderer;
pub mod shaper;
use std::sync::{Arc, Mutex, OnceLock};
pub use atlas::{AtlasRegion, ColorGlyphAtlas, GlyphAtlas, GlyphInfo};
pub use emoji::{contains_emoji, is_emoji, EmojiRenderer, EmojiSprite};
pub use font::{Font, FontFace, FontMetrics, FontStyle, FontWeight};
static GLOBAL_FONT_REGISTRY: OnceLock<Arc<Mutex<registry::FontRegistry>>> = OnceLock::new();
pub fn global_font_registry() -> Arc<Mutex<registry::FontRegistry>> {
Arc::clone(
GLOBAL_FONT_REGISTRY.get_or_init(|| Arc::new(Mutex::new(registry::FontRegistry::new()))),
)
}
pub use html_escape::decode_html_entities;
pub use layout::{
LayoutOptions, LineBreakMode, PositionedGlyph, TextAlignment, TextAnchor, TextLayout,
TextLayoutEngine,
};
pub use rasterizer::{GlyphFormat, GlyphRasterizer, RasterizedGlyph};
pub use registry::{FontRegistry, GenericFont};
pub use renderer::{ColorSpan, GlyphInstance, PreparedText, TextRenderer};
pub use shaper::{ShapedGlyph, ShapedText, TextShaper};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum TextError {
#[error("Failed to load font: {0}")]
FontLoadError(String),
#[error("Failed to parse font: {0}")]
FontParseError(String),
#[error("Glyph not found for codepoint: {0}")]
GlyphNotFound(char),
#[error("Atlas is full, cannot allocate glyph")]
AtlasFull,
#[error("Invalid font data")]
InvalidFontData,
}
pub type Result<T> = std::result::Result<T, TextError>;