summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-12-17 15:43:30 +0100
committerLaurenz <laurmaedje@gmail.com>2020-12-17 15:43:30 +0100
commit6f111f941008f10ddc06e6f56da9e3582e90d2c4 (patch)
tree0ee44f6c9d88353320893522cf14931863ddf742 /src/library
parent7e91c8dc87e345ee38b934375d113e824a423a2b (diff)
Test [font] 🧣
Diffstat (limited to 'src/library')
-rw-r--r--src/library/layout.rs20
-rw-r--r--src/library/style.rs18
2 files changed, 19 insertions, 19 deletions
diff --git a/src/library/layout.rs b/src/library/layout.rs
index 36a20821..23066fdc 100644
--- a/src/library/layout.rs
+++ b/src/library/layout.rs
@@ -21,10 +21,10 @@ use crate::prelude::*;
pub fn align(mut args: Args, ctx: &mut EvalContext) -> Value {
let snapshot = ctx.state.clone();
let body = args.find::<SynTree>();
- let first = args.get::<_, Spanned<AlignArg>>(ctx, 0);
- let second = args.get::<_, Spanned<AlignArg>>(ctx, 1);
- let hor = args.get::<_, Spanned<AlignArg>>(ctx, "horizontal");
- let ver = args.get::<_, Spanned<AlignArg>>(ctx, "vertical");
+ let first = args.get::<_, Spanned<SpecAlign>>(ctx, 0);
+ let second = args.get::<_, Spanned<SpecAlign>>(ctx, 1);
+ let hor = args.get::<_, Spanned<SpecAlign>>(ctx, "horizontal");
+ let ver = args.get::<_, Spanned<SpecAlign>>(ctx, "vertical");
args.done(ctx);
let prev_main = ctx.state.align.main;
@@ -58,7 +58,7 @@ pub fn align(mut args: Args, ctx: &mut EvalContext) -> Value {
} else {
// We don't know the axis: This has to be a `center` alignment for a
// positional argument.
- debug_assert_eq!(arg, AlignArg::Center);
+ debug_assert_eq!(arg, SpecAlign::Center);
if had.main && had.cross {
ctx.diag(error!(span, "duplicate alignment"));
@@ -108,7 +108,7 @@ pub fn align(mut args: Args, ctx: &mut EvalContext) -> Value {
/// An argument to `[align]`.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
-enum AlignArg {
+enum SpecAlign {
Left,
Right,
Top,
@@ -116,7 +116,7 @@ enum AlignArg {
Center,
}
-convert_ident!(AlignArg, "alignment", |v| match v {
+convert_ident!(SpecAlign, "alignment", |v| match v {
"left" => Some(Self::Left),
"right" => Some(Self::Right),
"top" => Some(Self::Top),
@@ -125,7 +125,7 @@ convert_ident!(AlignArg, "alignment", |v| match v {
_ => None,
});
-impl AlignArg {
+impl SpecAlign {
/// The specific axis this alignment refers to.
///
/// Returns `None` if this is `Center` since the axis is unknown.
@@ -140,7 +140,7 @@ impl AlignArg {
}
}
-impl Switch for AlignArg {
+impl Switch for SpecAlign {
type Other = Align;
fn switch(self, flow: Flow) -> Self::Other {
@@ -163,7 +163,7 @@ impl Switch for AlignArg {
}
}
-impl Display for AlignArg {
+impl Display for SpecAlign {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.pad(match self {
Self::Left => "left",
diff --git a/src/library/style.rs b/src/library/style.rs
index 804e9424..c641a598 100644
--- a/src/library/style.rs
+++ b/src/library/style.rs
@@ -71,13 +71,6 @@ pub fn font(mut args: Args, ctx: &mut EvalContext) -> Value {
}
}
- let mut needs_flattening = false;
- let list: Vec<_> = args.find_all::<StringLike>().map(|s| s.to_lowercase()).collect();
- if !list.is_empty() {
- Rc::make_mut(&mut ctx.state.font.families).list = list;
- needs_flattening = true;
- }
-
if let Some(style) = args.get::<_, FontStyle>(ctx, "style") {
ctx.state.font.variant.style = style;
}
@@ -90,6 +83,13 @@ pub fn font(mut args: Args, ctx: &mut EvalContext) -> Value {
ctx.state.font.variant.stretch = stretch;
}
+ let mut needs_flattening = false;
+ let list: Vec<_> = args.find_all::<StringLike>().map(|s| s.to_lowercase()).collect();
+ if !list.is_empty() {
+ Rc::make_mut(&mut ctx.state.font.families).list = list;
+ needs_flattening = true;
+ }
+
for (class, dict) in args.find_all_str::<Spanned<ValueDict>>() {
let fallback = Args(dict)
.find_all::<StringLike>()
@@ -100,12 +100,12 @@ pub fn font(mut args: Args, ctx: &mut EvalContext) -> Value {
needs_flattening = true;
}
- args.done(ctx);
-
if needs_flattening {
Rc::make_mut(&mut ctx.state.font.families).flatten();
}
+ args.done(ctx);
+
if let Some(body) = body {
body.eval(ctx);
ctx.state = snapshot;