Support max_width and text::Alignment for canvas::Text

This commit is contained in:
Héctor Ramón Jiménez 2025-04-30 04:19:15 +02:00
parent 6ebf386249
commit 97b4ed0d84
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 139 additions and 127 deletions

View file

@ -58,15 +58,7 @@ impl Cache {
text::to_shaping(key.shaping),
);
let (bounds, has_rtl) = text::measure(&buffer);
if has_rtl {
buffer.set_size(
font_system,
Some(bounds.width),
Some(bounds.height),
);
}
let bounds = text::align(&mut buffer, font_system, key.align_x);
let _ = entry.insert(Entry {
buffer,
@ -123,6 +115,8 @@ pub struct Key<'a> {
pub bounds: Size,
/// The shaping strategy of the text.
pub shaping: text::Shaping,
/// The alignment of the text.
pub align_x: text::Alignment,
}
impl Key<'_> {
@ -134,6 +128,7 @@ impl Key<'_> {
self.bounds.width.to_bits().hash(&mut hasher);
self.bounds.height.to_bits().hash(&mut hasher);
self.shaping.hash(&mut hasher);
self.align_x.hash(&mut hasher);
hasher.finish()
}