]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Warn about fonts which are not available.
authorJeremias Maerki <jeremias@apache.org>
Wed, 14 Sep 2005 10:29:04 +0000 (10:29 +0000)
committerJeremias Maerki <jeremias@apache.org>
Wed, 14 Sep 2005 10:29:04 +0000 (10:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@280816 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fonts/FontInfo.java

index 7b554f1c4a48808ebb6ac10b1770e67c6adabbec..e53d05716f7fae965e23ea9aa818eb9633cc6d48 100644 (file)
@@ -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.
 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 @@ import java.util.Map;
  */
 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 @@ public class FontInfo {
     
     /** 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 @@ public class FontInfo {
 
             // 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 @@ public class FontInfo {
         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.