aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core/src
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2023-08-02 09:01:31 +0100
committerSimon Steiner <ssteiner@apache.org>2023-08-02 09:01:31 +0100
commit0ec06d934b8671dcdde338aa5e5605cf26fddf85 (patch)
treeb8572efd9672db33a469b7175ef1669f7b3fef42 /fop-core/src
parentc49a080dc64d39ece4a0aba6f3ad20af56a4ac25 (diff)
downloadxmlgraphics-fop-0ec06d934b8671dcdde338aa5e5605cf26fddf85.tar.gz
xmlgraphics-fop-0ec06d934b8671dcdde338aa5e5605cf26fddf85.zip
FOP-2985: Revert AFP reset character spacing
Diffstat (limited to 'fop-core/src')
-rw-r--r--fop-core/src/main/java/org/apache/fop/afp/ptoca/PtocaBuilder.java20
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java1
-rw-r--r--fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java46
3 files changed, 24 insertions, 43 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/afp/ptoca/PtocaBuilder.java b/fop-core/src/main/java/org/apache/fop/afp/ptoca/PtocaBuilder.java
index 63026ee84..084ba5daa 100644
--- a/fop-core/src/main/java/org/apache/fop/afp/ptoca/PtocaBuilder.java
+++ b/fop-core/src/main/java/org/apache/fop/afp/ptoca/PtocaBuilder.java
@@ -361,26 +361,6 @@ public abstract class PtocaBuilder implements PtocaConstants {
}
/**
- * Resets the intercharacter adjustment (additional increment or decrement between graphic
- * characters) to 0.
- * <p>
- * This is a modal control sequence.
- *
- * @throws IOException if an I/O error occurs
- */
- public void resetInterCharacterAdjustment() throws IOException {
- if (0 == this.currentInterCharacterAdjustment) {
- return;
- }
- newControlSequence();
- writeShort(0); //Increment
- writeBytes(0); // Direction
- commit(chained(SIA));
-
- this.currentInterCharacterAdjustment = 0;
- }
-
- /**
* A control sequence is a sequence of bytes that specifies a control
* function. A control sequence consists of a control sequence introducer
* and zero or more parameters. The control sequence can extend multiple
diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java b/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java
index 66ada9fac..9a4a7b93e 100644
--- a/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java
+++ b/fop-core/src/main/java/org/apache/fop/render/afp/AFPPainter.java
@@ -1102,7 +1102,6 @@ public class AFPPainter extends AbstractIFPainter<AFPDocumentHandler> {
}
}
}
- builder.resetInterCharacterAdjustment();
flushText(builder, sb, charSet);
if (pto != null) {
bytesAvailable = pto.getBytesAvailable();
diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java
index b396d6d67..92bf91edb 100644
--- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPPainterTestCase.java
@@ -24,6 +24,7 @@ import java.awt.Dimension;
import java.awt.Rectangle;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -44,8 +45,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.apache.commons.io.IOUtils;
-
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageException;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
@@ -63,6 +62,9 @@ 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.afp.parser.MODCAParser;
+import org.apache.fop.afp.parser.UnparsedStructuredField;
+import org.apache.fop.afp.ptoca.PtocaConstants;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.events.Event;
@@ -212,36 +214,37 @@ public class AFPPainterTestCase {
+ "END DOCUMENT DOC00001\n");
}
- /**
- * Checks that letter spacing is reset to 0 after the relevant text block.
- */
@Test
- public void testLetterSpacingReset() throws Exception {
+ public void testLetterSpacing() throws Exception {
List<String> strings = new ArrayList<>();
strings.add("xxxx");
- InputStream inputStream = getDocResultInputStream(strings, 10000);
- byte[] bytes = IOUtils.toByteArray(inputStream);
- // The 134th byte is incremented by 5 to account for the 5 extra bytes inserted for the reset.
- Assert.assertEquals((byte)39, bytes[134]);
- // And these are the 5 reset bytes.
- Assert.assertEquals((byte)5, bytes[163]);
- Assert.assertEquals((byte)195, bytes[164]);
- Assert.assertEquals((byte)0, bytes[165]);
- Assert.assertEquals((byte)0, bytes[166]);
- Assert.assertEquals((byte)0, bytes[167]);
+ InputStream bis = getDocResultInputStream(strings, 10000);
+ MODCAParser parser = new MODCAParser(bis);
+ UnparsedStructuredField field;
+ while ((field = parser.readNextStructuredField()) != null) {
+ if (field.toString().contains("Data Presentation Text")) {
+ break;
+ }
+ }
+ DataInputStream data = new DataInputStream(new ByteArrayInputStream(field.getData()));
+ data.skip(13); //2 for controlInd
+ Assert.assertEquals(data.readByte(), 5); //len
+ Assert.assertEquals(data.readByte(), PtocaConstants.SIA | PtocaConstants.CHAIN_BIT); //functionType
+ Assert.assertEquals(data.readShort(), 33); //Increment
+ Assert.assertEquals(data.readByte(), 0); //Direction
+ data.skip(4); //varSpaceCharacterIncrement
+ //flushText:
+ Assert.assertEquals(data.readByte(), 2); //len
+ Assert.assertEquals(data.readByte(), PtocaConstants.TRN | PtocaConstants.CHAIN_BIT); //functionType
}
private String writeText(List<String> text) throws Exception {
- InputStream bis = getDocResultInputStream(text);
+ InputStream bis = getDocResultInputStream(text, 0);
StringBuilder sb = new StringBuilder();
new AFPParser(false).read(bis, sb);
return sb.toString();
}
- private static InputStream getDocResultInputStream(List<String> text) throws Exception {
- return getDocResultInputStream(text, 0);
- }
-
private static InputStream getDocResultInputStream(List<String> text, int letterSpacing) throws Exception {
FOUserAgent agent = FopFactory.newInstance(new URI(".")).newFOUserAgent();
IFContext context = new IFContext(agent);
@@ -266,7 +269,6 @@ public class AFPPainterTestCase {
afpPainter.drawText(0, 0, letterSpacing, 0, null, s);
}
doc.endDocument();
-
return new ByteArrayInputStream(outputStream.toByteArray());
}