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 2017/09/26 14:22:52 UTC

svn commit: r1809748 - in /xmlgraphics/fop/trunk/fop-core/src: main/java/org/apache/fop/fonts/type1/Type1FontLoader.java test/java/org/apache/fop/fonts/type1/Type1FontLoaderTestCase.java

Author: ssteiner
Date: Tue Sep 26 14:22:51 2017
New Revision: 1809748

URL: http://svn.apache.org/viewvc?rev=1809748&view=rev
Log:
FOP-2742: SVG to PS NPE/text missing when using PFM file

Added:
    xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/type1/Type1FontLoaderTestCase.java   (with props)
Modified:
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1FontLoader.java

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=1809748&r1=1809747&r2=1809748&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1FontLoader.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/type1/Type1FontLoader.java Tue Sep 26 14:22:51 2017
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts.type1;
 
+import java.awt.Rectangle;
 import java.awt.geom.RectangularShape;
 import java.io.IOException;
 import java.io.InputStream;
@@ -415,7 +416,10 @@ public class Type1FontLoader extends Fon
             returnFont.setFirstChar(pfm.getFirstChar());
             returnFont.setLastChar(pfm.getLastChar());
             for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) {
-                singleFont.setWidth(i, pfm.getCharWidth(i));
+                int cw = pfm.getCharWidth(i);
+                singleFont.setWidth(i, cw);
+                int[] bbox = pfm.getFontBBox();
+                singleFont.setBoundingBox(i, new Rectangle(bbox[0], bbox[1], cw, bbox[3]));
             }
             if (useKerning) {
                 returnFont.replaceKerningMap(pfm.getKerning());

Added: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/type1/Type1FontLoaderTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/type1/Type1FontLoaderTestCase.java?rev=1809748&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/type1/Type1FontLoaderTestCase.java (added)
+++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/type1/Type1FontLoaderTestCase.java Tue Sep 26 14:22:51 2017
@@ -0,0 +1,61 @@
+/*
+ * 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.fonts.type1;
+
+import java.awt.Rectangle;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.commons.io.IOUtils;
+
+import org.apache.fop.apps.io.ResourceResolverFactory;
+import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.EmbeddingMode;
+import org.apache.fop.fonts.EncodingMode;
+import org.apache.fop.fonts.FontLoader;
+import org.apache.fop.fonts.FontUris;
+
+public class Type1FontLoaderTestCase {
+    @Test
+    public void testBoundingBox() throws IOException {
+        File pfb = new File("test/resources/fonts/type1/c0419bt_.pfb");
+        File pfbNoAFM = File.createTempFile("fop", "pfb");
+        File pfm = File.createTempFile("fop", "pfm");
+        try {
+            IOUtils.copy(new FileInputStream(pfb), new FileOutputStream(pfbNoAFM));
+
+            FileOutputStream fos = new FileOutputStream(pfm);
+            fos.write(new byte[512]);
+            fos.close();
+
+            FontUris fontUris = new FontUris(pfbNoAFM.toURI(), null, null, pfm.toURI());
+            CustomFont x = FontLoader.loadFont(fontUris, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, true, true,
+                    ResourceResolverFactory.createDefaultInternalResourceResolver(new File(".").toURI()), false, false);
+            Assert.assertEquals(x.getBoundingBox(0, 12).getBounds(), new Rectangle(-240, -60, 0, 60));
+        } finally {
+            pfbNoAFM.delete();
+            pfm.delete();
+        }
+    }
+}

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



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