-
Notifications
You must be signed in to change notification settings - Fork 2
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 Level 4 CSS Color (and Level 5 color-mix()
) values in sRGB gamut
#77
Comments
color-mix()
) values in sRGB gamut
Reported by @DaveJarvis #77 (comment)
…mut #77 When a color is outside of the sRGB gamut, performs a gamut mapping. Supporting actual non-sRGB colors requires additional work.
Fixed, now EchoSVG supports level 4 CSS colors as well as the Level 5
This is a known issue, and EchoSVG already does much better than Batik or Inkscape (unknown rules are just ignored instead of causing the whole stylesheet parsing to fail, which is what Batik does). Fixing this in full is non-trivial due to the design of Batik's That said, I have figured out a possible clean solution which I may implement in the future.
Documents are supposed to always have a However, I have committed a fix so this NPE should never happen again. |
Not sure if my comment made it into the PR before the change was committed. FWIW, the conditional around checking for import java.util.Objects;
Object o1 = null;
Object o2 = "aString";
String s;
s = Objects.toString(o1, "isNull"); // returns "isNull"
s = Objects.toString(o2, "isNull"); // returns "aString" |
Thanks for the suggestion, although it wasn't a PR but a direct commit to the repository. That said, if using |
Replicate
Produce a Mermaid diagram having the following input (see Mermaid live or Kroki, or the attached diagram.svg.txt):
Rasterize the SVG diagram using EchoSVG.
Expected
Diagram renders (at least partially). Here's how Inkscape renders the diagram:
Actual
The following exceptions are thrown:
org.w3c.dom.DOMException
: The "stroke" property does not support HSLCOLOR values.java.lang.NullPointerException
: Cannot invoke "io.sf.carte.echosvg.util.ParsedURL.toString()" because "uri" is nullThe first error seems like something that the DOM parser should issue a warning about, but not stop parsing. This is Inkscape's behaviour and it would be useful if there was an API option to indicate that parsing should try to continue until an unrecoverable error. Missing colours aren't the end of the world. See
CSSEngine.java
, line 1194:That eventually calls
AbstractValueFactory.java
, lines 59 to 63:Having a way to reduce all similar exceptions in this class to warnings, rather than an exception, with the ability to register a warning listener (no-op listener by default) would be useful.
Forcing calling classes to register an "exception handler" would be a viable alternative, and could look like:
That would leave the choice about whether to throw an exception up to the calling code.
The second error is a bug. When
uri
isnull
, callinguri.toString()
fails. See line 1202:The root cause is in
SVGOMStyleElement.java
, lines 133 to 139, where it is assumed that a base URI is set for the document. That's not necessarily true (e.g., an SVG file can be streamed from a generator that has no URI). I traced thenull
toAbstractNode.java
, line 435, which assigns the base URI todoc.getDocumentURI()
(for an element that has no attributes). This lets thenull
pass through.The simplest fix, of course, is not to call
uri.toString()
whenuri
isnull
. A deeper fix would be to correct the assumption of a URI that always exists and define a fake URI that can be used when no URI is otherwise determined.The text was updated successfully, but these errors were encountered: