From bbcdeb128cce04cd95714b7bc7af5a23a7e38bd2 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 29 Jul 2020 18:09:51 +0200 Subject: =?UTF-8?q?Move,=20rename=20and=20switch=20some=20things=20(boring?= =?UTF-8?q?)=20=F0=9F=9A=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Problems -> Diagnostics - Position -> Pos - offset_spans -> Offset trait - Size -> Length (and some more size types renamed) - Paper into its own module - scope::Parser -> parsing::CallParser - Create `Decorations` alias - Remove lots of double newlines - Switch from f32 to f64 --- src/library/font.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/library/font.rs') diff --git a/src/library/font.rs b/src/library/font.rs index 9f7902f6..28b79115 100644 --- a/src/library/font.rs +++ b/src/library/font.rs @@ -1,8 +1,7 @@ use toddle::query::{FontWeight, FontStyle}; -use crate::size::FSize; +use crate::length::ScaleLength; use super::*; - function! { /// `font.family`: Set the font family. #[derive(Debug, Clone, PartialEq)] @@ -13,17 +12,17 @@ function! { } parse(header, body, ctx, f) { - let list = header.args.pos.get_all::(&mut f.problems) + let list = header.args.pos.get_all::(&mut f.diagnostics) .map(|s| s.0.to_lowercase()) .collect(); let tuples: Vec<_> = header.args.key - .get_all::(&mut f.problems) + .get_all::(&mut f.diagnostics) .collect(); let classes = tuples.into_iter() .map(|(class, mut tuple)| { - let fallback = tuple.get_all::(&mut f.problems) + let fallback = tuple.get_all::(&mut f.diagnostics) .map(|s| s.0.to_lowercase()) .collect(); (class.to_lowercase(), fallback) @@ -64,8 +63,8 @@ function! { parse(header, body, ctx, f) { FontStyleFunc { body: body!(opt: body, ctx, f), - style: header.args.pos.get::(&mut f.problems) - .or_missing(&mut f.problems, header.name.span, "style"), + style: header.args.pos.get::(&mut f.diagnostics) + .or_missing(&mut f.diagnostics, header.name.span, "style"), } } @@ -84,7 +83,7 @@ function! { parse(header, body, ctx, f) { let body = body!(opt: body, ctx, f); - let weight = header.args.pos.get::>(&mut f.problems) + let weight = header.args.pos.get::>(&mut f.diagnostics) .map(|Spanned { v: (weight, is_clamped), span }| { if is_clamped { warning!( @@ -96,7 +95,7 @@ function! { weight }) - .or_missing(&mut f.problems, header.name.span, "weight"); + .or_missing(&mut f.diagnostics, header.name.span, "weight"); FontWeightFunc { body, weight } } @@ -111,25 +110,25 @@ function! { #[derive(Debug, Clone, PartialEq)] pub struct FontSizeFunc { body: Option, - size: Option, + size: Option, } parse(header, body, ctx, f) { FontSizeFunc { body: body!(opt: body, ctx, f), - size: header.args.pos.get::(&mut f.problems) - .or_missing(&mut f.problems, header.name.span, "size") + size: header.args.pos.get::(&mut f.diagnostics) + .or_missing(&mut f.diagnostics, header.name.span, "size") } } layout(self, ctx, f) { styled(&self.body, ctx, self.size, |t, s| { match s { - FSize::Absolute(size) => { + ScaleLength::Absolute(size) => { t.base_font_size = size; t.font_scale = 1.0; } - FSize::Scaled(scale) => t.font_scale = scale, + ScaleLength::Scaled(scale) => t.font_scale = scale, } }) } -- cgit v1.2.3