You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
incorrect generated colour different to one specified #1927
bugSomething isn't workingpdfRelated to PDF export or PDF embedding.visualizeRelated to the visualize category, which is about drawing and illustrating
I am trying to match colours on images and text. I have the exact colour values in hex, putting them into typst causes a slightly different colour to be presented. Ensure you compile these examples using typst c to generate a PDF.
I used a colour picker to get the real colour presented, it's placed in a comment at the end of the line.
#set page(fill: rgb("#F7208B")) // #F71A8C
#set page(fill: rgb("#131313")) // #0C0C0C
This can either be fixed, or return to me the correct algorithm/transformation to create a suitable matching colour.
I'm getting #f6168d and #0a0a0a in SumatraPDF, but #f71a8c and #0b0b0b in pdf.js (firefox), opening the exact same file. I suspect this may be about pdf viewers and and not typst.
Typst currently encodes colors using CalRGB color spaces in PDFs.
Computer monitors usually use the sRGB color space. However, according to the PDF standard (Version 1.7 Section 8.6.5.5 Note 2) it's not possible to represent the sRGB color space as a CalRGB color space, only to approximate it.
To properly support it typst will have to implement support for ICC color spaces.
Typst currently encodes colors using CalRGB color spaces in PDFs.
Computer monitors usually use the sRGB color space. However, according to the PDF standard (Version 1.7 Section 8.6.5.5 Note 2) it's not possible to represent the sRGB color space as a CalRGB color space, only to approximate it.
To properly support it typst will have to implement support for ICC color spaces.
As far as I understand it, many PDF readers will just ignore ICC
Strange that mupdf is complaining about broken ICC profiles, on my end it works just fine 😱
Adobe Acrobat probably has the best support, Chrome also supports ICC profiles, and so does mupdf
This could be an issue with the ICC profile being in a new version of ICC (which may have support issues in some readers, but I would at least expect acrobat to complain). It appears that they all recognize the ICC profile but chose to ignore it (at least for sRGB). Can you try setting the color to the similar luma(14), it should work in the same way by using grayscale instead and the grayscale ICC profile (that may be a temporary workaround, and it leads to smaller file sizes anyway). I also extracted the ICC profile and ran it with a diagnostics tools and it looks correct to me 🤷♂️
bugSomething isn't workingpdfRelated to PDF export or PDF embedding.visualizeRelated to the visualize category, which is about drawing and illustrating
Activity
mattfbacon commentedon Aug 14, 2023
I can confirm that, when importing the document into Inkscape and checking the fill color of the page, it is
#f71a8c.Enivex commentedon Aug 14, 2023
I'm getting #f6168d and #0a0a0a in SumatraPDF, but #f71a8c and #0b0b0b in pdf.js (firefox), opening the exact same file. I suspect this may be about pdf viewers and and not typst.
freundTech commentedon Aug 14, 2023
Typst currently encodes colors using CalRGB color spaces in PDFs.
Computer monitors usually use the sRGB color space. However, according to the PDF standard (Version 1.7 Section 8.6.5.5 Note 2) it's not possible to represent the sRGB color space as a CalRGB color space, only to approximate it.
To properly support it typst will have to implement support for ICC color spaces.
Enivex commentedon Aug 14, 2023
As far as I understand it, many PDF readers will just ignore ICC
l1mey112 commentedon Sep 27, 2023
What is the current status of this issue? I remember @Dherse was working on a rework of colours in a branch for Typst.
Dherse commentedon Sep 27, 2023
It's been merged with icc profiles for readers that support it!
l1mey112 commentedon Sep 27, 2023
Testing these changes out with the
typst-giton Arch, rendering the below.Chromium:
#0a0a0aFirefox:
#0c0c0cThese browsers do not have ICC support, having different colours is expected. I've tried a different renderer,
mupdf:What viewer could I use to properly render ICC colours? Is there ways to rasterise the entire PDF?
Dherse commentedon Sep 27, 2023
Strange that mupdf is complaining about broken ICC profiles, on my end it works just fine 😱
Adobe Acrobat probably has the best support, Chrome also supports ICC profiles, and so does mupdf
Dherse commentedon Sep 27, 2023
@l1mey112 can you send me your document so that I can inspect it? (you can also send it to me on Discord so that it stays private)
l1mey112 commentedon Sep 27, 2023
This is the document, I am selecting the colours on the left.
output.pdf
Dherse commentedon Sep 27, 2023
Okay, here is a little report:
This could be an issue with the ICC profile being in a new version of ICC (which may have support issues in some readers, but I would at least expect acrobat to complain). It appears that they all recognize the ICC profile but chose to ignore it (at least for sRGB). Can you try setting the color to the similar
luma(14), it should work in the same way by using grayscale instead and the grayscale ICC profile (that may be a temporary workaround, and it leads to smaller file sizes anyway). I also extracted the ICC profile and ran it with a diagnostics tools and it looks correct to me 🤷♂️laurmaedje commentedon Sep 29, 2023
Fixed by #2262