diff options
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 10 | ||||
| -rw-r--r-- | src/layout/text.rs | 3 |
2 files changed, 6 insertions, 7 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 714bac4b..44960de7 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -8,7 +8,7 @@ mod spacing; mod stack; mod text; -use crate::env::{ResourceId, SharedEnv}; +use crate::env::{Env, ResourceId}; use crate::geom::*; use crate::shaping::Shaped; @@ -21,7 +21,7 @@ pub use stack::*; pub use text::*; /// Layout a tree into a collection of frames. -pub fn layout(tree: &Tree, env: SharedEnv) -> Vec<Frame> { +pub fn layout(tree: &Tree, env: &mut Env) -> Vec<Frame> { tree.layout(&mut LayoutContext { env }) } @@ -65,10 +65,10 @@ pub trait Layout { } /// The context for layouting. -#[derive(Debug, Clone)] -pub struct LayoutContext { +#[derive(Debug)] +pub struct LayoutContext<'a> { /// The environment from which fonts are gathered. - pub env: SharedEnv, + pub env: &'a mut Env, } /// A collection of areas to layout into. diff --git a/src/layout/text.rs b/src/layout/text.rs index cfd83372..ee85ee17 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -25,13 +25,12 @@ pub struct NodeText { impl Layout for NodeText { fn layout(&self, ctx: &mut LayoutContext, _: &Areas) -> Layouted { - let mut env = ctx.env.borrow_mut(); Layouted::Frame( shaping::shape( &self.text, self.dir, self.font_size, - &mut env.fonts, + &mut ctx.env.fonts, &self.families, self.variant, ), |
