diff options
author | Simon Steiner <ssteiner@apache.org> | 2021-09-01 06:06:25 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2021-09-01 06:06:25 +0000 |
commit | b23edd0f37ef50c18f0a91d544417ef7e7b3561f (patch) | |
tree | 6a1430dd7e3327d9567cd499ff6d83003e1815b0 /fop-core/src | |
parent | 7edce5dd5880f3c8df10a37079bbcbc83063d238 (diff) | |
download | xmlgraphics-fop-b23edd0f37ef50c18f0a91d544417ef7e7b3561f.tar.gz xmlgraphics-fop-b23edd0f37ef50c18f0a91d544417ef7e7b3561f.zip |
FOP-3024: Make sure even number of bytes are output per trn for AFP TTF
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1892774 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src')
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/afp/fonts/FopCharacterSet.java | 2 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/afp/fonts/FopCharacterSet.java b/fop-core/src/main/java/org/apache/fop/afp/fonts/FopCharacterSet.java index 9d53cc7ea..dec45919f 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/fonts/FopCharacterSet.java +++ b/fop-core/src/main/java/org/apache/fop/afp/fonts/FopCharacterSet.java @@ -51,7 +51,7 @@ public class FopCharacterSet extends CharacterSet { public FopCharacterSet(String codePage, String encoding, String name, Typeface charSet, AFPResourceAccessor accessor, AFPEventProducer eventProducer) { - super(codePage, encoding, CharacterSetType.SINGLE_BYTE, name, accessor, eventProducer); + super(codePage, encoding, CharacterSetType.DOUBLE_BYTE, name, accessor, eventProducer); this.charSet = charSet; } diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java index 9c6b51873..992436b43 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java @@ -240,7 +240,7 @@ public class AFPTrueTypeTestCase { @Test public void testAFPPainterWidths() throws IFException, IOException { - String s = getAFPPainterWidths(true); + String s = getAFPPainterWidths(true, "abcdefghijklmno"); Assert.assertTrue(s, s.contains("DATA PRESENTATION_TEXT AMB AMI 0 SCFL SVI TRN a AMI" + " 9 TRN b AMI 29 TRN c AMI 59 TRN d AMI 99 TRN e AMI 149 TRN f AMI 209 TRN g AMI 24 TRN h AMI 105 TRN" + " i AMI 196 TRN j AMI 42 TRN k AMI 153 TRN l AMI 19 TRN m AMI 151 TRN n AMI 38 TRN o AMI 190")); @@ -248,11 +248,23 @@ public class AFPTrueTypeTestCase { @Test public void testAFPPainterWidthsNoPositionByChar() throws IFException, IOException { - String s = getAFPPainterWidths(false); + String s = getAFPPainterWidths(false, "abcdefghijklmno"); Assert.assertTrue(s, s.contains("DATA PRESENTATION_TEXT AMB AMI 0 SCFL SVI TRN abcdefghijklmno")); } - private String getAFPPainterWidths(boolean positionByChar) throws IFException, IOException { + @Test + public void testAFPPainterWidthsNoPositionByCharLongText() throws IFException, IOException { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 30; i++) { + sb.append("test "); + } + String s = getAFPPainterWidths(false, sb.toString()); + Assert.assertTrue(s, s.contains("DATA PRESENTATION_TEXT AMB AMI 0 SCFL SVI TRN test test test test test test " + + "test test test test test test test test test test test test test test test test test test test t " + + "TRN est test test test test")); + } + + private String getAFPPainterWidths(boolean positionByChar, String text) throws IFException, IOException { AFPDocumentHandler afpDocumentHandler = mock(AFPDocumentHandler.class); when(afpDocumentHandler.getPaintingState()).thenReturn(new AFPPaintingState()); when(afpDocumentHandler.getResourceManager()).thenReturn(new AFPResourceManager(null)); @@ -264,7 +276,7 @@ public class AFPTrueTypeTestCase { AFPPainter afpPainter = new MyAFPPainter(afpDocumentHandler, positionByChar); afpPainter.setFont("any", "normal", 400, null, 12000, Color.BLACK); - afpPainter.drawText(0, 0, 0, 0, null, "abcdefghijklmno"); + afpPainter.drawText(0, 0, 0, 0, null, text); ByteArrayOutputStream bos = new ByteArrayOutputStream(); po.writeToStream(bos); |