You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ss...@apache.org on 2020/12/15 13:28:47 UTC

svn commit: r1884462 - in /xmlgraphics/fop/trunk/fop-core/src: main/java/org/apache/fop/render/afp/AFPPainter.java test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java test/java/org/apache/fop/render/afp/AFPPainterTestCase.java

Author: ssteiner
Date: Tue Dec 15 13:28:47 2020
New Revision: 1884462

URL: http://svn.apache.org/viewvc?rev=1884462&view=rev
Log:
FOP-2989: Missing text in AFP output when using high resolution

Added:
    xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java   (with props)
Modified:
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java
    xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java?rev=1884462&r1=1884461&r2=1884462&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java Tue Dec 15 13:28:47 2020
@@ -915,7 +915,7 @@ public class AFPPainter extends Abstract
         final Font font;
         final AFPFont afpFont;
         final CharacterSet charSet;
-        final PresentationTextObject pto;
+        PresentationTextObject pto;
 
         private DefaultPtocaProducer(int x, int y,
                                       final int letterSpacing, final int wordSpacing, final int[][] dp,
@@ -960,7 +960,12 @@ public class AFPPainter extends Abstract
                     page.endPresentationObject();
                 }
                 pto = page.getPresentationTextObject();
-                pto.createControlSequences(this);
+                boolean success = pto.createControlSequences(this);
+                if (!success) {
+                    page.endPresentationObject();
+                    pto = page.getPresentationTextObject();
+                    pto.createControlSequences(this);
+                }
             } catch (IOException ioe) {
                 throw new IFException("I/O error in drawText()", ioe);
             }

Added: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java?rev=1884462&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java (added)
+++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java Tue Dec 15 13:28:47 2020
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+package org.apache.fop.afp.fonts;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.fop.fonts.Font;
+
+public class OutlineFontTestCase {
+    @Test
+    public void testWidth() {
+        CharacterSet characterSet = getCharacterSet();
+        OutlineFont outlineFont = new OutlineFont(null, true, characterSet, null);
+        Font font = new Font(null, null, outlineFont, 26000);
+        Assert.assertEquals(font.getWidth(' '), 0);
+    }
+
+    public static CharacterSet getCharacterSet() {
+        CharacterSet characterSet = new CharacterSet(null, "utf-8", CharacterSetType.SINGLE_BYTE, "", null, null);
+        characterSet.addCharacterSetOrientation(new CharacterSetOrientation(0, 0, 0, 0));
+        return characterSet;
+    }
+}

Propchange: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/fonts/OutlineFontTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java?rev=1884462&r1=1884461&r2=1884462&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java Tue Dec 15 13:28:47 2020
@@ -57,6 +57,7 @@ import org.apache.fop.afp.AFPPaintingSta
 import org.apache.fop.afp.AFPResourceManager;
 import org.apache.fop.afp.fonts.CharacterSet;
 import org.apache.fop.afp.fonts.CharactersetEncoder;
+import org.apache.fop.afp.fonts.OutlineFontTestCase;
 import org.apache.fop.afp.fonts.RasterFont;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FopFactory;
