From 475ca7a62ec99f0b4d8319410b7ee3134a5fcfec Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 27 Nov 2020 22:35:42 +0100 Subject: =?UTF-8?q?Basic=20environment=20and=20resource=20loader=20?= =?UTF-8?q?=F0=9F=8F=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/layout/mod.rs') 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 { - let mut ctx = LayoutContext { loader }; +pub fn layout(document: &Document, env: SharedEnv) -> Vec { + 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, } -- cgit v1.2.3