On Mon, Jun 26, 2006 at 11:33:32PM -0700, Doug Felt @ Sun wrote:
> Chris Nokleberg wrote:
> >This also means that the line breaking algorithm has to run twice,
> >for each of the AttributedStrings (there is no way to duplicate a
> >TextLayout but tell it to use different styles).
> >
> I'm not sure why you need to duplicate the TextLayout at that level.
> Once you have a GlyphVector can't the proxy just use it to render
> however it wants?  The only problem I see would be if you needed to
> rebuild the glyphvector to use a different font or different number of
> glyphs--all bets are off in that case.

In this case, where I overload the FOREGROUND attribute to signal the
shadow style runs, the issue is that I may sometimes need the FOREGROUND
to represent an actual foreground color :-). For example, I may have a
string where every letter is a different color, but every other word has
a shadow. I can't simply dedicate one attribute as a sideband channel,
because I may have to use it for its intended purpose. So I end up
having to generate an almost identical TextLayout just to carry the
shadow runs.

BTW it's probably obvious but I use FOREGROUND/BACKGROUND because you
can use any int as the value and it does not affect the metrics of the
generated GlyphVectors

> There is a slightly cleaner hack you might try if you're willing to
> forgo styled text streaming and some rendering performance.  Since the
> foreground and background attributes use Paint as a value, and this is
> an interface, you can use any subclass of Paint you want, including one
> you build.  You can then provide your own implementation of Paint, hang
> any data you want off it, and then delegate Paint's one API method to a
> standard Color or other Paint subclass that you keep as a member.  I
> suspect (I'm not sure) our rendering loops are optimized for our
> standard Paint implementations, and using your own would cause slower
> software loops to be used.

This is a great suggestion, I'm not sure why I didn't see it before. I
must have thought that the TextAttribute FOREGROUND and BACKGROUND
attributes only tooks Colors and not a Paints, although that would be
silly. I think it will take care of the multiple TextLayout issue
too. The performance should not a problem, because the proxy can
"unwrap" the Paint before passing it along to the underlying
Graphics2D. The key is just to have a place to hang data from.

Thanks!
Chris

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