#[repr(C)]pub struct TextIns {
pub font_t1: Vec2,
pub font_t2: Vec2,
pub color: Vec4,
pub rect_pos: Vec2,
pub rect_size: Vec2,
pub char_depth: f32,
pub base: Vec2,
pub font_size: f32,
pub char_offset: f32,
pub marker: f32,
}
Fields
font_t1: Vec2
Texture coordinates for the bottom-left corner of the glyph in the texture atlas
font_t2: Vec2
Texture coordinates for the top-right corner of the glyph in the texture atlas
color: Vec4
Color for a glyph, usually set at the same color as TextIns
rect_pos: Vec2
Glyph position in view space
rect_size: Vec2
Glyph size in view space
char_depth: f32
Depth offset (prevents z-fighting)
base: Vec2
Position used in TextIns::closest_offset
.
font_size: f32
Font size in pixels
char_offset: f32
Character index in the text string
marker: f32
TODO(JP): document.
Implementations
pub fn generate_2d_glyphs<F>(
text_style: &TextStyle,
fonts_data: &RwLock<CxFontsData>,
dpi_factor: f32,
font_scale: f32,
draw_depth: f32,
color: Vec4,
pos: Vec2,
char_offset: usize,
chars: impl IntoIterator<Item = impl Borrow<char>>,
char_callback: F
) -> Vec<TextIns> where
F: FnMut(char, usize, f32, f32) -> f32,
pub fn generate_2d_glyphs<F>(
text_style: &TextStyle,
fonts_data: &RwLock<CxFontsData>,
dpi_factor: f32,
font_scale: f32,
draw_depth: f32,
color: Vec4,
pos: Vec2,
char_offset: usize,
chars: impl IntoIterator<Item = impl Borrow<char>>,
char_callback: F
) -> Vec<TextIns> where
F: FnMut(char, usize, f32, f32) -> f32,
TODO(JP): It’s hard to get text to render crisply; see
pub fn draw_glyphs_with_scroll_sticky(
cx: &mut Cx,
glyphs: &[TextIns],
text_style: &TextStyle,
horizontal: bool,
vertical: bool
) -> Area
Draw text using absolute positioning.
This does not use the layouting system in Zaplib.
Only single-line text is supported. This means that you can only use
Wrapping::None
and Wrapping::Ellipsis
for TextInsProps::wrapping
.
Draw text and walk in the layout system.
Calls cx.add_box
for each “chunk” of text (depending on TextInsProps::wrapping
).
TODO(JP): This doesn’t seem to work well with Direction::Down
(or other directions for
that matter). Not a high priority but might good to be aware of.
TextInsProps::position_anchoring
is ignored by this function.
Looks up text with the behavior of a text selection mouse cursor.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for TextIns
impl UnwindSafe for TextIns
Blanket Implementations
Mutably borrows from an owned value. Read more