diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-17 00:17:28 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-17 00:17:28 +0200 |
| commit | 9a798ce6f6e734a02764473891632c071fed41ee (patch) | |
| tree | cb433d5b6309f55799749c19eec8579d86bf36b2 /src/library | |
| parent | 9462fb17b390c57846b9215217ca7c32b649f0a5 (diff) | |
Make percentages for h and v relative to area instead of font size
Diffstat (limited to 'src/library')
| -rw-r--r-- | src/library/layout.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs index 977b3153..67e58606 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -80,20 +80,17 @@ pub fn pagebreak(_: &mut EvalContext, _: &mut Arguments) -> TypResult<Value> { /// `h`: Horizontal spacing. pub fn h(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> { - spacing_impl(args, GenAxis::Cross) + let spacing = args.expect("spacing")?; + Ok(Value::template(move |ctx| { + ctx.push_spacing(GenAxis::Cross, spacing); + })) } /// `v`: Vertical spacing. pub fn v(_: &mut EvalContext, args: &mut Arguments) -> TypResult<Value> { - spacing_impl(args, GenAxis::Main) -} - -fn spacing_impl(args: &mut Arguments, axis: GenAxis) -> TypResult<Value> { - let spacing = args.expect::<Linear>("spacing")?; + let spacing = args.expect("spacing")?; Ok(Value::template(move |ctx| { - // TODO: Should this really always be font-size relative? - let amount = spacing.resolve(ctx.state.font.size); - ctx.push_spacing(axis, amount); + ctx.push_spacing(GenAxis::Main, spacing); })) } |
