From f54e6a380663699f96c5b6730a138f66aa8c75de Mon Sep 17 00:00:00 2001 From: Glenn Adams Date: Thu, 12 Apr 2012 17:31:41 +0000 Subject: [PATCH] Take leading derived space before/after into account when computing rows for TXT renderer. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1325394 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/trunk/output.xml | 6 +++--- .../org/apache/fop/render/txt/TXTRenderer.java | 15 +++++++++------ status.xml | 9 ++++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index 8597ab787..65a09dde5 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -1337,8 +1337,8 @@ Note that the value of the encoding attribute in the example is the double-byte

@@ -1388,4 +1388,4 @@ Note that the value of the encoding attribute in the example is the double-byte
- \ No newline at end of file + diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index 6c58561a8..dd3d883f6 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -72,6 +72,9 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { /** Buffer for background and images. */ private StringBuffer[] decoData; + /** Leading of line containing Courier font size of 10pt. */ + public static final int LINE_LEADING = 1070; + /** Height of one symbol in Courier font size of 10pt. */ public static final int CHAR_HEIGHT = 7860; @@ -192,7 +195,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { */ protected void renderText(TextArea area) { int col = Helper.ceilPosition(this.currentIPPosition, CHAR_WIDTH); - int row = Helper.ceilPosition(this.currentBPPosition, CHAR_HEIGHT); + int row = Helper.ceilPosition(this.currentBPPosition - LINE_LEADING, CHAR_HEIGHT + 2*LINE_LEADING); String s = area.getText(); @@ -216,7 +219,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { double height = bounds.getHeight(); pageWidth = Helper.ceilPosition((int) width, CHAR_WIDTH); - pageHeight = Helper.ceilPosition((int) height, CHAR_HEIGHT); + pageHeight = Helper.ceilPosition((int) height, CHAR_HEIGHT + 2*LINE_LEADING); // init buffers charData = new StringBuffer[pageHeight]; @@ -460,9 +463,9 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { */ public void renderImage(Image image, Rectangle2D pos) { int x1 = Helper.ceilPosition(currentIPPosition, CHAR_WIDTH); - int y1 = Helper.ceilPosition(currentBPPosition, CHAR_HEIGHT); + int y1 = Helper.ceilPosition(currentBPPosition - LINE_LEADING, CHAR_HEIGHT + 2*LINE_LEADING); int width = Helper.ceilPosition((int) pos.getWidth(), CHAR_WIDTH); - int height = Helper.ceilPosition((int) pos.getHeight(), CHAR_HEIGHT); + int height = Helper.ceilPosition((int) pos.getHeight(), CHAR_HEIGHT + 2*LINE_LEADING); fillRect(x1, y1, width, height, IMAGE_CHAR); } @@ -559,9 +562,9 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { protected void drawBackAndBorders(Area area, float startx, float starty, float width, float height) { bm.setWidth(Helper.ceilPosition(toMilli(width), CHAR_WIDTH)); - bm.setHeight(Helper.ceilPosition(toMilli(height), CHAR_HEIGHT)); + bm.setHeight(Helper.ceilPosition(toMilli(height), CHAR_HEIGHT + 2*LINE_LEADING)); bm.setStartX(Helper.ceilPosition(toMilli(startx), CHAR_WIDTH)); - bm.setStartY(Helper.ceilPosition(toMilli(starty), CHAR_HEIGHT)); + bm.setStartY(Helper.ceilPosition(toMilli(starty), CHAR_HEIGHT + 2*LINE_LEADING)); super.drawBackAndBorders(area, startx, starty, width, height); } diff --git a/status.xml b/status.xml index 105b80fbd..df13b8fe6 100644 --- a/status.xml +++ b/status.xml @@ -62,9 +62,12 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> - - A global setting to wrap F11 images in page segments. - + + Take leading derived space before/after into account when computing rows for TXT renderer. + + + Support list-block in marker, thus preventing NPE. + Support list-block in marker, thus preventing NPE. -- 2.39.5