You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by bu...@apache.org on 2012/10/04 14:16:30 UTC

[Bug 53962] Text decoration in text tag is not painted properly when using different font sizes

https://issues.apache.org/bugzilla/show_bug.cgi?id=53962

--- Comment #1 from Mario <m....@rug.nl> ---
I reported this bug and also found the cause and a fix for it.

The cause lies in StrokingTextPainter.java in the methods paintDecorations(List
runs, Graphics2D, int) and getDecorationStrokeOutline(List runs, int). In these
methods the bounds of text decorations are calculated for each determined 'text
run'. Based on the surrounding code I assume that text runs in this context
basically mean groups of consecutive characters that share the same text
attributes (i.e. styling).

That calculation of text decoration bounds is done in a for loop in which the
last calculated y position and height are stored for later reference. Having
calculated the decoration bounds for the first text run, the y position and
height are stored for later and the text decoration is painted with those
values. When calculating the decoration for a second text run (or a third,
fourth, fifth... for that matter), the y position and height variables storing
the values for later are not updated and the values of the first run decoration
are used to paint it.

These same steps are used in both mentioned methods. Questions is why is this
so? Why are only the text decoration y position and height of the first run
stored for later? There is probably a reason, or isn't there?

My solution for this bug is to not use the variables storing the y position and
height for later, but to use the values straight out of the text run's layout
decoration bounds calculation (i.e. straight from the source and calculated a
new for every text run).

I've attached a patch which incorporates this solution.

As I made the patch, I came accross
StrokingTextPainter.getDecorationOutline(List, int) which is of similar nature
as the before mentioned methods. Maybe the solution needs to be applied there
as well, although I haven't run in any problems with that one yet.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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