Skip to content

incorrect generated colour different to one specified #1927

Closed

Description

@l1mey112

Description

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.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Aug 14, 2023
  2. mattfbacon commented on Aug 14, 2023

    @mattfbacon
    Contributor

    I can confirm that, when importing the document into Inkscape and checking the fill color of the page, it is #f71a8c.

  3. Enivex commented on Aug 14, 2023

    @Enivex
    Collaborator

    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.

  4. freundTech commented on Aug 14, 2023

    @freundTech
    Contributor

    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.

  5. Enivex commented on Aug 14, 2023

    @Enivex
    Collaborator

    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

  6. added
    pdf
    visualize
    on Sep 4, 2023
  7. l1mey112 commented on Sep 27, 2023

    @l1mey112
    Author

    What is the current status of this issue? I remember @Dherse was working on a rework of colours in a branch for Typst.

  8. Dherse commented on Sep 27, 2023

    @Dherse
    Contributor

    What is the current status of this issue? I remember @Dherse was working on a rework of colours in a branch for Typst.

    It's been merged with icc profiles for readers that support it!

  9. l1mey112 commented on Sep 27, 2023

    @l1mey112
    Author

    Testing these changes out with the typst-git on Arch, rendering the below.

    #rect(fill: rgb("#141414"), height: 100%)[hello]
    

    Chromium: #0a0a0a
    Firefox: #0c0c0c

    These browsers do not have ICC support, having different colours is expected. I've tried a different renderer, mupdf:

    $ mupdf output.pdf &
    [1] 2092346
    warning: lcms: not an ICC profile, invalid signature.
    warning: ignoring broken ICC profile
    $ grabc
    #0c0c0c
    

    What viewer could I use to properly render ICC colours? Is there ways to rasterise the entire PDF?

  10. Dherse commented on Sep 27, 2023

    @Dherse
    Contributor

    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

  11. Dherse commented on Sep 27, 2023

    @Dherse
    Contributor

    @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)

  12. l1mey112 commented on Sep 27, 2023

    @l1mey112
    Author

    This is the document, I am selecting the colours on the left.

    output.pdf

  13. Dherse commented on Sep 27, 2023

    @Dherse
    Contributor

    Okay, here is a little report:

    • mupdf: not correct
    • Xpdf: correct
    • Acrobat: not correct
    • Summatra PDF: not correct
    • Chromium: not correct
    • Firefox/pdf.js: not correct
    • evince: not correct

    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 🤷‍♂️

  14. laurmaedje commented on Sep 29, 2023

    @laurmaedje
    Member

    Fixed by #2262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpdfvisualize

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions