Hi! This is a followup from the batik-user mailinglist.
Background: We are using batik to rasterize SVG for browsers
without SVG support. To do this, we need to produce high-
quality, non-antialiased text (we are using small palettes)
like Arial,PLAIN,10pt.
After getting poor results (see attachement) we posted a
question to batik-user, and Vincent Hardy replied:
"I think what is happening is that Adobe is using font hinting to handle
small font sizes and we are not. Therefore, they are giving a better
result at small font sizes. The best option is to rasterize with
antialiasing on, but I do not know of any good way to reduce the blurring
that
this causes."
----
Ok, so the solution seems to make a dirty-hack, creating a batik-extension
(ie. <myns:mytext>) that ignores styling (and scaling) and uses standard
AWT font-rendering.
So I sat down over the weekend and tried to understand the pipeline used to
render text i Batik. After a few dead-ends (like TextLayoutAdapter),
i found
AWTGVTGlyphVector.draw(Graphics2D,GraphicsNodeRenderContext,AttributedCharac
terIterator).
The problem seems to be the Shape s =(glyph).getOutline(),
graphics2D.fill(s)
method used; so using TextLayout.draw(graphics2D,x,y) should do it.
Then it started to get interesting:
With a AWT TextLayout draw()ing on the provided Graphics2D produces
the samt bad results!
Thinking that something (antialiasing) happend after my draw(), I created a
BufferedImage, drew my TextLayout on it. And drew my BufferedImage to
Batik´s Graphics2D. It worked.
Clearly, it must be my inexprience with AWT, so I tried to reproduce
the the bad text quality on "my" BufferedImage. Using the same
FontRenderContext,AffineTransform and RenderingHints the
text is still ok.
Can anybody explain this? It´s making my crazy! The idea of
rendering all my elements to small BufferedImages and drawing
them to the final image is sickening.
Or is there a better approach than writing a extension?
/ Andreas Bielk
/**********************************************************
C o d e S e n s e A B
Marinens väg 30, SE-136 40 Haninge, Sweden
Office: +46 (0)8 - 707 32 30 GSM: +46 (0)70 - 532 92 01
http://www.codesense.com
***********************************************************/
(PGP public key available at: search.keyserver.net)
batik11.png
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]