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 13:04:12 UTC

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

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

          Priority: P2
            Bug ID: 53962
          Assignee: batik-dev@xmlgraphics.apache.org
           Summary: Text decoration in text tag is not painted properly
                    when using different font sizes
          Severity: minor
    Classification: Unclassified
                OS: Linux
          Reporter: m.s.ganzeboom@rug.nl
          Hardware: PC
            Status: NEW
           Version: 1.8
         Component: GVT Text
           Product: Batik

Created attachment 29444
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29444&action=edit
SVG file showing the incorrect text decoration positioning with different font
sizes

While testing a custom text editing component for the application I'm working
on using Batik, I found that underline, overline and line-through text
decorations aren't positioned correctly when different font sizes are used.

I observed this behaviour when using a text tag embedded with tspan tags. 

Steps to reproduce:
1. Do a fresh checkout of the trunk sources (at time of writing: 1378739)
2. Download this bug report's SVG attachment.
3. Start the Squiqqle browser from the checked out sources.
4. Load the attachment in the Squiqqle browser.

Actual results:
As the attachment shows, both text tags contain two words displayed in a
different font size. Both have underline, overline and line-through
decorations. For the first word the y-position and thickness of the lines is
calculated correctly. However, for the second word (which is in a different
font size) the lines are positioned on the same y value and have the same
thickness.

Expected results:
The 'line' text decorations should have been positioned on different y values,
each corresponding to their font size. Dito for the line thickness.

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


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

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53962

--- Comment #2 from Mario <m....@rug.nl> ---
Created attachment 29446
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29446&action=edit
Patch to fix the incorrect text decorations when using different font sizes

The patch to apply to revision 1378739.

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


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

Posted by bu...@apache.org.
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