Export Shaping and LineHeight in widget::text

This commit is contained in:
Héctor Ramón Jiménez 2023-05-08 15:37:29 +02:00
parent b8c2cca384
commit 16bf8fc762
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
2 changed files with 11 additions and 13 deletions

View file

@ -10,6 +10,8 @@ use crate::{
use std::borrow::Cow; use std::borrow::Cow;
pub use text::{LineHeight, Shaping};
/// A paragraph of text. /// A paragraph of text.
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct Text<'a, Renderer> pub struct Text<'a, Renderer>
@ -19,13 +21,13 @@ where
{ {
content: Cow<'a, str>, content: Cow<'a, str>,
size: Option<f32>, size: Option<f32>,
line_height: text::LineHeight, line_height: LineHeight,
width: Length, width: Length,
height: Length, height: Length,
horizontal_alignment: alignment::Horizontal, horizontal_alignment: alignment::Horizontal,
vertical_alignment: alignment::Vertical, vertical_alignment: alignment::Vertical,
font: Option<Renderer::Font>, font: Option<Renderer::Font>,
shaping: text::Shaping, shaping: Shaping,
style: <Renderer::Theme as StyleSheet>::Style, style: <Renderer::Theme as StyleSheet>::Style,
} }
@ -39,13 +41,13 @@ where
Text { Text {
content: content.into(), content: content.into(),
size: None, size: None,
line_height: text::LineHeight::default(), line_height: LineHeight::default(),
font: None, font: None,
width: Length::Shrink, width: Length::Shrink,
height: Length::Shrink, height: Length::Shrink,
horizontal_alignment: alignment::Horizontal::Left, horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top, vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Basic, shaping: Shaping::Basic,
style: Default::default(), style: Default::default(),
} }
} }
@ -57,10 +59,7 @@ where
} }
/// Sets the [`LineHeight`] of the [`Text`]. /// Sets the [`LineHeight`] of the [`Text`].
pub fn line_height( pub fn line_height(mut self, line_height: impl Into<LineHeight>) -> Self {
mut self,
line_height: impl Into<text::LineHeight>,
) -> Self {
self.line_height = line_height.into(); self.line_height = line_height.into();
self self
} }
@ -112,8 +111,8 @@ where
self self
} }
/// Sets the [`text::Shaping`] strategy of the [`Text`]. /// Sets the [`Shaping`] strategy of the [`Text`].
pub fn shaping(mut self, shaping: text::Shaping) -> Self { pub fn shaping(mut self, shaping: Shaping) -> Self {
self.shaping = shaping; self.shaping = shaping;
self self
} }
@ -199,12 +198,12 @@ pub fn draw<Renderer>(
layout: Layout<'_>, layout: Layout<'_>,
content: &str, content: &str,
size: Option<f32>, size: Option<f32>,
line_height: text::LineHeight, line_height: LineHeight,
font: Option<Renderer::Font>, font: Option<Renderer::Font>,
appearance: Appearance, appearance: Appearance,
horizontal_alignment: alignment::Horizontal, horizontal_alignment: alignment::Horizontal,
vertical_alignment: alignment::Vertical, vertical_alignment: alignment::Vertical,
shaping: text::Shaping, shaping: Shaping,
) where ) where
Renderer: text::Renderer, Renderer: text::Renderer,
{ {

View file

@ -1,4 +1,3 @@
pub use crate::core::text::Shaping;
pub use crate::core::widget::text::*; pub use crate::core::widget::text::*;
pub type Text<'a, Renderer = crate::Renderer> = pub type Text<'a, Renderer = crate::Renderer> =