@@ -248,14 +249,45 @@ public class AFPPainterTestCase {
         documentHandler.startDocument();
         documentHandler.startPage(0, "", "", new Dimension());
         AFPPainter afpPainter = new AFPPainter(documentHandler);
-        int style = Constants.EN_DOTTED;
-        BorderProps.Mode mode = BorderProps.Mode.COLLAPSE_OUTER;
-        Color color = ColorUtil.parseColorString(ua, "fop-rgb-icc(0.5019608,0.5019608,0.5019608,#CMYK,,0,0,0,0.5)");
-        int borderWidth = 500;
-        int radiusStart = 0;
-        int radiusEnd = 0;
-        BorderProps border1 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
-        afpPainter.drawBorderRect(new Rectangle(0, 0, 552755, 16090), null, border1, null, null, Color.WHITE);
+        drawBorder(afpPainter, ua);
+        documentHandler.endDocument();
+
+        InputStream bis = new ByteArrayInputStream(os.toByteArray());
+        StringBuilder sb = new StringBuilder();
+        new AFPParser(false).read(bis, sb);
+        Assert.assertEquals(sb.toString(), "BEGIN DOCUMENT DOC00001\n"
+                + "BEGIN PAGE PGN00001\n"
+                + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n"
+                + "DESCRIPTOR PAGE\n"
+                + "MIGRATION PRESENTATION_TEXT\n"
+                + "END ACTIVE_ENVIRONMENT_GROUP AEG00001\n"
+                + "BEGIN PRESENTATION_TEXT PT000001\n"
+                + "DATA PRESENTATION_TEXT\n"
+                + "END PRESENTATION_TEXT PT000001\n"
+                + "BEGIN PRESENTATION_TEXT PT000002\n"
+                + "DATA PRESENTATION_TEXT\n"
+                + "END PRESENTATION_TEXT PT000002\n"
+                + "END PAGE PGN00001\n"
+                + "END DOCUMENT DOC00001\n");
+    }
+
+    @Test
+    public void testDrawBorderRectAndText() throws IFException, PropertyException, IOException {
+        FOUserAgent ua = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent();
+        AFPDocumentHandler documentHandler = new AFPDocumentHandler(new IFContext(ua));
+        documentHandler.setResolution(480);
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        documentHandler.setResult(new StreamResult(os));
+        documentHandler.startDocument();
+        documentHandler.startPage(0, "", "", new Dimension());
+        AFPPainter afpPainter = new AFPPainter(documentHandler);
+        setFont(documentHandler, afpPainter);
+        drawBorder(afpPainter, ua);
+        StringBuilder text = new StringBuilder();
+        for (int i = 0; i < 4770; i++) {
+            text.append("a");
+        }
+        afpPainter.drawText(0, 0, 0, 0, null, text.toString());
         documentHandler.endDocument();
 
         InputStream bis = new ByteArrayInputStream(os.toByteArray());
@@ -273,7 +305,32 @@ public class AFPPainterTestCase {
                 + "BEGIN PRESENTATION_TEXT PT000002\n"
                 + "DATA PRESENTATION_TEXT\n"
                 + "END PRESENTATION_TEXT PT000002\n"
+                + "BEGIN PRESENTATION_TEXT PT000003\n"
+                + "DATA PRESENTATION_TEXT\n"
+                + "END PRESENTATION_TEXT PT000003\n"
                 + "END PAGE PGN00001\n"
                 + "END DOCUMENT DOC00001\n");
     }
+
+    private void setFont(AFPDocumentHandler doc, AFPPainter afpPainter) throws IFException {
+        FontInfo fi = new FontInfo();
+        fi.addFontProperties("", Font.DEFAULT_FONT);
+        RasterFont rf = new RasterFont("", true);
+        CharacterSet cs = OutlineFontTestCase.getCharacterSet();
+        rf.addCharacterSet(12000, cs);
+        fi.addMetrics("", rf);
+        doc.setFontInfo(fi);
+        afpPainter.setFont("any", "normal", 400, "", 12000, Color.BLACK);
+    }
+
+    private void drawBorder(AFPPainter afpPainter, FOUserAgent ua) throws IFException, PropertyException {
+        int style = Constants.EN_DOTTED;
+        BorderProps.Mode mode = BorderProps.Mode.COLLAPSE_OUTER;
+        Color color = ColorUtil.parseColorString(ua, "fop-rgb-icc(0.5019608,0.5019608,0.5019608,#CMYK,,0,0,0,0.5)");
+        int borderWidth = 500;
+        int radiusStart = 0;
+        int radiusEnd = 0;
+        BorderProps border1 = new BorderProps(style, borderWidth, radiusStart, radiusEnd, color, mode);
+        afpPainter.drawBorderRect(new Rectangle(0, 0, 552755, 16090), null, border1, null, null, Color.WHITE);
+    }
 }



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