2022-10-06 12:13:43 -04:00
|
|
|
mod error;
|
|
|
|
|
mod text_atlas;
|
|
|
|
|
mod text_render;
|
2022-05-09 10:19:10 -02:30
|
|
|
|
2022-10-06 12:13:43 -04:00
|
|
|
pub use error::{PrepareError, RenderError};
|
|
|
|
|
pub use text_atlas::TextAtlas;
|
2022-11-28 07:18:45 -03:30
|
|
|
use text_render::ContentType;
|
2022-10-06 12:13:43 -04:00
|
|
|
pub use text_render::TextRenderer;
|
2022-05-16 09:23:13 -02:30
|
|
|
|
2023-01-29 22:04:01 -03:30
|
|
|
// Re-export all top-level types from `cosmic-text` for convenience.
|
|
|
|
|
pub use cosmic_text::{
|
|
|
|
|
self, fontdb, Action, Affinity, Attrs, AttrsList, AttrsOwned, Buffer, BufferLine, CacheKey,
|
|
|
|
|
Color, Command, Cursor, Edit, Editor, Family, FamilyOwned, Font, FontMatches, FontSystem,
|
|
|
|
|
LayoutCursor, LayoutGlyph, LayoutLine, LayoutRun, LayoutRunIter, Metrics, ShapeGlyph,
|
|
|
|
|
ShapeLine, ShapeSpan, ShapeWord, Stretch, Style, SubpixelBin, SwashCache, SwashContent,
|
|
|
|
|
SwashImage, Weight, Wrap,
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-26 00:07:05 -03:30
|
|
|
use etagere::AllocId;
|
2022-10-25 01:11:57 -02:30
|
|
|
|
2022-11-28 07:18:45 -03:30
|
|
|
pub(crate) enum GpuCacheStatus {
|
|
|
|
|
InAtlas {
|
|
|
|
|
x: u16,
|
|
|
|
|
y: u16,
|
|
|
|
|
content_type: ContentType,
|
|
|
|
|
},
|
2022-05-09 10:19:10 -02:30
|
|
|
SkipRasterization,
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 12:13:43 -04:00
|
|
|
pub(crate) struct GlyphDetails {
|
2022-05-09 11:52:38 -02:30
|
|
|
width: u16,
|
|
|
|
|
height: u16,
|
2022-11-28 07:18:45 -03:30
|
|
|
gpu_cache: GpuCacheStatus,
|
2022-05-09 10:19:10 -02:30
|
|
|
atlas_id: Option<AllocId>,
|
2022-10-25 22:38:12 -02:30
|
|
|
top: i16,
|
|
|
|
|
left: i16,
|
2022-05-09 10:19:10 -02:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
2022-10-06 12:13:43 -04:00
|
|
|
pub(crate) struct GlyphToRender {
|
2022-11-29 14:33:12 -03:30
|
|
|
pos: [i32; 2],
|
2022-05-09 11:52:38 -02:30
|
|
|
dim: [u16; 2],
|
|
|
|
|
uv: [u16; 2],
|
2022-10-28 01:24:45 -02:30
|
|
|
color: u32,
|
2022-11-28 07:18:45 -03:30
|
|
|
content_type: u32,
|
2023-02-14 14:44:09 -03:30
|
|
|
depth: f32,
|
2022-05-09 10:19:10 -02:30
|
|
|
}
|
|
|
|
|
|
2022-10-18 13:17:35 -02:30
|
|
|
/// The screen resolution to use when rendering text.
|
2022-05-09 10:19:10 -02:30
|
|
|
#[repr(C)]
|
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
|
|
|
pub struct Resolution {
|
2022-10-18 13:17:35 -02:30
|
|
|
/// The width of the screen in pixels.
|
2022-05-09 10:19:10 -02:30
|
|
|
pub width: u32,
|
2022-10-18 13:17:35 -02:30
|
|
|
/// The height of the screen in pixels.
|
2022-05-09 10:19:10 -02:30
|
|
|
pub height: u32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
2022-10-18 13:17:35 -02:30
|
|
|
pub(crate) struct Params {
|
2022-05-09 10:19:10 -02:30
|
|
|
screen_resolution: Resolution,
|
2022-06-06 15:09:14 -02:30
|
|
|
_pad: [u32; 2],
|
2022-05-09 10:19:10 -02:30
|
|
|
}
|
|
|
|
|
|
2023-01-26 00:07:05 -03:30
|
|
|
/// 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.
|
2023-01-29 21:29:20 -03:30
|
|
|
pub struct TextArea<'a, 'b: 'a> {
|
2023-01-26 00:07:05 -03:30
|
|
|
/// The buffer containing the text to be rendered.
|
2023-01-29 22:04:01 -03:30
|
|
|
pub buffer: &'a Buffer<'b>,
|
2023-01-26 00:44:29 -03:30
|
|
|
/// 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.
|
2023-01-26 00:07:05 -03:30
|
|
|
pub bounds: TextBounds,
|
2022-09-13 16:35:20 -02:30
|
|
|
}
|