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


2nd year Computer Science
University of Sussex

===========================================================================
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".

Reply via email to