Text, many performance improvements
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! Renderer-oriented scene snapshot types.
|
||||
|
||||
use cosmic_text::CacheKey;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::trace_targets;
|
||||
@@ -92,12 +93,16 @@ pub struct GlyphInstance {
|
||||
pub glyph: String,
|
||||
pub position: Point,
|
||||
pub advance: f32,
|
||||
pub cache_key: Option<CacheKey>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PreparedText {
|
||||
pub text: String,
|
||||
pub origin: Point,
|
||||
pub bounds: Option<UiSize>,
|
||||
pub font_size: f32,
|
||||
pub line_height: f32,
|
||||
pub color: Color,
|
||||
pub glyphs: Vec<GlyphInstance>,
|
||||
}
|
||||
@@ -118,13 +123,17 @@ impl PreparedText {
|
||||
glyph: ch.to_string(),
|
||||
position: Point::new(x, origin.y),
|
||||
advance,
|
||||
cache_key: None,
|
||||
});
|
||||
x += advance;
|
||||
}
|
||||
|
||||
Self {
|
||||
text,
|
||||
origin,
|
||||
bounds: None,
|
||||
font_size,
|
||||
line_height: font_size,
|
||||
color,
|
||||
glyphs,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user