mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-14 19:27:07 -04:00
Integration: #836 a grey stop beside a CMYK stop exports as the K ink, keeping the PDF shading in DeviceCMYK
(cherry picked from commit f28456d9d33930fcdd48b1c74460d72fe47a6d77)
This commit is contained in:
1 parent
ed6bcae877
commit
87682c3674
3 files changed
+12
-3
No files matched your search
@@ -169,7 +169,6 @@ impl Color {
|
||||
let [r, g, b] = self.to_rgb();
|
||||
Color::rgb(1.0 - r, 1.0 - g, 1.0 - b)
|
||||
}
|
||||
/// Linear interpolation in display RGB.
|
||||
/// The colour `t` of the way to `other`. Process inks blend as inks (CMYK with CMYK or grey,
|
||||
/// grey with grey), as InDesign blends a gradient's stops; anything else blends in RGB.
|
||||
pub fn lerp(&self, other: &Color, t: f32) -> Color {
|
||||
|
||||
@@ -981,7 +981,15 @@ impl Exporter<'_> {
|
||||
let (swatch, tint, angle) = (fill.swatch.as_str(), fill.tint, fill.gradient_angle);
|
||||
if let Some(g) = designcraft_color::swatch::resolve_gradient(&self.doc.swatches, swatch) {
|
||||
let kind = g.kind;
|
||||
let expanded = g.expanded_stops();
|
||||
let mut expanded = g.expanded_stops();
|
||||
// Grey and CMYK stops blend as inks, so a grey stop beside a CMYK one is the K ink.
|
||||
if !self.rgb_only && expanded.iter().any(|(_, c, _)| matches!(c, Color::Cmyk { .. })) {
|
||||
for (_, c, _) in &mut expanded {
|
||||
if let Color::Gray { k } = *c {
|
||||
*c = Color::cmyk(0.0, 0.0, 0.0, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
// A PDF shading needs one colour space. Midpoint expansion can introduce RGB even
|
||||
// when every authored stop is CMYK/Gray; PDF/A can also change the output space.
|
||||
let components = |c: &Color| match c {
|
||||
|
||||
@@ -53,7 +53,7 @@ fn mixed_gradient_export_survives_in_subprocess() {
|
||||
let rgb = Color::rgb(1.0, 0.0, 0.0);
|
||||
let cmyk = Color::cmyk(1.0, 0.0, 0.0, 0.0);
|
||||
let gray = Color::gray(0.4);
|
||||
for colors in [vec![cmyk, rgb], vec![rgb, cmyk], vec![rgb, gray], vec![gray, cmyk], vec![gray, rgb, cmyk]] {
|
||||
for colors in [vec![cmyk, rgb], vec![rgb, cmyk], vec![rgb, gray], vec![gray, rgb, cmyk]] {
|
||||
for kind in [GradientKind::Linear, GradientKind::Radial] {
|
||||
for standard in [Standard::None, Standard::PdfX4, Standard::PdfA2b] {
|
||||
let d = document(&colors, kind, 0.5, 0.7);
|
||||
@@ -107,6 +107,8 @@ fn homogeneous_gradients_keep_device_spaces_and_components() {
|
||||
([Color::rgb(1.0, 0.0, 0.0), Color::rgb(0.0, 0.0, 1.0)], "DeviceRGB", vec![1.0, 0.0, 0.0], vec![0.0, 0.0, 1.0]),
|
||||
([Color::cmyk(1.0, 0.0, 0.0, 0.0), Color::cmyk(0.0, 1.0, 0.0, 0.0)], "DeviceCMYK", vec![1.0, 0.0, 0.0, 0.0], vec![0.0, 1.0, 0.0, 0.0]),
|
||||
([Color::gray(0.2), Color::gray(0.8)], "DeviceGray", vec![0.8], vec![0.2]),
|
||||
// Grey beside CMYK is the K ink, so the shading stays CMYK.
|
||||
([Color::gray(0.4), Color::cmyk(1.0, 0.0, 0.0, 0.0)], "DeviceCMYK", vec![0.0, 0.0, 0.0, 0.4], vec![1.0, 0.0, 0.0, 0.0]),
|
||||
] {
|
||||
for standard in [Standard::None, Standard::PdfX4] {
|
||||
let report = export_pdf_with_report(
|
||||
|
||||
Reference in new issue
Block a user