From: Adrian Cumiskey Date: Tue, 29 Jul 2008 17:14:25 +0000 (+0000) Subject: * Provide warning message if no "any" font family is configured. X-Git-Tag: fop-1_0~376^2~99 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd378f8734e995e649dda935105fdd72353083e0;p=xmlgraphics-fop.git * Provide warning message if no "any" font family is configured. * When no configuration is provided, the fallback "any" base 12 font mapping is to "Times" (so as to be consistent) with the base 14 fonts and not Helvetica (as previously). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@680777 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/render/afp/AFPEventProducer.java b/src/java/org/apache/fop/render/afp/AFPEventProducer.java index 08641b20e..28d93cf65 100644 --- a/src/java/org/apache/fop/render/afp/AFPEventProducer.java +++ b/src/java/org/apache/fop/render/afp/AFPEventProducer.java @@ -60,4 +60,12 @@ public interface AFPEventProducer extends EventProducer { */ void warnDefaultFontSetup(Object source); + /** + * Warn about a missing default "any" font configuration. + * @param source the event source + * @param style the font style + * @param weight the font weight + * @event.severity WARN + */ + void warnMissingDefaultFont(Object source, String style, int weight); } diff --git a/src/java/org/apache/fop/render/afp/AFPEventProducer.xml b/src/java/org/apache/fop/render/afp/AFPEventProducer.xml index 8eec9b656..31ce19a65 100644 --- a/src/java/org/apache/fop/render/afp/AFPEventProducer.xml +++ b/src/java/org/apache/fop/render/afp/AFPEventProducer.xml @@ -1,4 +1,5 @@ No AFP fonts configured. Using default setup. + No AFP default "any", {style}, {weight} font configured. diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java b/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java index e0d56f31b..9157b9083 100644 --- a/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java +++ b/src/java/org/apache/fop/render/afp/fonts/AFPBase12FontCollection.java @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Id: $ */ +/* $Id$ */ package org.apache.fop.render.afp.fonts; @@ -79,13 +79,12 @@ public class AFPBase12FontCollection implements FontCollection { RasterFont font = null; /** standard font family reference names for Helvetica font */ - final String[] helveticaNamesPlusAny = {"Helvetica", "Arial", "sans-serif", "any"}; + final String[] helveticaNames = {"Helvetica", "Arial", "sans-serif"}; font = new RasterFont("Helvetica"); addCharacterSet(font, "C0H200", new Helvetica()); - num = addFontProperties(fontInfo, font, helveticaNamesPlusAny, + num = addFontProperties(fontInfo, font, helveticaNames, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, num); - final String[] helveticaNames = {"Helvetica", "Arial", "sans-serif"}; font = new RasterFont("Helvetica Italic"); addCharacterSet(font, "C0H300", new HelveticaOblique()); num = addFontProperties(fontInfo, font, helveticaNames, @@ -102,8 +101,11 @@ public class AFPBase12FontCollection implements FontCollection { Font.STYLE_ITALIC, Font.WEIGHT_BOLD, num); + /** standard font family reference names for Times font */ + + /** any is treated as serif */ final String[] timesNames = {"Times", "TimesRoman", "Times Roman", "Times-Roman", - "Times New Roman", "TimesNewRoman", "serif"}; + "Times New Roman", "TimesNewRoman", "serif", "any"}; font = new RasterFont("Times Roman"); addCharacterSet(font, "CON200", new TimesRoman()); diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java index 9b8c52cdb..540ee3b49 100644 --- a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java +++ b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.List; import org.apache.fop.events.EventBroadcaster; +import org.apache.fop.fonts.Font; import org.apache.fop.fonts.FontCollection; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontTriplet; @@ -52,6 +53,7 @@ public class AFPFontCollection implements FontCollection { /** {@inheritDoc} */ public int setup(int start, FontInfo fontInfo) { int num = 1; + AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster); if (fontInfoList != null && fontInfoList.size() > 0) { for (Iterator it = fontInfoList.iterator(); it.hasNext();) { AFPFontInfo afpFontInfo = (AFPFontInfo)it.next(); @@ -65,8 +67,19 @@ public class AFPFontCollection implements FontCollection { num++; } } + if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); + } + if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_NORMAL); + } + if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_BOLD) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD); + } + if (fontInfo.fontLookup("any", Font.STYLE_ITALIC, Font.WEIGHT_BOLD) == null) { + eventProducer.warnMissingDefaultFont(this, Font.STYLE_ITALIC, Font.WEIGHT_BOLD); + } } else { - AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster); eventProducer.warnDefaultFontSetup(this); // Go with a default base 12 configuration for AFP environments