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 je...@apache.org on 2008/08/05 09:47:18 UTC

svn commit: r682617 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: render/PrintRendererConfigurator.java svg/PDFDocumentGraphics2DConfigurator.java

Author: jeremias
Date: Tue Aug  5 00:47:18 2008
New Revision: 682617

URL: http://svn.apache.org/viewvc?rev=682617&view=rev
Log:
The FontEventListener was not wired into font auto-detection. An error while loading a font wasn't relayed to the event subsystem.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=682617&r1=682616&r2=682617&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRendererConfigurator.java Tue Aug  5 00:47:18 2008
@@ -43,6 +43,8 @@
 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 @@
         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 @@
      * @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 @@
                                     fontFileFinder.find(fontBase.getAbsolutePath()),
                                     fontInfoList,
                                     fontResolver,
-                                    fontCache
+                                    fontCache,
+                                    listener
                             );
                         }
                     } catch (IOException e) {
@@ -158,7 +165,8 @@
                             fontFileFinder.find(),
                             fontInfoList,
                             fontResolver,
-                            fontCache
+                            fontCache,
+                            listener
                     );
                 } catch (IOException e) {
                     LogUtil.handleException(log, e, strict);
@@ -167,12 +175,12 @@
                 // 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 @@
                             fontFileFinder.find(directory),
                             fontInfoList,
                             fontResolver,
-                            fontCache
+                            fontCache,
+                            listener
                     );
                 } catch (IOException e) {
                     LogUtil.handleException(log, e, strict);
@@ -208,7 +217,7 @@
             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 @@
      */
     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 @@
      * @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 @@
             }
             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 {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=682617&r1=682616&r2=682617&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Tue Aug  5 00:47:18 2008
@@ -63,7 +63,8 @@
 
             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();
             }



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