glyphon/src/lib.rs

69 lines
1.3 KiB
Rust
Raw Normal View History

2022-10-06 12:13:43 -04:00
use etagere::AllocId;
2022-05-09 08:49:10 -04:00
2022-10-06 12:13:43 -04:00
mod error;
mod recently_used;
mod text_atlas;
mod text_render;
2022-05-09 08:49:10 -04:00
2022-10-06 12:13:43 -04:00
pub use error::{PrepareError, RenderError};
2022-05-09 10:22:38 -04:00
pub use fontdue;
2022-10-06 12:13:43 -04:00
use recently_used::RecentlyUsedMap;
pub use text_atlas::TextAtlas;
pub use text_render::TextRenderer;
2022-05-16 07:53:13 -04:00
#[repr(C)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
pub trait HasColor: Copy {
fn color(&self) -> Color;
2022-05-09 21:10:00 -04:00
}
2022-10-06 12:13:43 -04:00
pub(crate) enum GpuCache {
2022-05-09 08:49:10 -04:00
InAtlas { x: u16, y: u16 },
SkipRasterization,
}
2022-10-06 12:13:43 -04:00
pub(crate) struct GlyphDetails {
2022-05-09 10:22:38 -04:00
width: u16,
height: u16,
2022-05-09 08:49:10 -04:00
gpu_cache: GpuCache,
atlas_id: Option<AllocId>,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
2022-10-06 12:13:43 -04:00
pub(crate) struct GlyphToRender {
2022-05-09 10:22:38 -04:00
pos: [u32; 2],
dim: [u16; 2],
uv: [u16; 2],
2022-05-09 08:49:10 -04:00
color: [u8; 4],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Resolution {
pub width: u32,
pub height: u32,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Params {
screen_resolution: Resolution,
2022-06-06 13:39:14 -04:00
_pad: [u32; 2],
2022-05-09 08:49:10 -04:00
}
/// 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,
}