Trait speedy2d::font::TextLayout [−][src]
pub trait TextLayout { fn lookup_glyph_for_codepoint(&self, codepoint: char) -> Option<FontGlyph>; fn layout_text(
&self,
text: &str,
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock>
where
Self: Sized, { ... } fn layout_text_from_unindexed_codepoints(
&self,
unindexed_codepoints: &[char],
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock>
where
Self: Sized, { ... } fn layout_text_from_codepoints(
&self,
codepoints: &[Codepoint],
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock>
where
Self: Sized, { ... } }
Expand description
Objects implementing this trait are able to lay out text, ready for rendering.
Required methods
fn lookup_glyph_for_codepoint(&self, codepoint: char) -> Option<FontGlyph>
fn lookup_glyph_for_codepoint(&self, codepoint: char) -> Option<FontGlyph>
Returns the glyph corresponding to the provided codepoint. If the glyph
cannot be found, None
is returned.
Provided methods
fn layout_text(
&self,
text: &str,
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock> where
Self: Sized,
fn layout_text(
&self,
text: &str,
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock> where
Self: Sized,
Lays out a block of text with the specified scale and options. The
result may be passed to Graphics2D::draw_text
.
As the string undergoes normalization before being laid out, the
user_index
of each FormattedGlyph
is undefined. To gain control
over the user_index
field, consider using
either layout_text_line_from_codepoints()
or
layout_text_line_from_unindexed_codepoints()
.
fn layout_text_from_unindexed_codepoints(
&self,
unindexed_codepoints: &[char],
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock> where
Self: Sized,
fn layout_text_from_unindexed_codepoints(
&self,
unindexed_codepoints: &[char],
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock> where
Self: Sized,
Lays out a block of text with the specified scale and options. The
result may be passed to Graphics2D::draw_text
.
The user_index
field of each FormattedGlyph
will be set to the
location of the input codepoint in unindexed_codepoints
, starting
from zero.
fn layout_text_from_codepoints(
&self,
codepoints: &[Codepoint],
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock> where
Self: Sized,
fn layout_text_from_codepoints(
&self,
codepoints: &[Codepoint],
scale: f32,
options: TextOptions
) -> Rc<FormattedTextBlock> where
Self: Sized,
Lays out a block of text with the specified scale and options. The
result may be passed to Graphics2D::draw_text
.
The user_index
field of each FormattedGlyph
will be set to the
user_index
of the corresponding Codepoint
.