From c4a87e5e7c5032d2579cdd23939aedec499f93f0 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 2 Nov 2021 10:30:27 +0100 Subject: [PATCH] Number style -> type --- src/library/text.rs | 16 ++++++++-------- src/style/mod.rs | 10 +++++----- tests/typ/text/features.typ | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/library/text.rs b/src/library/text.rs index e55ba4830..924723b4e 100644 --- a/src/library/text.rs +++ b/src/library/text.rs @@ -11,7 +11,7 @@ use crate::font::{ }; use crate::geom::{Dir, Em, Length, Point, Size}; use crate::style::{ - FontFeatures, NumberPosition, NumberStyle, NumberWidth, Style, TextStyle, + FontFeatures, NumberPosition, NumberType, NumberWidth, Style, TextStyle, }; use crate::util::SliceExt; @@ -103,7 +103,7 @@ pub fn font(ctx: &mut EvalContext, args: &mut Args) -> TypResult { } castable! { - NumberStyle: "auto or string", + NumberType: "auto or string", Value::Auto => Self::Auto, Value::Str(string) => match string.as_str() { "lining" => Self::Lining, @@ -176,7 +176,7 @@ pub fn font(ctx: &mut EvalContext, args: &mut Args) -> TypResult { let ligatures = args.named("ligatures")?; let discretionary_ligatures = args.named("discretionary-ligatures")?; let historical_ligatures = args.named("historical-ligatures")?; - let number_style = args.named("number-style")?; + let number_type = args.named("number-type")?; let number_width = args.named("number-width")?; let number_position = args.named("number-position")?; let slashed_zero = args.named("slashed-zero")?; @@ -233,7 +233,7 @@ pub fn font(ctx: &mut EvalContext, args: &mut Args) -> TypResult { set!(text.features_mut().ligatures.standard => ligatures); set!(text.features_mut().ligatures.discretionary => discretionary_ligatures); set!(text.features_mut().ligatures.historical => historical_ligatures); - set!(text.features_mut().numbers.style => number_style); + set!(text.features_mut().numbers.type_ => number_type); set!(text.features_mut().numbers.width => number_width); set!(text.features_mut().numbers.position => number_position); set!(text.features_mut().numbers.slashed_zero => slashed_zero); @@ -661,10 +661,10 @@ fn tags(features: &FontFeatures) -> Vec { feat(b"hilg", 1); } - match features.numbers.style { - NumberStyle::Auto => {} - NumberStyle::Lining => feat(b"lnum", 1), - NumberStyle::OldStyle => feat(b"onum", 1), + match features.numbers.type_ { + NumberType::Auto => {} + NumberType::Lining => feat(b"lnum", 1), + NumberType::OldStyle => feat(b"onum", 1), } match features.numbers.width { diff --git a/src/style/mod.rs b/src/style/mod.rs index cb27181f9..4b1d2837a 100644 --- a/src/style/mod.rs +++ b/src/style/mod.rs @@ -268,7 +268,7 @@ pub struct FontFeatures { pub smallcaps: bool, /// Whether to apply stylistic alternates. ("salt") pub alternates: bool, - /// Which stylistic set to apply. ("ss00" - "ss20") + /// Which stylistic set to apply. ("ss01" - "ss20") pub stylistic_set: Option, /// Configuration of ligature features. pub ligatures: LigatureFeatures, @@ -317,7 +317,7 @@ impl Default for LigatureFeatures { #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct NumberFeatures { /// Whether to use lining or old-style numbers. - pub style: NumberStyle, + pub type_: NumberType, /// Whether to use proportional or tabular numbers. pub width: NumberWidth, /// How to position numbers vertically. @@ -331,7 +331,7 @@ pub struct NumberFeatures { impl Default for NumberFeatures { fn default() -> Self { Self { - style: NumberStyle::Auto, + type_: NumberType::Auto, width: NumberWidth::Auto, position: NumberPosition::Normal, slashed_zero: false, @@ -340,9 +340,9 @@ impl Default for NumberFeatures { } } -/// How numbers / figures look. +/// Which kind of numbers / figures to select. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum NumberStyle { +pub enum NumberType { /// Select the font's preference. Auto, /// Numbers that fit well with capital text. ("lnum") diff --git a/tests/typ/text/features.typ b/tests/typ/text/features.typ index 10214bdb1..fc84514b2 100644 --- a/tests/typ/text/features.typ +++ b/tests/typ/text/features.typ @@ -21,10 +21,10 @@ a vs #font(alternates: true)[a] \ fi vs. #font(ligatures: false)[No fi] \ --- -// Test number style. +// Test number type. #font("Roboto") -#font(number-style: "old-style") 0123456789 \ -#font(number-style: auto)[0123456789] +#font(number-type: "old-style") 0123456789 \ +#font(number-type: auto)[0123456789] --- // Test number width. @@ -57,8 +57,8 @@ fi vs. #font(features: (liga: 0))[No fi] #font(stylistic-set: 25) --- -// Error: 21-32 expected "lining" or "old-style" -#font(number-style: "different") +// Error: 20-31 expected "lining" or "old-style" +#font(number-type: "different") --- // Error: 17-22 expected array of strings or dictionary mapping tags to integers, found boolean