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 2005/09/14 12:29:10 UTC

svn commit: r280816 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java

Author: jeremias
Date: Wed Sep 14 03:29:04 2005
New Revision: 280816

URL: http://svn.apache.org/viewcvs?rev=280816&view=rev
Log:
Warn about fonts which are not available.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java?rev=280816&r1=280815&r2=280816&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java Wed Sep 14 03:29:04 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,17 @@
 package org.apache.fop.fonts;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.layoutmgr.AbstractBreaker;
+
 
 /**
  * The FontInfo for the layout and rendering of a fo document.
@@ -36,6 +42,9 @@
  */
 public class FontInfo {
     
+    /** logging instance */
+    protected static Log log = LogFactory.getLog(FontInfo.class);
+
     /** Map containing fonts that have been used */
     private Map usedFonts;
     
@@ -44,6 +53,8 @@
     
     /** look up a font-name to get a font (that implements FontMetrics at least) */
     private Map fonts;
+    
+    private Collection loggedFontKeys;
 
     /**
      * Main constructor
@@ -116,15 +127,11 @@
 
             // then try any family with orig weight
             if (f == null) {
+                notifyFontReplacement(key);
                 key = createFontKey("any", style, weight);
                 f = (String)triplets.get(key);
             }
 
-            // then try any family with adjusted weight
-            if (f == null) {
-                f = findAdjustWeight(family, style, weight);
-            }
-
             // then use default
             if (f == null) {
                 f = (String)triplets.get(Font.DEFAULT_FONT);
@@ -136,6 +143,16 @@
         return f;
     }
 
+    private void notifyFontReplacement(String key) {
+        if (loggedFontKeys == null) {
+            loggedFontKeys = new java.util.HashSet();
+        }
+        if (!loggedFontKeys.contains(key)) {
+            loggedFontKeys.add(key);
+            log.warn("Font '" + key + "' not found. Substituting with default font.");
+        }
+    }
+    
     /**
      * Find a font with a given family and style by trying
      * different font weights according to the spec.



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