En rponse Sampsa Mikael Sojakka [EMAIL PROTECTED]:
I am also working on a program which need complex custom layout of text.
(Desktop Publishing).
I currently use a class which cache a glyphvector (per glyph!) and its basic
fontmetrics. The creation of the glyphvector is pretty slow but the rendering
is fast enough to type while displaying 2000 glyphs. (faster than drawstring()
anyway).
Emmanuel.
And drawing this Glyphvector
using the Graphics2D method drawGlyphVector() is very slow.
Hi,
I am currently in the process of writing a light HTML renderer. In
order
to accomplish this I obviously need to support custom layout of text
rendered in multiple Fonts and varying sizes.
My original idea was to use the Flyweight design pattern of caching
glyphs and using references to these glyphs during the layout and
positioning of the characters in the text. Unfortunately the Java API
does not allow me to access individual Glyph objects. Instead, I can
use
createGlyphVector() in java.awt.Font to get a GlyphVector that
encompasses the glyphs. The problem is that drawing this Glyphvector
using the Graphics2D method drawGlyphVector() is very slow. In fact it
is so slow that it is hard to imagine any practical use for this
method
at all. This is bewildering since the Java API documentation claims
that
a GlyphVector "is the fastest method to present the visual
representation of characters to a user".
I have also experimented with the standard drawString() method which
achieves acceptable performance iff no bound calculations are
performed.
Unfortunately I need these bound calculations in order to handle the
custom layout management of text in various fonts...
So the question is:
Does anyone know of a fast way of rendering styled text in Java? How
do
the classes in javax.swing.text and javax.swing.text.html handle this?
Should I cache bound calculations for individual rendered characters
or
is there a better way I'm not seeing?
Cheers,
Sampsa Sojakka
===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".