Add text::Wrapping support

Co-authored-by: Neeraj Jaiswal <neerajj85@gmail.com>
This commit is contained in:
Héctor Ramón Jiménez 2024-09-04 21:25:59 +02:00
parent 8d826cc662
commit f98328f4f1
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
21 changed files with 160 additions and 30 deletions

View file

@ -41,6 +41,9 @@ pub struct Text<Content = String, Font = crate::Font> {
/// The [`Shaping`] strategy of the [`Text`].
pub shaping: Shaping,
/// The [`Wrapping`] strategy of the [`Text`].
pub wrapping: Wrapping,
}
/// The shaping strategy of some text.
@ -67,6 +70,22 @@ pub enum Shaping {
Advanced,
}
/// The wrapping strategy of some text.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Wrapping {
/// No wrapping.
None,
/// Wraps at the word level.
///
/// This is the default.
#[default]
Word,
/// Wraps at the glyph level.
Glyph,
/// Wraps at the word level, or fallback to glyph level if a word can't fit on a line by itself.
WordOrGlyph,
}
/// The height of a line of text in a paragraph.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum LineHeight {