From: William Victor Mote Date: Thu, 14 Aug 2003 14:59:56 +0000 (+0000) Subject: move fonts.Font to fonts.Typeface (in preparation for moving layout.FontState to... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1203 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dbb70a6873319ab9948777513b8149e7a1262364;p=xmlgraphics-fop.git move fonts.Font to fonts.Typeface (in preparation for moving layout.FontState to fonts.Font) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196799 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fonts/CustomFont.java b/src/java/org/apache/fop/fonts/CustomFont.java index 80863b373..959bcfd91 100644 --- a/src/java/org/apache/fop/fonts/CustomFont.java +++ b/src/java/org/apache/fop/fonts/CustomFont.java @@ -56,7 +56,7 @@ import java.util.Map; /** * Abstract base class for custom fonts loaded from files, for example. */ -public abstract class CustomFont extends Font +public abstract class CustomFont extends Typeface implements FontDescriptor, MutableFont { private String fontName = null; diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java deleted file mode 100644 index 3d0b2ed0f..000000000 --- a/src/java/org/apache/fop/fonts/Font.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * $Id: Font.java,v 1.2 2003/03/06 17:43:05 jeremias Exp $ - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The end-user documentation included with the redistribution, if any, must - * include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "FOP" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ============================================================================ - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation and was originally created by - * James Tauber . For more information on the Apache - * Software Foundation, please see . - */ -package org.apache.fop.fonts; - -// FOP - - -/** - * Base class for PDF font classes - */ -public abstract class Font implements FontMetrics { - - /** - * Get the encoding of the font. - * @return the encoding - */ - public abstract String getEncoding(); - - /** - * Map a Unicode character to a code point in the font. - * @param c character to map - * @return the mapped character - */ - public abstract char mapChar(char c); - - /** - * Determines whether the font is a multibyte font. - * @return True if it is multibyte - */ - public boolean isMultiByte() { - return false; - } - -} - diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index 6af3e9523..f6df61418 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.java @@ -148,7 +148,7 @@ public class FontReader extends DefaultHandler { * Get the generated font object * @return the font */ - public Font getFont() { + public Typeface getFont() { return returnFont; } diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java index b18af07dc..f37aa75ec 100644 --- a/src/java/org/apache/fop/fonts/LazyFont.java +++ b/src/java/org/apache/fop/fonts/LazyFont.java @@ -59,14 +59,14 @@ import java.util.Map; /** * This class is used to defer the loading of a font until it is really used. */ -public class LazyFont extends Font implements FontDescriptor { +public class LazyFont extends Typeface implements FontDescriptor { private String metricsFileName = null; private String fontEmbedPath = null; private boolean useKerning = false; private boolean isMetricsLoaded = false; - private Font realFont = null; + private Typeface realFont = null; private FontDescriptor realFontDescriptor = null; /** @@ -109,7 +109,7 @@ public class LazyFont extends Font implements FontDescriptor { * Gets the real font. * @return the real font */ - public Font getRealFont() { + public Typeface getRealFont() { load(); return realFont; } diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java new file mode 100644 index 000000000..1e4f2af3f --- /dev/null +++ b/src/java/org/apache/fop/fonts/Typeface.java @@ -0,0 +1,83 @@ +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber . For more information on the Apache + * Software Foundation, please see . + */ +package org.apache.fop.fonts; + +// FOP + + +/** + * Base class for PDF font classes + */ +public abstract class Typeface implements FontMetrics { + + /** + * Get the encoding of the font. + * @return the encoding + */ + public abstract String getEncoding(); + + /** + * Map a Unicode character to a code point in the font. + * @param c character to map + * @return the mapped character + */ + public abstract char mapChar(char c); + + /** + * Determines whether the font is a multibyte font. + * @return True if it is multibyte + */ + public boolean isMultiByte() { + return false; + } + +} + diff --git a/src/java/org/apache/fop/layout/FontState.java b/src/java/org/apache/fop/layout/FontState.java index 316675ca8..2414a2a25 100644 --- a/src/java/org/apache/fop/layout/FontState.java +++ b/src/java/org/apache/fop/layout/FontState.java @@ -165,8 +165,8 @@ public class FontState { */ public char mapChar(char c) { - if (metric instanceof org.apache.fop.fonts.Font) { - return ((org.apache.fop.fonts.Font)metric).mapChar(c); + if (metric instanceof org.apache.fop.fonts.Typeface) { + return ((org.apache.fop.fonts.Typeface)metric).mapChar(c); } // Use default CodePointMapping diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index cab819d76..45791a549 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -64,7 +64,7 @@ import org.apache.commons.io.IOUtil; // FOP import org.apache.fop.fonts.CIDFont; import org.apache.fop.fonts.CustomFont; -import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.FontDescriptor; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.fonts.FontType; @@ -1102,11 +1102,11 @@ public class PDFFactory { + desc.getFontType()); } - Font tempFont; + Typeface tempFont; if (desc instanceof LazyFont) { tempFont = ((LazyFont)desc).getRealFont(); } else { - tempFont = (Font)desc; + tempFont = (Typeface)desc; } if (!(tempFont instanceof CustomFont)) { throw new IllegalArgumentException( diff --git a/src/java/org/apache/fop/render/pdf/FontSetup.java b/src/java/org/apache/fop/render/pdf/FontSetup.java index 7687328d9..3d30f6c8c 100644 --- a/src/java/org/apache/fop/render/pdf/FontSetup.java +++ b/src/java/org/apache/fop/render/pdf/FontSetup.java @@ -53,7 +53,7 @@ package org.apache.fop.render.pdf; // FOP import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.FontDescriptor; import org.apache.fop.fonts.FontUtil; import org.apache.fop.fonts.LazyFont; @@ -253,7 +253,7 @@ public class FontSetup { Iterator e = fonts.keySet().iterator(); while (e.hasNext()) { String f = (String)e.next(); - Font font = (Font)fonts.get(f); + Typeface font = (Typeface)fonts.get(f); FontDescriptor desc = null; if (font instanceof FontDescriptor) { desc = (FontDescriptor)font; diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 2850be8c6..8b469f6e2 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -77,7 +77,7 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.Version; import org.apache.fop.fo.properties.RuleStyle; import org.apache.fop.fo.properties.BackgroundRepeat; -import org.apache.fop.fonts.Font; +import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.FontMetrics; import org.apache.fop.pdf.PDFEncryptionManager; import org.apache.fop.pdf.PDFFilterList; @@ -867,7 +867,7 @@ public class PDFRenderer extends PrintRenderer { int size = ((Integer) word.getTrait(Trait.FONT_SIZE)).intValue(); // This assumes that *all* CIDFonts use a /ToUnicode mapping - Font f = (Font) fontInfo.getFonts().get(name); + Typeface f = (Typeface) fontInfo.getFonts().get(name); boolean useMultiByte = f.isMultiByte(); // String startText = useMultiByte ? "