summaryrefslogtreecommitdiffstats
path: root/graphics/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-04 21:25:59 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-04 21:26:47 +0200
commitf98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7 (patch)
tree8fb3e8b470bff711e0ca2f1bf120ab6c66ba9a9d /graphics/src/text.rs
parent8d826cc662554b337282e7c982383f5db428d7aa (diff)
downloadiced-f98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7.tar.gz
iced-f98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7.tar.bz2
iced-f98328f4f1ee58b6288e4f19d7475e7eeb9a7ba7.zip
Add `text::Wrapping` support
Co-authored-by: Neeraj Jaiswal <neerajj85@gmail.com>
Diffstat (limited to '')
-rw-r--r--graphics/src/text.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/graphics/src/text.rs b/graphics/src/text.rs
index 23ec14d4..feb9932a 100644
--- a/graphics/src/text.rs
+++ b/graphics/src/text.rs
@@ -11,7 +11,7 @@ pub use cosmic_text;
use crate::core::alignment;
use crate::core::font::{self, Font};
-use crate::core::text::Shaping;
+use crate::core::text::{Shaping, Wrapping};
use crate::core::{Color, Pixels, Point, Rectangle, Size, Transformation};
use once_cell::sync::OnceCell;
@@ -306,6 +306,16 @@ pub fn to_shaping(shaping: Shaping) -> cosmic_text::Shaping {
}
}
+/// Converts some [`Wrapping`] strategy to a [`cosmic_text::Wrap`] strategy.
+pub fn to_wrap(wrapping: Wrapping) -> cosmic_text::Wrap {
+ match wrapping {
+ Wrapping::None => cosmic_text::Wrap::None,
+ Wrapping::Word => cosmic_text::Wrap::Word,
+ Wrapping::Glyph => cosmic_text::Wrap::Glyph,
+ Wrapping::WordOrGlyph => cosmic_text::Wrap::WordOrGlyph,
+ }
+}
+
/// Converts some [`Color`] to a [`cosmic_text::Color`].
pub fn to_color(color: Color) -> cosmic_text::Color {
let [r, g, b, a] = color.into_rgba8();