diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-08-01 00:01:17 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-08-01 00:10:54 +0200 |
| commit | 06dbac6efd98be5a015023c88ed3dbd9a35a4594 (patch) | |
| tree | bb3c75230098bf71d1ac23bbe7184e4ae7a6cef2 /src/layout/model.rs | |
| parent | 064954cf9edbb0201b6184e69978f86e93741008 (diff) | |
Port font handling to fontdock and ttf-parser 🛳
- Use fontdock for indexing fonts and querying
- Typst binary now automatically indexes and uses system fonts in addition to a fixed font folder!
- Removes subsetting support for now (was half-finished anyways, plan is to use harfbuzz for subsetting in the future)
- Adds font width configuration support
Diffstat (limited to 'src/layout/model.rs')
| -rw-r--r-- | src/layout/model.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/layout/model.rs b/src/layout/model.rs index a15598d2..3fb594d5 100644 --- a/src/layout/model.rs +++ b/src/layout/model.rs @@ -5,10 +5,9 @@ use std::future::Future; use std::pin::Pin; use smallvec::smallvec; -use toddle::query::FontStyle; use crate::{Pass, Feedback}; -use crate::GlobalFontLoader; +use crate::SharedFontLoader; use crate::style::{LayoutStyle, PageStyle, TextStyle}; use crate::length::{Length, Size}; use crate::syntax::{Model, SyntaxModel, Node, Decoration}; @@ -31,7 +30,7 @@ pub struct ModelLayouter<'a> { pub struct LayoutContext<'a> { /// The font loader to retrieve fonts from when typesetting text /// using [`layout_text`]. - pub loader: &'a GlobalFontLoader, + pub loader: &'a SharedFontLoader, /// The style for pages and text. pub style: &'a LayoutStyle, /// The base unpadded dimensions of this container (for relative sizing). @@ -167,7 +166,7 @@ impl<'a> ModelLayouter<'a> { Linebreak => self.layouter.finish_line(), Text(text) => { - if self.style.text.variant.style == FontStyle::Italic { + if self.style.text.italic { decorate(self, Decoration::Italic); } @@ -179,7 +178,7 @@ impl<'a> ModelLayouter<'a> { } ToggleItalic => { - self.style.text.variant.style.toggle(); + self.style.text.italic = !self.style.text.italic; decorate(self, Decoration::Italic); } @@ -191,7 +190,7 @@ impl<'a> ModelLayouter<'a> { Raw(lines) => { // TODO: Make this more efficient. let fallback = self.style.text.fallback.clone(); - self.style.text.fallback.list.insert(0, "monospace".to_string()); + self.style.text.fallback.list_mut().insert(0, "monospace".to_string()); self.style.text.fallback.flatten(); // Layout the first line. |
