diff options
Diffstat (limited to 'crates/typst-library/src')
| -rw-r--r-- | crates/typst-library/src/lib.rs | 1 | ||||
| -rw-r--r-- | crates/typst-library/src/text/deco.rs | 2 | ||||
| -rw-r--r-- | crates/typst-library/src/text/raw.rs | 9 |
3 files changed, 7 insertions, 5 deletions
diff --git a/crates/typst-library/src/lib.rs b/crates/typst-library/src/lib.rs index bdb97f84..03e96441 100644 --- a/crates/typst-library/src/lib.rs +++ b/crates/typst-library/src/lib.rs @@ -63,6 +63,7 @@ fn prelude(global: &mut Scope) { global.define("green", Color::GREEN); global.define("lime", Color::LIME); global.define("luma", Color::luma_data()); + global.define("oklab", Color::oklab_data()); global.define("rgb", Color::rgb_data()); global.define("cmyk", Color::cmyk_data()); global.define("range", Array::range_data()); diff --git a/crates/typst-library/src/text/deco.rs b/crates/typst-library/src/text/deco.rs index 4f85abef..6fd56bb6 100644 --- a/crates/typst-library/src/text/deco.rs +++ b/crates/typst-library/src/text/deco.rs @@ -240,7 +240,7 @@ pub struct HighlightElem { /// ```example /// This is #highlight(fill: blue)[with blue]. /// ``` - #[default(Color::Rgba(RgbaColor::new(0xFF, 0xFF, 0x5F, 0xFF)).into())] + #[default(Color::from_u8(0xFF, 0xFF, 0x5F, 0xFF).into())] pub fill: Paint, /// The top end of the background rectangle. diff --git a/crates/typst-library/src/text/raw.rs b/crates/typst-library/src/text/raw.rs index 1f46f94d..688e69d8 100644 --- a/crates/typst-library/src/text/raw.rs +++ b/crates/typst-library/src/text/raw.rs @@ -454,11 +454,12 @@ fn styled(piece: &str, foreground: Paint, style: synt::Style) -> Content { body } -fn to_typst(synt::Color { r, g, b, a }: synt::Color) -> RgbaColor { - RgbaColor { r, g, b, a } +fn to_typst(synt::Color { r, g, b, a }: synt::Color) -> Color { + Color::from_u8(r, g, b, a) } -fn to_syn(RgbaColor { r, g, b, a }: RgbaColor) -> synt::Color { +fn to_syn(color: Color) -> synt::Color { + let [r, g, b, a] = color.to_vec4_u8(); synt::Color { r, g, b, a } } @@ -628,7 +629,7 @@ fn item( synt::ThemeItem { scope: scope.parse().unwrap(), style: synt::StyleModifier { - foreground: color.map(|s| to_syn(s.parse::<RgbaColor>().unwrap())), + foreground: color.map(|s| to_syn(s.parse::<Color>().unwrap())), background: None, font_style, }, |
