mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-26 02:58:32 -06:00
A luminosity soft mask is drawn into an RGB buffer and its value read as the luminance of that buffer. A /DeviceCMYK colour reached the buffer through the CMYK display profile, where 100% K is a dark grey, so a mask painted 100% K in a DeviceCMYK group let about an eighth of the masked paint through (mask value 0.125 instead of 0). ISO 32000-2 11.5.3 converts a device-space group colour to gray "with no compensation for gamma or other colour calibration", and 10.4.2.3 gives DeviceCMYK to DeviceGray as gray = 1 - min(1, 0.3 c + 0.59 m + 0.11 y + k). hayro-interpret patch (63): when the group colour space of a luminosity soft mask is /DeviceCMYK itself (not an ICC-based or calibrated space), the mask's context paints /DeviceCMYK fill and stroke colours as that gray, and a four-component /BC becomes the same gray. A gray reads back as itself through any luminance weights that sum to one. CMYK on the page, CMYK in DeviceGray/DeviceRGB mask groups, and CMYK images, shadings and tiling patterns inside such a mask keep the profile. Tests: color::device_cmyk_gray_tests (hayro-interpret) and it::luminosity_group_space (pdfcraft-render); the three DeviceCMYK render tests fail with the patch reverted. Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>