svn commit: r1811944 - in /xmlgraphics/fop/trunk/fop-core/src: main/java/org/apache/fop/fonts/LazyFont.java test/java/org/apache/fop/fonts/LazyFontTestCase.java

[email protected]
Newsgroups gmane.text.xml.fop.cvs
Message-ID <[email protected]>
Author: ssteiner
Date: Thu Oct 12 11:44:13 2017
New Revision: 1811944

URL: http://svn.apache.org/viewvc?rev=1811944&view=rev
Log:
FOP-2752: Show name of font file on error

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

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java?rev=1811944&r1=1811943&r2=1811944&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java Thu Oct 12 11:44:13 2017
@@ -19,7 +19,6 @@
 
 package org.apache.fop.fonts;
 import java.awt.Rectangle;
-import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.List;
@@ -31,7 +30,6 @@ import org.xml.sax.InputSource;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.io.InternalResourceResolver;
 import org.apache.fop.complexscripts.fonts.Positionable;
 import org.apache.fop.complexscripts.fonts.Substitutable;
@@ -124,15 +122,14 @@ public class LazyFont extends Typeface i
                 if (realFont instanceof FontDescriptor) {
                     realFontDescriptor = (FontDescriptor) realFont;
                 }
-            } catch (FOPException fopex) {
-                log.error("Failed to read font metrics file " + fontUris.getMetrics(), fopex);
+            } catch (RuntimeException e) {
+                String error = "Failed to read font file " + fontUris.getEmbed();
+                throw new RuntimeException(error, e);
+            } catch (Exception e) {
+                String error = "Failed to read font file " + fontUris.getEmbed();
+                log.error(error, e);
                 if (fail) {
-                    throw new RuntimeException(fopex);
-                }
-            } catch (IOException ioex) {
-                log.error("Failed to read font metrics file " + fontUris.getMetrics(), ioex);
-                if (fail) {
-                    throw new RuntimeException(ioex);
+                    throw new RuntimeException(error, e);
                 }
             }
             realFont.setEventListener(this.eventListener);

Added: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java?rev=1811944&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java (added)
+++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java Thu Oct 12 11:44:13 2017
@@ -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.fonts;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class LazyFontTestCase {
+    @Test
+    public void testFontError() throws URISyntaxException {
+        FontUris fontUris = new FontUris(new URI("test"), null);
+        LazyFont lazyFont = new LazyFont(new EmbedFontInfo(fontUris, true, true, null, null), null, true);
+        String ex = null;
+        try {
+            lazyFont.getAscender();
+        } catch (RuntimeException e) {
+            ex = e.getMessage();
+        }
+        Assert.assertEquals(ex, "Failed to read font file test");
+    }
+}

Propchange: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.