Support max_width and text::Alignment for canvas::Text
This commit is contained in:
parent
6ebf386249
commit
97b4ed0d84
13 changed files with 139 additions and 127 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue