Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CSS color module level 4 #1630

Closed
sander-deryckere opened this issue Apr 28, 2022 · 7 comments
Closed

Support CSS color module level 4 #1630

sander-deryckere opened this issue Apr 28, 2022 · 7 comments
Labels
feature New feature that should be supported
Milestone

Comments

@sander-deryckere
Copy link

When using a color value without commas (like style="color: hsl(180 100% 50%);"), the resulting color is black. While color values with a comma (like style="color: hsl(180, 100%, 50%);") work as expected.

Both should give the same results: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl

@liZe liZe added the feature New feature that should be supported label Apr 28, 2022
@liZe
Copy link
Member

liZe commented Apr 28, 2022

Hi!

That’s a feature introduced in CSS color module 4.

@liZe
Copy link
Member

liZe commented Apr 28, 2022

It will require some work in Kozea/tinycss2#47.

@liZe liZe added the good first issue Issues that can be quite easily solved by Python developers with a good CSS background label Apr 29, 2022
@liZe
Copy link
Member

liZe commented Apr 29, 2022

If anyone is interested in implementing this feature, I’ll be happy to help! That’s a fun feature to learn more about web specifications, and it shouldn’t be too difficult to get nice results with a small amount of code lines.

@Thomasb81
Copy link

Thomasb81 commented May 7, 2022

Hello

Apparently to fix this issue following function need to be fix:
https://github.com/Kozea/tinycss2/blob/291c1429e7de23d839c8bc187908b967013db477/tinycss2/color3.py#L126
in order to support 180, 100%, 50% or 180 100% 50%

But I understand also that hsl(180 100% 50%) is new syntax introduce by css-color-4 which is not yet approved W3C standard.
So if this fix is implemented is there other feature of this draft that need to be anticipate ?

@liZe
Copy link
Member

liZe commented May 7, 2022

So if this fix is implemented is there other feature of this draft that need to be anticipate ?

Actually, we should keep the color3 module and write another color4 module in tinycss2, in order to let users choose the version they want to support. We’ll then be able to use color4 instead of color3 in WeasyPrint.

It’s safe to implement almost everything from this specification. Even if it’s only a working draft, some of its features are already implemented in other browsers, it shouldn’t change much in the future. Libraries using tinycss2 will be free to use the version they want.

@Thomasb81
Copy link

Thomasb81 commented May 7, 2022

color4 seems far more complex than color3.

In particular there is support for Device-independent colors and Predefined Color Space

Where the purpose if I understand it well is to have high fidelity color rending on device : monitor in case you read you document on a calibrated screen or on paper-ink-printer to preserve author intent.

Can such application be supported by PDF and WeasyPrint ? I may be wrong but I guess today only RGBA is supported and everything is converted to RGBA. With Color4 I understand that the specified color space should end-up in the pdf document.
Implementing everything on this topic required sharp knowledge and very few user may use them ...

@liZe
Copy link
Member

liZe commented May 10, 2022

color4 seems far more complex than color3.

Yes, it is.

I may be wrong but I guess today only RGBA is supported and everything is converted to RGBA.

Unfortunately, you’re wrong. CMYK support, for example, would be very useful for WeasyPrint.

In particular there is support for Device-independent colors and Predefined Color Space […] Can such application be supported by PDF and WeasyPrint?

There are three different steps.

The first step is to handle the syntax in tinycss2.color4. This part is necessary before handling what we can/want to handle in WeasyPrint. For this step, there’s no need to assume whether device-independent colors or predefined color spaces can/will be supported by PDF and WeasyPrint.

The second part is to use tinycss2.color4 instead of tinycss2.color3 in WeasyPrint. It’s the first step giving the possibility to handle new syntaxes (ie. fixing this bug).

The third part is to include new features, in the future. We’ll answer these questions then.(Spoiler alert: they are useful, for example for PDF/A support that can require default ICC profiles to be embedded. That’s just an example, CMYK being another obvious one.)

Implementing everything on this topic required sharp knowledge

Do you imply that implementing countless CSS specifications, HTML, PDF generation or SVG rendering doesn’t require sharp knowledge 😁? We can learn, as we always do.

More seriously, we don’t want to handle everything in WeasyPrint right now. We only need the two first steps, and they are the easiest ones.

and very few user may use them

I wouldn’t assume that CMYK is only used by "very few users" in the print industry 😁. And among the 7 million downloads of tinycss2 last month, it’s probably possible to find a few users that would benefit from a clean support of the level 4 syntax.

@liZe liZe changed the title Color values without comma are not supported Support CSS color module level 4 Sep 17, 2022
@liZe liZe removed the good first issue Issues that can be quite easily solved by Python developers with a good CSS background label May 19, 2024
@liZe liZe added this to the 63.0 milestone Jul 11, 2024
@liZe liZe pinned this issue Sep 14, 2024
@liZe liZe closed this as completed Oct 29, 2024
@grewn0uille grewn0uille unpinned this issue Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

No branches or pull requests

3 participants