diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-02-03 10:37:50 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-02-03 10:37:50 +0100 |
| commit | 40ea35cbe7482ce04096c4d63a848c8601cc1848 (patch) | |
| tree | 080a5727ba552ee4b2bf750208e5c243c1e195ef /src/layout/text.rs | |
| parent | 20fb4e7c379b79b84d9884d5f2c89d781c5793e2 (diff) | |
Upgrade to new toddle interface 🐳
Diffstat (limited to 'src/layout/text.rs')
| -rw-r--r-- | src/layout/text.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/layout/text.rs b/src/layout/text.rs index a0f47643..6b512a07 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -4,17 +4,18 @@ //! When the primary layouting axis horizontally inversed, the word is spelled //! backwards. Vertical word layout is not yet supported. -use toddle::query::{SharedFontLoader, FontQuery, FontIndex}; +use toddle::query::{FontQuery, FontIndex}; use toddle::tables::{CharMap, Header, HorizontalMetrics}; +use crate::GlobalFontLoader; use crate::size::{Size, Size2D}; use crate::style::TextStyle; use super::*; /// Performs the text layouting. -struct TextLayouter<'a, 'p> { - ctx: TextContext<'a, 'p>, +struct TextLayouter<'a> { + ctx: TextContext<'a>, text: &'a str, actions: LayoutActions, buffer: String, @@ -24,10 +25,10 @@ struct TextLayouter<'a, 'p> { /// The context for text layouting. #[derive(Copy, Clone)] -pub struct TextContext<'a, 'p> { +pub struct TextContext<'a> { /// The font loader to retrieve fonts from when typesetting text /// using [`layout_text`]. - pub loader: &'a SharedFontLoader<'p>, + pub loader: &'a GlobalFontLoader, /// The style for text: Font selection with classes, weights and variants, /// font sizes, spacing and so on. pub style: &'a TextStyle, @@ -39,13 +40,13 @@ pub struct TextContext<'a, 'p> { } /// Layouts text into a box. -pub async fn layout_text(text: &str, ctx: TextContext<'_, '_>) -> Layout { +pub async fn layout_text(text: &str, ctx: TextContext<'_>) -> Layout { TextLayouter::new(text, ctx).layout().await } -impl<'a, 'p> TextLayouter<'a, 'p> { +impl<'a> TextLayouter<'a> { /// Create a new text layouter. - fn new(text: &'a str, ctx: TextContext<'a, 'p>) -> TextLayouter<'a, 'p> { + fn new(text: &'a str, ctx: TextContext<'a>) -> TextLayouter<'a> { TextLayouter { ctx, text, |
