glyphon/src/lib.rs

63 lines
1.3 KiB
Rust
Raw Normal View History

2022-10-06 12:13:43 -04:00
use etagere::AllocId;
2022-05-09 10:19:10 -02:30
2022-10-06 12:13:43 -04:00
mod error;
mod recently_used;
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};
use recently_used::RecentlyUsedMap;
pub use text_atlas::TextAtlas;
pub use text_render::TextRenderer;
2022-05-16 09:23:13 -02:30
2022-10-25 01:11:57 -02:30
pub use cosmic_text;
2022-10-06 12:13:43 -04:00
pub(crate) enum GpuCache {
2022-05-09 10:19:10 -02:30
InAtlas { x: u16, y: u16 },
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-05-09 10:19:10 -02:30
gpu_cache: GpuCache,
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 {
pos: [i32; 2],
2022-05-09 11:52:38 -02:30
dim: [u16; 2],
uv: [u16; 2],
color: u32,
2022-05-09 10:19:10 -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 {
/// The width of the screen in pixels.
2022-05-09 10:19:10 -02:30
pub width: u32,
/// 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)]
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
}
/// Controls the overflow behavior of any glyphs that are outside of the layout bounds.
pub enum TextOverflow {
/// Glyphs can overflow the bounds.
Overflow,
/// Hide any glyphs outside the bounds. If a glyph is partially outside the bounds, it will be
/// clipped to the bounds.
Hide,
}