diff options
author | Simon Steiner <ssteiner@apache.org> | 2017-10-12 11:44:13 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2017-10-12 11:44:13 +0000 |
commit | d81e5851f7c083b4bd86867dee19bc4f19c5610e (patch) | |
tree | 85d02474f3db2aa85d88bdd48ba63939a940cd94 | |
parent | c803867f451abf384fdc1bd5f524bfe3c2e47851 (diff) | |
download | xmlgraphics-fop-d81e5851f7c083b4bd86867dee19bc4f19c5610e.tar.gz xmlgraphics-fop-d81e5851f7c083b4bd86867dee19bc4f19c5610e.zip |
FOP-2752: Show name of font file on error
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1811944 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java | 17 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java | 40 |
2 files changed, 47 insertions, 10 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java b/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java index d99a3675f..8963d2102 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/LazyFont.java @@ -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 implements FontDescriptor, Substitutable, 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); diff --git a/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java new file mode 100644 index 000000000..afea3ce9d --- /dev/null +++ b/fop-core/src/test/java/org/apache/fop/fonts/LazyFontTestCase.java @@ -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"); + } +} |