1mod cache;
8mod error;
9mod text_atlas;
10mod text_render;
11mod viewport;
12
13pub use cache::Cache;
14pub use error::{PrepareError, RenderError};
15pub use text_atlas::{ColorMode, TextAtlas};
16pub use text_render::TextRenderer;
17pub use viewport::Viewport;
18
19use text_render::ContentType;
20
21#[doc(no_inline)]
23pub use cosmic_text::{
24 self, Action, Affinity, Attrs, AttrsList, AttrsOwned, Buffer, BufferLine, CacheKey, Color,
25 Command, Cursor, Edit, Editor, Family, FamilyOwned, Font, FontSystem, LayoutCursor,
26 LayoutGlyph, LayoutLine, LayoutRun, LayoutRunIter, Metrics, ShapeGlyph, ShapeLine, ShapeSpan,
27 ShapeWord, Shaping, Stretch, Style, SubpixelBin, SwashCache, SwashContent, SwashImage, Weight,
28 Wrap, fontdb,
29};
30
31use etagere::AllocId;
32
33pub(crate) enum GpuCacheStatus {
34 InAtlas {
35 x: u16,
36 y: u16,
37 content_type: ContentType,
38 },
39 SkipRasterization,
40}
41
42pub(crate) struct GlyphDetails {
43 width: u16,
44 height: u16,
45 gpu_cache: GpuCacheStatus,
46 atlas_id: Option<AllocId>,
47 top: i16,
48 left: i16,
49}
50
51#[repr(C)]
52#[derive(Clone, Copy, Debug)]
53pub(crate) struct GlyphToRender {
54 pos: [i32; 2],
55 dim: [u16; 2],
56 uv: [u16; 2],
57 color: u32,
58 content_type_with_srgb: [u16; 2],
59 depth: f32,
60}
61
62#[repr(C)]
64#[derive(Clone, Copy, Debug, Eq, PartialEq)]
65pub struct Resolution {
66 pub width: u32,
68 pub height: u32,
70}
71
72#[repr(C)]
73#[derive(Clone, Copy, Debug, Eq, PartialEq)]
74pub(crate) struct Params {
75 screen_resolution: Resolution,
76 _pad: [u32; 2],
77}
78
79#[derive(Clone, Copy, Debug, Eq, PartialEq)]
81pub struct TextBounds {
82 pub left: i32,
84 pub top: i32,
86 pub right: i32,
88 pub bottom: i32,
90}
91
92impl Default for TextBounds {
94 fn default() -> Self {
95 Self {
96 left: i32::MIN,
97 top: i32::MIN,
98 right: i32::MAX,
99 bottom: i32::MAX,
100 }
101 }
102}
103
104#[derive(Clone)]
106pub struct TextArea<'a> {
107 pub buffer: &'a Buffer,
109 pub left: f32,
111 pub top: f32,
113 pub scale: f32,
115 pub bounds: TextBounds,
118 pub default_color: Color,
120}