pub struct TextLayout;Implementations§
Source§impl TextLayout
impl TextLayout
pub fn new() -> Self
Sourcepub fn break_into_lines(
&self,
font_context: &FontContext,
text: &str,
max_width: f64,
font_size: f64,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
letter_spacing: f64,
hyphens: Hyphens,
lang: Option<&str>,
) -> Vec<BrokenLine>
pub fn break_into_lines( &self, font_context: &FontContext, text: &str, max_width: f64, font_size: f64, font_family: &str, font_weight: u32, font_style: FontStyle, letter_spacing: f64, hyphens: Hyphens, lang: Option<&str>, ) -> Vec<BrokenLine>
Break a string into lines that fit within max_width.
Uses a greedy line-breaking algorithm with optional hyphenation.
When hyphens is Auto, long words that don’t fit are split at
syllable boundaries using the Knuth-Liang algorithm. When Manual,
only soft hyphens (U+00AD) in the text are used as break points.
Sourcepub fn shape_text(
&self,
font_context: &FontContext,
text: &str,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
) -> Option<Vec<ShapedGlyph>>
pub fn shape_text( &self, font_context: &FontContext, text: &str, font_family: &str, font_weight: u32, font_style: FontStyle, ) -> Option<Vec<ShapedGlyph>>
Shape text and return shaped glyphs for a custom font.
Returns None for standard fonts or if shaping fails.
Sourcepub fn break_runs_into_lines(
&self,
font_context: &FontContext,
chars: &[StyledChar],
max_width: f64,
hyphens: Hyphens,
lang: Option<&str>,
) -> Vec<RunBrokenLine>
pub fn break_runs_into_lines( &self, font_context: &FontContext, chars: &[StyledChar], max_width: f64, hyphens: Hyphens, lang: Option<&str>, ) -> Vec<RunBrokenLine>
Break multi-style text (runs) into lines that fit within max_width.
Sourcepub fn measure_widest_word(
&self,
font_context: &FontContext,
text: &str,
font_size: f64,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
letter_spacing: f64,
hyphens: Hyphens,
lang: Option<&str>,
) -> f64
pub fn measure_widest_word( &self, font_context: &FontContext, text: &str, font_size: f64, font_family: &str, font_weight: u32, font_style: FontStyle, letter_spacing: f64, hyphens: Hyphens, lang: Option<&str>, ) -> f64
Measure the widest single word in a string (min-content width).
When hyphens is Auto, returns the widest syllable width instead
of the widest word, since hyphenation allows breaking within words.
Sourcepub fn measure_width(
&self,
font_context: &FontContext,
text: &str,
font_size: f64,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
letter_spacing: f64,
) -> f64
pub fn measure_width( &self, font_context: &FontContext, text: &str, font_size: f64, font_family: &str, font_weight: u32, font_style: FontStyle, letter_spacing: f64, ) -> f64
Measure the width of a string on a single line.
Sourcepub fn break_into_lines_optimal(
&self,
font_context: &FontContext,
text: &str,
max_width: f64,
font_size: f64,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
letter_spacing: f64,
hyphens: Hyphens,
lang: Option<&str>,
justify: bool,
) -> Vec<BrokenLine>
pub fn break_into_lines_optimal( &self, font_context: &FontContext, text: &str, max_width: f64, font_size: f64, font_family: &str, font_weight: u32, font_style: FontStyle, letter_spacing: f64, hyphens: Hyphens, lang: Option<&str>, justify: bool, ) -> Vec<BrokenLine>
Break text into lines using the Knuth-Plass optimal algorithm.
Falls back to greedy breaking if KP finds no feasible solution.
Sourcepub fn break_runs_into_lines_optimal(
&self,
font_context: &FontContext,
chars: &[StyledChar],
max_width: f64,
hyphens: Hyphens,
lang: Option<&str>,
justify: bool,
) -> Vec<RunBrokenLine>
pub fn break_runs_into_lines_optimal( &self, font_context: &FontContext, chars: &[StyledChar], max_width: f64, hyphens: Hyphens, lang: Option<&str>, justify: bool, ) -> Vec<RunBrokenLine>
Break multi-style text into lines using the Knuth-Plass optimal algorithm.
Falls back to greedy breaking if KP finds no feasible solution.
Sourcepub fn truncate_with_ellipsis(
&self,
font_context: &FontContext,
lines: Vec<BrokenLine>,
max_width: f64,
font_size: f64,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
letter_spacing: f64,
) -> Vec<BrokenLine>
pub fn truncate_with_ellipsis( &self, font_context: &FontContext, lines: Vec<BrokenLine>, max_width: f64, font_size: f64, font_family: &str, font_weight: u32, font_style: FontStyle, letter_spacing: f64, ) -> Vec<BrokenLine>
Truncate lines to a single line with ellipsis appended if it exceeds max_width.
Sourcepub fn truncate_clip(
&self,
font_context: &FontContext,
lines: Vec<BrokenLine>,
max_width: f64,
font_size: f64,
font_family: &str,
font_weight: u32,
font_style: FontStyle,
letter_spacing: f64,
) -> Vec<BrokenLine>
pub fn truncate_clip( &self, font_context: &FontContext, lines: Vec<BrokenLine>, max_width: f64, font_size: f64, font_family: &str, font_weight: u32, font_style: FontStyle, letter_spacing: f64, ) -> Vec<BrokenLine>
Truncate lines to a single line by clipping (no indicator appended).
Sourcepub fn truncate_runs_with_ellipsis(
&self,
font_context: &FontContext,
lines: Vec<RunBrokenLine>,
max_width: f64,
) -> Vec<RunBrokenLine>
pub fn truncate_runs_with_ellipsis( &self, font_context: &FontContext, lines: Vec<RunBrokenLine>, max_width: f64, ) -> Vec<RunBrokenLine>
Truncate multi-style run lines to a single line with ellipsis.
Sourcepub fn truncate_runs_clip(
&self,
font_context: &FontContext,
lines: Vec<RunBrokenLine>,
max_width: f64,
) -> Vec<RunBrokenLine>
pub fn truncate_runs_clip( &self, font_context: &FontContext, lines: Vec<RunBrokenLine>, max_width: f64, ) -> Vec<RunBrokenLine>
Truncate multi-style run lines to a single line by clipping.