summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-11-27 22:35:42 +0100
committerLaurenz <laurmaedje@gmail.com>2020-11-27 22:35:42 +0100
commit475ca7a62ec99f0b4d8319410b7ee3134a5fcfec (patch)
tree75037761e1da5681b2971e79e605f95903ba6032 /src/layout/mod.rs
parentbc997b7c3380d5f516f0aa58efc3dd513d75fafb (diff)
Basic environment and resource loader 🏞
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 28b27899..1f7d6c9f 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -8,9 +8,7 @@ mod spacing;
mod stack;
mod text;
-use image::RgbImage;
-
-use crate::font::SharedFontLoader;
+use crate::env::{ResourceId, SharedEnv};
use crate::geom::*;
use crate::shaping::Shaped;
@@ -23,16 +21,16 @@ pub use stack::*;
pub use text::*;
/// Layout a document and return the produced layouts.
-pub fn layout(document: &Document, loader: SharedFontLoader) -> Vec<BoxLayout> {
- let mut ctx = LayoutContext { loader };
+pub fn layout(document: &Document, env: SharedEnv) -> Vec<BoxLayout> {
+ let mut ctx = LayoutContext { env };
document.layout(&mut ctx)
}
/// The context for layouting.
#[derive(Debug, Clone)]
pub struct LayoutContext {
- /// The font loader to query fonts from when typesetting text.
- pub loader: SharedFontLoader,
+ /// The environment from which fonts are gathered.
+ pub env: SharedEnv,
}
/// Layout a node.
@@ -185,7 +183,7 @@ pub enum LayoutElement {
#[derive(Debug, Clone, PartialEq)]
pub struct ImageElement {
/// The image.
- pub buf: RgbImage,
+ pub resource: ResourceId,
/// The document size of the image.
pub size: Size,
}