Trait speedy2d::font::TextLayout

source ·
pub trait TextLayout {
    // Required methods
    fn lookup_glyph_for_codepoint(&self, codepoint: char) -> Option<FontGlyph>;
    fn empty_line_vertical_metrics(&self, scale: f32) -> LineVerticalMetrics;

    // Provided methods
    fn layout_text(
        &self,
        text: &str,
        scale: f32,
        options: TextOptions
    ) -> FormattedTextBlock { ... }
    fn layout_text_from_unindexed_codepoints(
        &self,
        unindexed_codepoints: &[char],
        scale: f32,
        options: TextOptions
    ) -> FormattedTextBlock { ... }
    fn layout_text_from_codepoints(
        &self,
        codepoints: &[Codepoint],
        scale: f32,
        options: TextOptions
    ) -> FormattedTextBlock { ... }
}
Expand description

Objects implementing this trait are able to lay out text, ready for rendering.

Required Methods§

source

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.

source

fn empty_line_vertical_metrics(&self, scale: f32) -> LineVerticalMetrics

The default metrics of a line which contains no characters.

Provided Methods§

source

fn layout_text( &self, text: &str, scale: f32, options: TextOptions ) -> FormattedTextBlock

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().

source

fn layout_text_from_unindexed_codepoints( &self, unindexed_codepoints: &[char], scale: f32, options: TextOptions ) -> FormattedTextBlock

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.

source

fn layout_text_from_codepoints( &self, codepoints: &[Codepoint], scale: f32, options: TextOptions ) -> FormattedTextBlock

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.

Implementors§