From d54c06bfb111487181e72591a0137e0900ad29c1 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 4 Dec 2024 20:16:07 +0700 Subject: [PATCH] Be explicit about CPAL color space The OpenType specification defines that this data is sRGB and Skrifa follows along. Be clear about it here though as even if other things change with color, this should be sure to be interpreting that data correctly. --- vello/src/scene.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vello/src/scene.rs b/vello/src/scene.rs index 555ca5f4..aba8ab68 100644 --- a/vello/src/scene.rs +++ b/vello/src/scene.rs @@ -6,7 +6,7 @@ mod bitmap; use std::sync::Arc; use peniko::{ - color::{palette, DynamicColor, Srgb}, + color::{palette, AlphaColor, DynamicColor, Srgb}, kurbo::{Affine, BezPath, Point, Rect, Shape, Stroke, Vec2}, BlendMode, Blob, Brush, BrushRef, Color, ColorStop, ColorStops, ColorStopsSource, Compose, Extend, Fill, Font, Gradient, Image, Mix, StyleRef, @@ -979,7 +979,9 @@ fn conv_brush( } } -fn color_index(cpal: &'_ Cpal<'_>, palette_index: u16) -> Option { +// The OpenType color palette is defined to be using the sRGB color space. +// +fn color_index(cpal: &'_ Cpal<'_>, palette_index: u16) -> Option> { // The "application determined" foreground color should be used // This will be handled by the caller if palette_index == 0xFFFF { @@ -988,7 +990,7 @@ fn color_index(cpal: &'_ Cpal<'_>, palette_index: u16) -> Option { let actual_colors = cpal.color_records_array().unwrap().unwrap(); // TODO: Error reporting in the `None` case let color = actual_colors.get(usize::from(palette_index))?; - Some(Color::from_rgba8( + Some(AlphaColor::::from_rgba8( color.red, color.green, color.blue,