1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extern crate azul_css;
extern crate azul_core;
extern crate unicode_normalization;
extern crate harfbuzz_sys;
extern crate freetype; // necessary to get baseline of font

pub mod text_layout;
pub mod text_shaping;

use azul_core::{
    traits::GetTextLayout,
    ui_solver::{ResolvedTextLayoutOptions, InlineTextLayout},
    app_resources::{Words, ScaledWords},
};

#[derive(Debug, Clone)]
pub struct InlineText<'a> {
    pub words: &'a Words,
    pub scaled_words: &'a ScaledWords,
}

impl<'a> GetTextLayout for InlineText<'a> {
    fn get_text_layout(&mut self, text_layout_options: &ResolvedTextLayoutOptions) -> InlineTextLayout {
        let layouted_text_block = text_layout::position_words(
            self.words,
            self.scaled_words,
            text_layout_options,
        );
        // TODO: Cache the layouted text block on the &mut self
        text_layout::word_positions_to_inline_text_layout(&layouted_text_block, &self.scaled_words)
    }
}