diff options
Diffstat (limited to 'src/java')
7 files changed, 62 insertions, 43 deletions
diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java index 9a49b28f1..1f4425a95 100644 --- a/src/java/org/apache/fop/apps/FOURIResolver.java +++ b/src/java/org/apache/fop/apps/FOURIResolver.java @@ -108,6 +108,8 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /** * Handles resolve exceptions appropriately. * + * @param e + * the exception * @param errorStr * error string * @param strict @@ -232,17 +234,16 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * The URL class does not implement this work around, so we * do. */ + assert (baseURL != null); String scheme = baseURL.getProtocol() + ":"; - if (href.startsWith(scheme)) { + if (href.startsWith(scheme) && "file:".equals(scheme)) { href = href.substring(scheme.length()); - if ("file:".equals(scheme)) { - int colonPos = href.indexOf(':'); - int slashPos = href.indexOf('/'); - if (slashPos >= 0 && colonPos >= 0 - && colonPos < slashPos) { - href = "/" + href; // Absolute file URL doesn't - // have a leading slash - } + int colonPos = href.indexOf(':'); + int slashPos = href.indexOf('/'); + if (slashPos >= 0 && colonPos >= 0 + && colonPos < slashPos) { + href = "/" + href; // Absolute file URL doesn't + // have a leading slash } } try { diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index d009cb425..28ee2c23e 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -218,25 +218,24 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable * id reference. * * {@inheritDoc} List) - * @todo check to make sure it works if multiple bookmark-items - * have the same idref */ public void resolveIDRef(String id, List pages) { - if (!id.equals(idRef)) { - Collection refs = (Collection)unresolvedIDRefs.get(id); - if (refs != null) { - Iterator iter = refs.iterator(); - while (iter.hasNext()) { - BookmarkData bd = (BookmarkData)iter.next(); - bd.resolveIDRef(id, pages); - } - unresolvedIDRefs.remove(id); - } - } else { + if (id.equals(idRef)) { + //Own ID has been resolved, so note the page pageRef = (PageViewport) pages.get(0); - // TODO get rect area of id on page - unresolvedIDRefs.remove(idRef); + //Note: Determining the placement inside the page is the renderer's job. + } + + //Notify all child bookmarks + Collection refs = (Collection)unresolvedIDRefs.get(id); + if (refs != null) { + Iterator iter = refs.iterator(); + while (iter.hasNext()) { + BookmarkData bd = (BookmarkData)iter.next(); + bd.resolveIDRef(id, pages); + } } + unresolvedIDRefs.remove(id); } /** diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index 81b5ff877..d9f2e0de8 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -450,7 +450,7 @@ public class FontInfo { FontTriplet key = null; String f = null; int newWeight = weight; - if (newWeight < 400) { + if (newWeight <= 400) { while (f == null && newWeight > 100) { newWeight -= 100; key = createFontKey(family, style, newWeight); diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index 5438d3a42..981f3ad69 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -100,6 +100,11 @@ public class Type1FontLoader extends FontLoader { try { pfm = new PFMFile(); pfm.load(pfmIn); + } catch (IOException ioe) { + if (afm == null) { + //Ignore the exception if we have a valid PFM. PFM is only the fallback. + throw ioe; + } } finally { IOUtils.closeQuietly(pfmIn); } diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index 4409c62b8..e8127ae34 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -43,6 +43,8 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; import org.apache.fop.fonts.EmbedFontInfo; import org.apache.fop.fonts.FontCache; +import org.apache.fop.fonts.FontEventAdapter; +import org.apache.fop.fonts.FontEventListener; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontManager; import org.apache.fop.fonts.FontResolver; @@ -94,8 +96,10 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator boolean strict = factory.validateUserConfigStrictly(); FontCache fontCache = fontManager.getFontCache(); + FontEventListener listener = new FontEventAdapter( + renderer.getUserAgent().getEventBroadcaster()); List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontListFromConfiguration(cfg, - fontResolver, strict, fontManager); + fontResolver, strict, fontManager, listener); if (fontCache != null && fontCache.hasChanged()) { fontCache.save(); @@ -110,12 +114,14 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator * @param fontResolver the FontResolver to use * @param strict true if an Exception should be thrown if an error is found. * @param fontManager the font manager + * @param listener a font event listener * @return a List of EmbedFontInfo objects. * @throws FOPException If an error occurs while processing the configuration */ public static List/*<EmbedFontInfo>*/ buildFontListFromConfiguration(Configuration cfg, FontResolver fontResolver, - boolean strict, FontManager fontManager) throws FOPException { + boolean strict, FontManager fontManager, + FontEventListener listener) throws FOPException { FontCache fontCache = fontManager.getFontCache(); String fontBaseURL = fontManager.getFontBaseURL(); List/*<EmbedFontInfo>*/ fontInfoList @@ -144,7 +150,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator fontFileFinder.find(fontBase.getAbsolutePath()), fontInfoList, fontResolver, - fontCache + fontCache, + listener ); } } catch (IOException e) { @@ -158,7 +165,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator fontFileFinder.find(), fontInfoList, fontResolver, - fontCache + fontCache, + listener ); } catch (IOException e) { LogUtil.handleException(log, e, strict); @@ -167,12 +175,12 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator // load fonts from classpath addFontInfoListFromFileList(ClasspathResource.getInstance() .listResourcesOfMimeType("application/x-font"), - fontInfoList, fontResolver, fontCache); + fontInfoList, fontResolver, fontCache, listener); addFontInfoListFromFileList( ClasspathResource.getInstance() .listResourcesOfMimeType( "application/x-font-truetype"), - fontInfoList, fontResolver, fontCache); + fontInfoList, fontResolver, fontCache, listener); } // directory (multiple font) configuration @@ -197,7 +205,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator fontFileFinder.find(directory), fontInfoList, fontResolver, - fontCache + fontCache, + listener ); } catch (IOException e) { LogUtil.handleException(log, e, strict); @@ -208,7 +217,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator Configuration[] font = fonts.getChildren("font"); for (int i = 0; i < font.length; i++) { EmbedFontInfo embedFontInfo = getFontInfoFromConfiguration( - font[i], fontResolver, strict, fontCache); + font[i], fontResolver, strict, fontCache, listener); if (embedFontInfo != null) { fontInfoList.add(embedFontInfo); } @@ -252,11 +261,12 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator */ private static void addFontInfoListFromFileList( List fontFileList, List/*<EmbedFontInfo>*/ embedFontInfoList, - FontResolver resolver, FontCache fontCache) { + FontResolver resolver, FontCache fontCache, FontEventListener listener) { for (Iterator iter = fontFileList.iterator(); iter.hasNext();) { URL fontUrl = (URL)iter.next(); // parse font to ascertain font info FontInfoFinder finder = new FontInfoFinder(); + finder.setEventListener(listener); //EmbedFontInfo fontInfo = finder.find(fontUrl, resolver, fontCache); //List<EmbedFontInfo> embedFontInfoList = finder.find(fontUrl, resolver, fontCache); @@ -332,7 +342,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator * @throws FOPException if something's wrong with the config data */ private static EmbedFontInfo getFontInfoFromConfiguration( - Configuration fontCfg, FontResolver fontResolver, boolean strict, FontCache fontCache) + Configuration fontCfg, FontResolver fontResolver, boolean strict, + FontCache fontCache, FontEventListener listener) throws FOPException { String metricsUrl = fontCfg.getAttribute("metrics-url", null); String embedUrl = fontCfg.getAttribute("embed-url", null); @@ -384,6 +395,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator } if (fontFile != null) { FontInfoFinder finder = new FontInfoFinder(); + finder.setEventListener(listener); EmbedFontInfo[] infos = finder.find(fontUrl, fontResolver, fontCache); return infos[0]; //When subFont is set, only one font is returned } else { diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java index 06dbaccd5..6694f0a7d 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java @@ -144,21 +144,22 @@ public final class RtfFontManager { } header.newLine(); - header.writeGroupMark (true); - header.writeControlWord ("fonttbl;"); + header.writeGroupMark(true); + header.writeControlWord("fonttbl"); int len = fontTable.size (); for (int i = 0; i < len; i++) { - header.writeGroupMark (true); + header.writeGroupMark(true); header.newLine(); - header.write ("\\f" + i); - header.write (" " + (String) fontTable.elementAt (i)); - header.writeGroupMark (false); + header.write("\\f" + i); + header.write(" " + (String) fontTable.elementAt (i)); + header.write(";"); + header.writeGroupMark(false); } header.newLine(); - header.writeGroupMark (false); + header.writeGroupMark(false); } diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java index 2d1c9279c..03ad4ee71 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java @@ -63,7 +63,8 @@ public class PDFDocumentGraphics2DConfigurator { List/*<EmbedFontInfo>*/ embedFontInfoList = PrintRendererConfigurator.buildFontListFromConfiguration( - cfg, fontResolver, false, fontManager); + cfg, fontResolver, false, fontManager, null); + //TODO Wire in the FontEventListener if (fontManager.useCache()) { fontManager.getFontCache().save(); } |