diff options
author | Chris Bowditch <cbowditch@apache.org> | 2012-01-18 11:54:36 +0000 |
---|---|---|
committer | Chris Bowditch <cbowditch@apache.org> | 2012-01-18 11:54:36 +0000 |
commit | 39d7a6a55d17367986843d273cf79dcd6a9f5f97 (patch) | |
tree | 1d4e18b722fb71cc69858f32a18057d61de4910c /test/java/org/apache/fop | |
parent | fb1489b30e69043c94908c6bd6898d97c697a8b5 (diff) | |
download | xmlgraphics-fop-39d7a6a55d17367986843d273cf79dcd6a9f5f97.tar.gz xmlgraphics-fop-39d7a6a55d17367986843d273cf79dcd6a9f5f97.zip |
Bugzilla #51209:
SVG text in AFP creates miscoded GOCA text
Submitted by: Luis Bernardo
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1232845 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java/org/apache/fop')
-rw-r--r-- | test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java b/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java new file mode 100644 index 000000000..e986567f2 --- /dev/null +++ b/test/java/org/apache/fop/afp/goca/GraphicsCharacterStringTestCase.java @@ -0,0 +1,72 @@ +/*
+ * 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.
+ */
+package org.apache.fop.afp.goca;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.fop.afp.fonts.CharacterSet;
+import org.apache.fop.afp.fonts.CharacterSetBuilder;
+import org.apache.fop.fonts.Typeface;
+import org.junit.Before;
+import org.junit.Test;
+
+public class GraphicsCharacterStringTestCase {
+ private GraphicsCharacterString gcsCp500;
+ private GraphicsCharacterString gcsCp1146;
+ // consider the EBCDIC code page variants Cp500 and Cp1146
+ // the £ corresponds to byte 5B (position 91) in the CCSID 285 and CCSID 1146
+ // the $ corresponds to byte 5B (position 91) in the CCSID 500
+ private final String poundsText = "££££";
+ private final String dollarsText = "$$$$";
+ private final byte[] bytesToCheck = {(byte) 0x5b, (byte) 0x5b, (byte) 0x5b, (byte) 0x5b};
+
+ @Before
+ public void setUp() throws Exception {
+ CharacterSetBuilder csb = CharacterSetBuilder.getSingleByteInstance();
+ CharacterSet cs1146 = csb.build("C0H200B0", "T1V10500", "Cp1146",
+ Class.forName("org.apache.fop.fonts.base14.Helvetica").asSubclass(Typeface.class)
+ .newInstance(), null);
+ gcsCp1146 = new GraphicsCharacterString(poundsText, 0, 0, cs1146);
+ CharacterSet cs500 = csb.build("C0H200B0", "T1V10500", "Cp500",
+ Class.forName("org.apache.fop.fonts.base14.Helvetica").asSubclass(Typeface.class)
+ .newInstance(), null);
+ gcsCp500 = new GraphicsCharacterString(dollarsText, 0, 0, cs500);
+ }
+
+ @Test
+ public void testWriteToStream() throws IOException {
+ // check pounds
+ ByteArrayOutputStream baos1146 = new ByteArrayOutputStream();
+ gcsCp1146.writeToStream(baos1146);
+ byte[] bytes1146 = baos1146.toByteArray();
+ for (int i = 0; i < bytesToCheck.length; i++) {
+ assertEquals(bytesToCheck[i], bytes1146[6 + i]);
+ }
+ assertEquals(bytesToCheck.length + 6, bytes1146.length);
+ // check dollars
+ ByteArrayOutputStream baos500 = new ByteArrayOutputStream();
+ gcsCp500.writeToStream(baos500);
+ byte[] bytes500 = baos500.toByteArray();
+ for (int i = 0; i < bytesToCheck.length; i++) {
+ assertEquals(bytesToCheck[i], bytes500[6 + i]);
+ }
+ assertEquals(bytesToCheck.length + 6, bytes500.length);
+ }
+}
|