Bug 16237 - superscripts and subscipts are placed too high / too low
Summary: superscripts and subscipts are placed too high / too low
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: page-master/layout (show other bugs)
Version: 0.20.4
Hardware: All All
: P3 minor
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-19 13:36 UTC by Volker Reichel
Modified: 2012-04-01 06:56 UTC (History)
0 users



Attachments
diff file which corrects this bug (336 bytes, patch)
2003-01-19 13:37 UTC, Volker Reichel
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichel 2003-01-19 13:36:25 UTC
Using "super" / "sub" in property vertical-align will place the characters
too high / too low. This is due to a minor mistake in class LineArea.
In method verticalAlign() the offset of the super/subscript is computed by
taking 2/3 of ascender for the choosen font. The value which should be used
must be 1/3 because you want to get a 2/3 overlap with the text before/after.

    
    /**
     * Balance (vertically) the inline areas within this line.
     */
    public void verticalAlign() {
        int superHeight = -this.placementOffset;
        int maxHeight = this.allocationHeight;
        Enumeration e = children.elements();
        while (e.hasMoreElements()) {
            Box b = (Box)e.nextElement();
            if (b instanceof InlineArea) {
                InlineArea ia = (InlineArea)b;
                if (ia instanceof WordArea) {
                    ia.setYOffset(placementOffset);
                }
                if (ia.getHeight() > maxHeight) {
                    maxHeight = ia.getHeight();
                }
                int vert = ia.getVerticalAlign();
                if (vert == VerticalAlign.SUPER) {
                    int fh = fontState.getAscender();
                    // was: ia.setYOffset((int)(placementOffset - (2.0 * fh / 
3.0)));
                    ia.setYOffset((int)(placementOffset - (fh / 3.0)));
                } else if (vert == VerticalAlign.SUB) {
                    int fh = fontState.getAscender();
                    // was: ia.setYOffset((int)(placementOffset + (2.0 * fh / 
3.0)));
                    ia.setYOffset((int)(placementOffset + (fh / 3.0)));
                }
Comment 1 Volker Reichel 2003-01-19 13:37:09 UTC
Created attachment 4488 [details]
diff file which corrects this bug
Comment 2 Christian Geisert 2003-01-20 15:21:42 UTC
Thanks for your contribution but I would rather not apply it to the
maintenance branch because there are quite a few stylesheets out there
which use vertical-align and this patch would probably make the documents
look wrong (even if it corrects vertical-align)

Of course we will consider this for the redesign.
Comment 3 Pascal Sancho 2007-10-23 07:56:03 UTC
Bug fixed in latest Trunk (rev 584703), and probably in FOP 0.94 and earlier
0.9x versions (see previous comment).
Comment 4 Glenn Adams 2012-04-01 06:56:25 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed