Mike Hearn created BATIK-1323:
---------------------------------

             Summary: Batik should default to 
shape-rendering="geometricPrecision" on clip paths
                 Key: BATIK-1323
                 URL: https://issues.apache.org/jira/browse/BATIK-1323
             Project: Batik
          Issue Type: Improvement
            Reporter: Mike Hearn


Batik does not anti-alias clips even when anti-aliasing is on in the rendering 
hints. This causes rendered outputs to look worse than competing renderers. 
When I first saw this I felt sure it must be a bug, because librsvg doesn't do 
this and because other parts of the rendered image _did_ have anti-aliasing. 

However, after 90 minutes debugging and searching JIRA, I found that in fact 
this is deliberate. Batik defaults shape-rendering to "optimizeForSpeed", not 
"geometricPrecision" (SVGClipPathElementBridge:111), apparently with no global 
way to override this. The decision appears to date from 2005 and has been 
reported as a bug several times since.

The SVG spec apparently allows renderers to make up their own defaults here, so 
Batik is not "wrong" exactly. However I was confused, because Mozilla DevDocs 
says:

[https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering]

"This value indicates that the user agent shall make appropriate tradeoffs to 
balance speed, crisp edges and geometric precision, but {*}with geometric 
precision given more importance than speed and crisp edges{*}."

i.e. this implies that renderers do normally prefer quality over speed. Also I 
tried shape-rendering but accidentally applied it to the clipped shape instead 
of the clip itself, and then it had no impact.

I think most people won't debug this, if they notice aliasing in the output 
image. They'll just assume Batik is buggy and maybe switch to another renderer. 
That was my plan if I couldn't fix it within a few hours of debugging. 
Fortunately, the fix is easy in my case because I control the SVG being 
rendered. For other people it would be not so easy.

Suggestion: if "hints" is null in that part of the code, default to the 
rendering hints of the root element or something else where AA settings are 
probably configured. Don't simply default to useAA=false if the shape-rendering 
property is missing.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-h...@xmlgraphics.apache.org

Reply via email to