summaryrefslogtreecommitdiff
path: root/src/engine/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-03-30 18:47:17 +0100
committerLaurenz <laurmaedje@gmail.com>2019-03-30 18:47:17 +0100
commite6e5aad7cef36a40a8d808fca02866649e464d87 (patch)
treea524eb37d960990760182d6790ff9d3d3934b2c0 /src/engine/mod.rs
parentdb96ecae94a7c06d04528e8d4461ebca86d2d249 (diff)
Refactor font providing ⚙
Diffstat (limited to 'src/engine/mod.rs')
-rw-r--r--src/engine/mod.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/engine/mod.rs b/src/engine/mod.rs
index f121ac82..baad9bac 100644
--- a/src/engine/mod.rs
+++ b/src/engine/mod.rs
@@ -2,7 +2,7 @@
use crate::syntax::{SyntaxTree, Node};
use crate::doc::{Document, Page, Text, TextCommand};
-use crate::font::{Font, FontFamily, FontConfig, FontError};
+use crate::font::{Font, FontFamily, FontFilter, FontError};
use crate::Context;
mod size;
@@ -41,13 +41,18 @@ impl<'a> Engine<'a> {
pub fn typeset(mut self) -> TypeResult<Document> {
// Load font defined by style
let mut font = None;
- let config = FontConfig::new(self.ctx.style.font_families.clone());
+ let filter = FontFilter::new(&self.ctx.style.font_families);
for provider in &self.ctx.font_providers {
- if let Some(mut source) = provider.provide(&config) {
- let mut program = Vec::new();
- source.read_to_end(&mut program)?;
- font = Some(Font::new(program)?);
- break;
+ let available = provider.available();
+ for info in available {
+ if filter.matches(info) {
+ if let Some(mut source) = provider.get(info) {
+ let mut program = Vec::new();
+ source.read_to_end(&mut program)?;
+ font = Some(Font::new(program)?);
+ break;
+ }
+ }
}
}
@@ -141,7 +146,7 @@ impl<'a> Engine<'a> {
}
}
-/// Default styles for a document.
+/// Default styles for typesetting.
#[derive(Debug, Clone, PartialEq)]
pub struct Style {
/// The width of the paper.