From ac8e8ff3d2c6acc9f56517464bcec6a8cb00e387 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Wed, 14 Sep 2005 10:29:04 +0000 Subject: [PATCH] Warn about fonts which are not available. 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 | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index 7b554f1c4..e53d05716 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -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 @@ 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. -- 2.39.5