You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Art Welch <ar...@EASTPOINT.COM> on 2000/12/16 00:00:06 UTC

halfLeading calculation problem

I noticed a problem where setting the line-height attribute on a block did
not result in lines being produced with the specified height. For example
setting a line-height="0.17in" was resulting in lines of approximately
0.15in. I believe that I know why this is happening. In
BlockArea.BlockArea() the half leading is set as follows:

	  this.halfLeading = (lineHeight - fontState.getFontSize())/2;

This is then used in BlockArea.addLineArea() as follows:

    public void addLineArea(LineArea la) {
	if (!la.isEmpty()) {
	    this.addDisplaySpace(this.halfLeading);
	    int size = la.getHeight();
	    this.addChild(la);
	    this.increaseHeight(size);
	    this.addDisplaySpace(this.halfLeading);
	}
    }

I think that the idea hear is that the LineArea would have height equal to
the font size. If this were the case then halfLeading + la.getHeight() +
halfLeading would indeed add up to lineHeight. Unfortunately
LineArea.getHeight() is coded as follows:

    public int getHeight() {
	return this.allocationHeight;
    }

and the allocationHeight is set in the constructor by the following code:

	this.nominalGlyphHeight = fontState.getAscender() -
	    fontState.getDescender(); 
	
	...
	
	this.allocationHeight = this.nominalGlyphHeight;

So we see that the LineArea will return the font Ascender - Descender for
the Height. Using Courier (7pt) I have the following values:

	Font Size	7048
	Ascender	4433
	Descender	-1106

These yield Ascender - Descender = 5539 which is of course not equal to the
Font Size of 7048.

Assuming that there is not another problem, like the Ascender or Descender,
or Font Size being calculated incorrectly, I submit that one of the height
calculations must be incorrect. Can we fix this? Does anyone know which one
(if either) is correct? My guess would be LineArea is correct, but I would
need to do a bit more research to be certain.

Thank You,
Art