]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
move layout.FontState to fonts.Font
authorWilliam Victor Mote <vmote@apache.org>
Thu, 14 Aug 2003 15:31:10 +0000 (15:31 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Thu, 14 Aug 2003 15:31:10 +0000 (15:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196800 13f79535-47bb-0310-9956-ffa450edef68

17 files changed:
src/java/org/apache/fop/fo/PropertyManager.java
src/java/org/apache/fop/fo/TextInfo.java
src/java/org/apache/fop/fo/flow/Leader.java
src/java/org/apache/fop/fo/flow/PageNumber.java
src/java/org/apache/fop/fo/flow/PageNumberCitation.java
src/java/org/apache/fop/fo/pagination/Title.java
src/java/org/apache/fop/fonts/Font.java [new file with mode: 0644]
src/java/org/apache/fop/layout/FontState.java [deleted file]
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
src/java/org/apache/fop/render/pdf/PDFRenderer.java
src/java/org/apache/fop/render/ps/PSGraphics2D.java
src/java/org/apache/fop/render/ps/PSTextPainter.java
src/java/org/apache/fop/svg/PDFGraphics2D.java
src/java/org/apache/fop/svg/PDFTextPainter.java
src/java/org/apache/fop/tools/AreaTreeBuilder.java
src/java/org/apache/fop/util/CharUtilities.java

index dc5d9f918b959be1ffdcddab632ad94783bc7ab4..0e73e64334876813661138feea615f2f11b50053 100644 (file)
@@ -57,7 +57,7 @@ import java.awt.geom.Rectangle2D;
 // FOP
 import org.apache.fop.area.CTM;
 import org.apache.fop.datatypes.FODimension;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.control.Document;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
 import org.apache.fop.fo.properties.CommonMarginBlock;
@@ -84,7 +84,7 @@ public class PropertyManager {
 
     private PropertyList properties;
     private Document fontInfo = null;
-    private FontState fontState = null;
+    private Font fontState = null;
     private CommonBorderAndPadding borderAndPadding = null;
     private CommonHyphenation hyphProps = null;
     private TextInfo textInfo = null;
@@ -133,7 +133,7 @@ public class PropertyManager {
      * @param fontInfo FontInfo to work with
      * @return a FontState object
      */
-    public FontState getFontState(Document fontInfo) {
+    public Font getFontState(Document fontInfo) {
         if (fontState == null) {
             if (fontInfo == null) {
                 fontInfo = this.fontInfo;
@@ -170,7 +170,7 @@ public class PropertyManager {
             String fname = fontInfo.fontLookup(fontFamily, fontStyle,
                                                fontWeight);
             FontMetrics metrics = fontInfo.getMetricsFor(fname);
-            fontState = new FontState(fname, metrics, fontSize);
+            fontState = new Font(fname, metrics, fontSize);
         }
         return fontState;
     }
index 860bbd119ea6033473d05bbdd4d73acee613314b..a84ab6c3c6227e4365cf94d54a9d7e516650fdeb 100644 (file)
@@ -51,7 +51,7 @@
 package org.apache.fop.fo;
 
 // FOP
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.traits.SpaceVal;
 import org.apache.fop.fo.properties.TextTransform;
@@ -61,7 +61,7 @@ import org.apache.fop.fo.properties.TextTransform;
  */
 public class TextInfo {
     /** object containing the font information */
-    public FontState fs;
+    public Font fs;
     /** fo:color property */
     public ColorType color;
     /** fo:wrap-option property */
index 285aef2e81a8d9b51a0d9bffe2c637dc0cb0a52c..9f59b44e8167aebdbd973a84cec6b7d5e1a6b5e0 100644 (file)
@@ -71,7 +71,7 @@ import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBackground;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
 import org.apache.fop.control.Document;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.fo.properties.CommonMarginInline;
 import org.apache.fop.fo.properties.CommonRelativePosition;
 import org.apache.fop.layoutmgr.ContentLayoutManager;
@@ -96,7 +96,7 @@ public class Leader extends FObjMixed {
     /** FontInfo for this object */
     protected Document fontInfo = null;
     /** FontState for this object */
-    protected FontState fontState;
+    protected Font fontState;
     protected InlineArea leaderArea = null;
 
     /**
index f6488bd1a8b6b94f6b3d480a7dda43ce3b64c023..8f9fd7d8fe778d67a210a1876df1fb774bdb9da7 100644 (file)
@@ -59,7 +59,7 @@ import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBackground;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
 import org.apache.fop.control.Document;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.fo.properties.CommonMarginInline;
 import org.apache.fop.fo.properties.CommonRelativePosition;
 import org.apache.fop.layout.TextState;
@@ -84,7 +84,7 @@ public class PageNumber extends FObj {
     /** FontInfo for this object */
     protected Document fontInfo = null;
     /** FontState for this object */
-    protected FontState fontState;
+    protected Font fontState;
 
     private float red;
     private float green;
index 53a2bafde3b3d700245af8df3f158397d4598b8f..a83665d9d06cc4713b5d237f4208088fdaa8fbcf 100644 (file)
@@ -69,7 +69,7 @@ import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBackground;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
 import org.apache.fop.control.Document;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.fo.properties.CommonMarginInline;
 import org.apache.fop.fo.properties.CommonRelativePosition;
 import org.apache.fop.layout.TextState;
@@ -91,7 +91,7 @@ public class PageNumberCitation extends FObj {
     /** FontInfo for this object **/
     protected Document fontInfo = null;
     /** Fontstate for this object **/
-    protected FontState fontState;
+    protected Font fontState;
 
     private float red;
     private float green;
index a1b9c9d9856bfc9385af4cce581fe75d62731cb6..a4daf6138311bc50efc4ce73f5393de0e0ab23d9 100644 (file)
@@ -62,7 +62,7 @@ import org.apache.fop.fo.properties.CommonAccessibility;
 import org.apache.fop.fo.properties.CommonAural;
 import org.apache.fop.fo.properties.CommonBackground;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.fo.properties.CommonMarginInline;
 import org.apache.fop.layoutmgr.ContentLayoutManager;
 import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
@@ -120,7 +120,7 @@ public class Title extends FObjMixed {
         CommonBackground bProps = propMgr.getBackgroundProps();
 
         // Common Font Properties
-        FontState fontState = propMgr.getFontState(foInputHandler.getFontInfo());
+        Font fontState = propMgr.getFontState(foInputHandler.getFontInfo());
 
         // Common Margin Properties-Inline
         CommonMarginInline mProps = propMgr.getMarginInlineProps();
diff --git a/src/java/org/apache/fop/fonts/Font.java b/src/java/org/apache/fop/fonts/Font.java
new file mode 100644 (file)
index 0000000..a304be5
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * $Id: FontState.java,v 1.23 2003/03/06 22:19:16 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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */ 
+package org.apache.fop.fonts;
+
+import java.util.Map;
+
+
+
+
+/**
+ * This class holds font state information and provides access to the font 
+ * metrics.
+ */
+public class Font {
+
+    private String fontName;
+    private int fontSize;
+    //private String fontFamily;
+    //private String fontStyle;
+    //private int fontWeight;
+
+    /**
+     * normal or small-caps font
+     */
+    //private int fontVariant;
+
+    private FontMetrics metric;
+
+    /**
+     * Main constructor
+     * @param key key of the font
+     * @param met font metrics
+     * @param fontSize font size
+     */
+    public Font(String key, FontMetrics met, int fontSize) {
+        this.fontName = key;
+        this.metric = met;
+        this.fontSize = fontSize;
+    }
+
+    /**
+     * Returns the font's ascender.
+     * @return the ascender
+     */
+    public int getAscender() {
+        return metric.getAscender(fontSize) / 1000;
+    }
+
+    /**
+     * Returns the font's CapHeight.
+     * @return the capital height
+     */
+    public int getCapHeight() {
+        return metric.getCapHeight(fontSize) / 1000;
+    }
+
+    /**
+     * Returns the font's Descender.
+     * @return the descender
+     */
+    public int getDescender() {
+        return metric.getDescender(fontSize) / 1000;
+    }
+
+    /**
+     * Returns the font's name.
+     * @return the font name
+     */
+    public String getFontName() {
+        return fontName;
+    }
+
+    /**
+     * Returns the font size
+     * @return the font size
+     */
+    public int getFontSize() {
+        return fontSize;
+    }
+
+    /**
+     * Returns the XHeight
+     * @return the XHeight
+     */
+    public int getXHeight() {
+        return metric.getXHeight(fontSize) / 1000;
+    }
+
+    /**
+     * Returns the font's kerning table
+     * @return the kerning table
+     */
+    public Map getKerning() {
+        Map ret = metric.getKerningInfo();
+        if (ret != null) {
+            return ret;
+        } else {
+            return java.util.Collections.EMPTY_MAP;
+        }
+    }
+
+    /**
+     * Returns the width of a character
+     * @param charnum character to look up
+     * @return width of the character
+     */
+    public int getWidth(int charnum) {
+        // returns width of given character number in millipoints
+        return (metric.getWidth(charnum, fontSize) / 1000);
+    }
+
+    /**
+     * Map a java character (unicode) to a font character.
+     * Default uses CodePointMapping.
+     * @param c character to map
+     * @return the mapped character
+     */
+    public char mapChar(char c) {
+
+        if (metric instanceof org.apache.fop.fonts.Typeface) {
+            return ((org.apache.fop.fonts.Typeface)metric).mapChar(c);
+        }
+
+        // Use default CodePointMapping
+        char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
+        if (d != 0) {
+            c = d;
+        } else {
+            c = '#';
+        }
+
+        return c;
+    }
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        StringBuffer sbuf = new StringBuffer();
+        sbuf.append('(');
+        /*
+        sbuf.append(fontFamily);
+        sbuf.append(',');*/
+        sbuf.append(fontName);
+        sbuf.append(',');
+        sbuf.append(fontSize);
+        /*
+        sbuf.append(',');
+        sbuf.append(fontStyle);
+        sbuf.append(',');
+        sbuf.append(fontWeight);*/
+        sbuf.append(')');
+        return sbuf.toString();
+    }
+}
+
+
+
diff --git a/src/java/org/apache/fop/layout/FontState.java b/src/java/org/apache/fop/layout/FontState.java
deleted file mode 100644 (file)
index 2414a2a..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * $Id: FontState.java,v 1.23 2003/03/06 22:19:16 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 <jtauber@jtauber.com>. For more information on the Apache
- * Software Foundation, please see <http://www.apache.org/>.
- */ 
-package org.apache.fop.layout;
-
-import java.util.Map;
-
-import org.apache.fop.fonts.CodePointMapping;
-import org.apache.fop.fonts.FontMetrics;
-
-/**
- * This class holds font state information and provides access to the font 
- * metrics.
- */
-public class FontState {
-
-    private String fontName;
-    private int fontSize;
-    //private String fontFamily;
-    //private String fontStyle;
-    //private int fontWeight;
-
-    /**
-     * normal or small-caps font
-     */
-    //private int fontVariant;
-
-    private FontMetrics metric;
-
-    /**
-     * Main constructor
-     * @param key key of the font
-     * @param met font metrics
-     * @param fontSize font size
-     */
-    public FontState(String key, FontMetrics met, int fontSize) {
-        this.fontName = key;
-        this.metric = met;
-        this.fontSize = fontSize;
-    }
-
-    /**
-     * Returns the font's ascender.
-     * @return the ascender
-     */
-    public int getAscender() {
-        return metric.getAscender(fontSize) / 1000;
-    }
-
-    /**
-     * Returns the font's CapHeight.
-     * @return the capital height
-     */
-    public int getCapHeight() {
-        return metric.getCapHeight(fontSize) / 1000;
-    }
-
-    /**
-     * Returns the font's Descender.
-     * @return the descender
-     */
-    public int getDescender() {
-        return metric.getDescender(fontSize) / 1000;
-    }
-
-    /**
-     * Returns the font's name.
-     * @return the font name
-     */
-    public String getFontName() {
-        return fontName;
-    }
-
-    /**
-     * Returns the font size
-     * @return the font size
-     */
-    public int getFontSize() {
-        return fontSize;
-    }
-
-    /**
-     * Returns the XHeight
-     * @return the XHeight
-     */
-    public int getXHeight() {
-        return metric.getXHeight(fontSize) / 1000;
-    }
-
-    /**
-     * Returns the font's kerning table
-     * @return the kerning table
-     */
-    public Map getKerning() {
-        Map ret = metric.getKerningInfo();
-        if (ret != null) {
-            return ret;
-        } else {
-            return java.util.Collections.EMPTY_MAP;
-        }
-    }
-
-    /**
-     * Returns the width of a character
-     * @param charnum character to look up
-     * @return width of the character
-     */
-    public int getWidth(int charnum) {
-        // returns width of given character number in millipoints
-        return (metric.getWidth(charnum, fontSize) / 1000);
-    }
-
-    /**
-     * Map a java character (unicode) to a font character.
-     * Default uses CodePointMapping.
-     * @param c character to map
-     * @return the mapped character
-     */
-    public char mapChar(char c) {
-
-        if (metric instanceof org.apache.fop.fonts.Typeface) {
-            return ((org.apache.fop.fonts.Typeface)metric).mapChar(c);
-        }
-
-        // Use default CodePointMapping
-        char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
-        if (d != 0) {
-            c = d;
-        } else {
-            c = '#';
-        }
-
-        return c;
-    }
-
-    /**
-     * @see java.lang.Object#toString()
-     */
-    public String toString() {
-        StringBuffer sbuf = new StringBuffer();
-        sbuf.append('(');
-        /*
-        sbuf.append(fontFamily);
-        sbuf.append(',');*/
-        sbuf.append(fontName);
-        sbuf.append(',');
-        sbuf.append(fontSize);
-        /*
-        sbuf.append(',');
-        sbuf.append(fontStyle);
-        sbuf.append(',');
-        sbuf.append(fontWeight);*/
-        sbuf.append(')');
-        return sbuf.toString();
-    }
-}
-
-
-
index 83262ec212aed35e30f5c2756363ae0736667ead..4061e475e1ee1b9ab07b4932298cd7df1a3e9719 100644 (file)
@@ -63,6 +63,7 @@ import org.apache.fop.area.LineArea;
 import org.apache.fop.traits.LayoutProps;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
 import org.apache.fop.fo.properties.CommonBackground;
+import org.apache.fop.fonts.*;
 
 /**
  * LayoutManager for a block FO.
index e26000f04ef520ec613d17de18ae4dd62a68bf70..903f8c51bb3c3ee999068d3a4ce07f9e89242c9d 100644 (file)
@@ -59,6 +59,7 @@ import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.Word;
 import org.apache.fop.area.inline.Space;
 import org.apache.fop.util.CharUtilities;
+import org.apache.fop.fonts.*;
 
 /**
  * LayoutManager for text (a sequence of characters) which generates one
index 8b469f6e23a92de25c7ef90f23df1e57e9577635..be653326b83859455051df27ed2bad22ccaed43d 100644 (file)
@@ -114,7 +114,7 @@ import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.InlineParent;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.datatypes.ColorType;
 
@@ -920,7 +920,7 @@ public class PDFRenderer extends PrintRenderer {
         String s = word.getWord();
 
         FontMetrics metrics = fontInfo.getMetricsFor(name);
-        FontState fs = new FontState(name, metrics, size);
+        Font fs = new Font(name, metrics, size);
         escapeText(s, fs, useMultiByte, pdf);
         pdf.append(endText);
 
@@ -936,7 +936,7 @@ public class PDFRenderer extends PrintRenderer {
      * @param useMultiByte Indicates the use of multi byte convention
      * @param pdf target buffer for the escaped text
      */
-    public void escapeText(String s, FontState fs,
+    public void escapeText(String s, Font fs,
                            boolean useMultiByte, StringBuffer pdf) {
         String startText = useMultiByte ? "<" : "(";
         String endText = useMultiByte ? "> " : ") ";
index 068d6272edcb2b542b1438d2ae4221610f83cb29..009bc9005a8539efbda045a7aed86e68a999356b 100644 (file)
@@ -58,7 +58,8 @@ import java.awt.AlphaComposite;
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Dimension;
-import java.awt.Font;
+/* java.awt.Font is not imported to avoid confusion with
+   org.apache.fop.fonts.Font */
 import java.awt.GradientPaint;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
@@ -84,7 +85,7 @@ import java.io.IOException;
 
 // FOP
 import org.apache.fop.control.Document;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 
 // Batik
 import org.apache.batik.ext.awt.g2d.AbstractGraphics2D;
@@ -113,10 +114,10 @@ public class PSGraphics2D extends AbstractGraphics2D {
     protected PSGenerator gen;
 
     /** Currently valid FontState */
-    protected FontState fontState;
+    protected Font fontState;
 
     /** Overriding FontState */
-    protected FontState overrideFontState = null;
+    protected Font overrideFontState = null;
 
     /**
      * the current (internal) font name
@@ -826,7 +827,7 @@ public class PSGraphics2D extends AbstractGraphics2D {
     public void drawString(String s, float x, float y) {
       try {
         if (overrideFontState == null) {
-            Font gFont = getFont();
+            java.awt.Font gFont = getFont();
             String n = gFont.getFamily();
             if (n.equals("sanserif")) {
                 n = "sans-serif";
@@ -1088,7 +1089,7 @@ public class PSGraphics2D extends AbstractGraphics2D {
      * Sets the overrideing font state.
      * @param infont FontState to set
      */
-    public void setOverrideFontState(FontState infont) {
+    public void setOverrideFontState(Font infont) {
         overrideFontState = infont;
     }
 
@@ -1100,7 +1101,7 @@ public class PSGraphics2D extends AbstractGraphics2D {
      * @see       java.awt.FontMetrics
      * @see       java.awt.Graphics#getFontMetrics()
      */
-    public java.awt.FontMetrics getFontMetrics(Font f) {
+    public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
         return fmg.getFontMetrics(f);
     }
 
index f357fa28357f2efc953744f3f2a7513cc24176b3..bb52fef6eabd9bc55c32e1aecd4e960c1dd2bed9 100644 (file)
@@ -53,7 +53,8 @@ package org.apache.fop.render.ps;
 import java.awt.Graphics2D;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.awt.Font;
+/* java.awt.Font is not imported to avoid confusion with
+   org.apache.fop.fonts.Font */
 
 import java.text.AttributedCharacterIterator;
 import java.awt.font.TextAttribute;
@@ -73,7 +74,7 @@ import org.apache.batik.bridge.SVGFontFamily;
 import org.apache.batik.gvt.renderer.StrokingTextPainter;
 
 import org.apache.fop.fonts.FontMetrics;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.control.Document;
 
 /**
@@ -189,7 +190,7 @@ public class PSTextPainter implements TextPainter {
                        &&  (taWeight.floatValue() > 1.0)) ? Document.BOLD
                        : Document.NORMAL;
 
-        FontState fontState = null;
+        Font fontState = null;
         Document fi = fontInfo;
         boolean found = false;
         String fontFamily = null;
@@ -207,7 +208,7 @@ public class PSTextPainter implements TextPainter {
                                                        weight);
                     FontMetrics metrics = fontInfo.getMetricsFor(fname);
                     int fsize = (int)(size.floatValue() * 1000);
-                    fontState = new FontState(fname, metrics, fsize);
+                    fontState = new Font(fname, metrics, fsize);
                     found = true;
                     break;
                 }
@@ -218,27 +219,27 @@ public class PSTextPainter implements TextPainter {
               fontInfo.fontLookup("any", style, Document.NORMAL);
             FontMetrics metrics = fontInfo.getMetricsFor(fname);
             int fsize = (int)(size.floatValue() * 1000);
-            fontState = new FontState(fname, metrics, fsize);
+            fontState = new Font(fname, metrics, fsize);
         } else {
             if (g2d instanceof PSGraphics2D) {
                 ((PSGraphics2D) g2d).setOverrideFontState(fontState);
             }
         }
-        int fStyle = Font.PLAIN;
+        int fStyle = java.awt.Font.PLAIN;
         if (weight == Document.BOLD) {
             if (style.equals("italic")) {
-                fStyle = Font.BOLD | Font.ITALIC;
+                fStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
             } else {
-                fStyle = Font.BOLD;
+                fStyle = java.awt.Font.BOLD;
             }
         } else {
             if (style.equals("italic")) {
-                fStyle = Font.ITALIC;
+                fStyle = java.awt.Font.ITALIC;
             } else {
-                fStyle = Font.PLAIN;
+                fStyle = java.awt.Font.PLAIN;
             }
         }
-        Font font = new Font(fontFamily, fStyle,
+        java.awt.Font font = new java.awt.Font(fontFamily, fStyle,
                              (int)(fontState.getFontSize() / 1000));
 
         g2d.setFont(font);
@@ -288,7 +289,7 @@ public class PSTextPainter implements TextPainter {
         return hasunsupported;
     }
 
-    private float getStringWidth(String str, FontState fontState) {
+    private float getStringWidth(String str, Font fontState) {
         float wordWidth = 0;
         float whitespaceWidth = fontState.getWidth(fontState.mapChar(' '));
 
index 7a7bcf364638d74e6db4d97738e9f1d528ac8e1a..e4e4a2f37577c4cb8c6dd8122addd63d2c551929 100644 (file)
@@ -65,7 +65,7 @@ import org.apache.fop.pdf.PDFLink;
 import org.apache.fop.pdf.PDFAnnotList;
 import org.apache.fop.pdf.BitmapImage;
 import org.apache.fop.control.Document;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.render.pdf.FontSetup;
 import org.apache.fop.fonts.FontMetrics;
 import org.apache.fop.fonts.LazyFont;
@@ -87,7 +87,8 @@ import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.Color;
 import java.awt.GraphicsConfiguration;
-import java.awt.Font;
+/*  java.awt.Font is not imported to avoid confusion with
+    org.apache.fop.fonts.Font */
 import java.awt.Image;
 import java.awt.Shape;
 import java.awt.Stroke;
@@ -159,7 +160,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
      * The override font state used when drawing text and the font cannot be
      * set using java fonts.
      */
-    protected FontState ovFontState = null;
+    protected Font ovFontState = null;
 
     /**
      * the current stream to add PDF commands to
@@ -266,7 +267,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
      *
      * @param infont the font state to use
      */
-    public void setOverrideFontState(FontState infont) {
+    public void setOverrideFontState(Font infont) {
         ovFontState = infont;
     }
 
@@ -1198,9 +1199,9 @@ public class PDFGraphics2D extends AbstractGraphics2D {
     public void drawString(String s, float x, float y) {
         // System.out.println("drawString(String)");
 
-        FontState fontState;
+        Font fontState;
         if (ovFontState == null) {
-            Font gFont = getFont();
+            java.awt.Font gFont = getFont();
             String n = gFont.getFamily();
             if (n.equals("sanserif")) {
                 n = "sans-serif";
@@ -1210,10 +1211,10 @@ public class PDFGraphics2D extends AbstractGraphics2D {
             int weight = gFont.isBold() ? Document.BOLD : Document.NORMAL;
             String fname = fontInfo.fontLookup(n, style, weight);
             FontMetrics metrics = fontInfo.getMetricsFor(fname);
-            fontState = new FontState(fname, metrics, siz * 1000);
+            fontState = new Font(fname, metrics, siz * 1000);
         } else {
             FontMetrics metrics = fontInfo.getMetricsFor(ovFontState.getFontName());
-            fontState = new FontState(ovFontState.getFontName(),
+            fontState = new Font(ovFontState.getFontName(),
                                       metrics, ovFontState.getFontSize());
             ovFontState = null;
         }
@@ -1367,7 +1368,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
                            float y) {
         System.err.println("drawString(AttributedCharacterIterator)");
 
-        FontState fontState = null;
+        Font fontState = null;
 
         Shape imclip = getClip();
         writeClip(imclip);
@@ -1587,7 +1588,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
      * @see       java.awt.FontMetrics
      * @see       java.awt.Graphics#getFontMetrics()
      */
-    public java.awt.FontMetrics getFontMetrics(Font f) {
+    public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
         return fmg.getFontMetrics(f);
     }
 
index a3645d2e30d5efd181b8c7060223d2b3995ff29e..247b98bb9434e72cabcbde8972aad1b8945f1ebe 100644 (file)
@@ -53,8 +53,8 @@ package org.apache.fop.svg;
 import java.awt.Graphics2D;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-import java.awt.Font;
-
+/* java.awt.Font is not imported to avoid confusion with
+   org.apache.fop.fonts.Font */
 import java.text.AttributedCharacterIterator;
 import java.awt.font.TextAttribute;
 import java.awt.Shape;
@@ -73,7 +73,7 @@ import org.apache.batik.bridge.SVGFontFamily;
 import org.apache.batik.gvt.renderer.StrokingTextPainter;
 
 import org.apache.fop.fonts.FontMetrics;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.control.Document;
 
 /**
@@ -189,7 +189,7 @@ public class PDFTextPainter implements TextPainter {
                        &&  (taWeight.floatValue() > 1.0)) ? Document.BOLD
                        : Document.NORMAL;
 
-        FontState fontState = null;
+        Font fontState = null;
         Document fi = fontInfo;
         boolean found = false;
         String fontFamily = null;
@@ -207,7 +207,7 @@ public class PDFTextPainter implements TextPainter {
                                                        weight);
                     FontMetrics metrics = fontInfo.getMetricsFor(fname);
                     int fsize = (int)(size.floatValue() * 1000);
-                    fontState = new FontState(fname, metrics, fsize);
+                    fontState = new Font(fname, metrics, fsize);
                     found = true;
                     break;
                 }
@@ -218,27 +218,27 @@ public class PDFTextPainter implements TextPainter {
               fontInfo.fontLookup("any", style, Document.NORMAL);
             FontMetrics metrics = fontInfo.getMetricsFor(fname);
             int fsize = (int)(size.floatValue() * 1000);
-            fontState = new FontState(fname, metrics, fsize);
+            fontState = new Font(fname, metrics, fsize);
         } else {
             if (g2d instanceof PDFGraphics2D) {
                 ((PDFGraphics2D) g2d).setOverrideFontState(fontState);
             }
         }
-        int fStyle = Font.PLAIN;
+        int fStyle = java.awt.Font.PLAIN;
         if (weight == Document.BOLD) {
             if (style.equals("italic")) {
-                fStyle = Font.BOLD | Font.ITALIC;
+                fStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
             } else {
-                fStyle = Font.BOLD;
+                fStyle = java.awt.Font.BOLD;
             }
         } else {
             if (style.equals("italic")) {
-                fStyle = Font.ITALIC;
+                fStyle = java.awt.Font.ITALIC;
             } else {
-                fStyle = Font.PLAIN;
+                fStyle = java.awt.Font.PLAIN;
             }
         }
-        Font font = new Font(fontFamily, fStyle,
+        java.awt.Font font = new java.awt.Font(fontFamily, fStyle,
                              (int)(fontState.getFontSize() / 1000));
 
         g2d.setFont(font);
@@ -288,7 +288,7 @@ public class PDFTextPainter implements TextPainter {
         return hasunsupported;
     }
 
-    private float getStringWidth(String str, FontState fontState) {
+    private float getStringWidth(String str, Font fontState) {
         float wordWidth = 0;
         float whitespaceWidth = fontState.getWidth(fontState.mapChar(' '));
 
index 5f06e5bf033e720e7821002fdfa6168430a981b6..16b720db25614877b5943532cf724a64069641d3 100644 (file)
@@ -101,7 +101,7 @@ import org.apache.fop.area.inline.Space;
 import org.apache.fop.area.inline.Viewport;
 import org.apache.fop.area.inline.Word;
 import org.apache.fop.control.Document;
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.pdf.PDFRenderer;
 import org.apache.fop.render.svg.SVGRenderer;
@@ -249,7 +249,7 @@ class TreeLoader extends AbstractLogEnabled {
     private AreaTree areaTree;
     private AreaTreeModel model;
     private Document fontInfo;
-    private FontState currentFontState;
+    private Font currentFontState;
 
     TreeLoader(Document fi) {
         fontInfo = fi;
@@ -562,7 +562,7 @@ class TreeLoader extends AbstractLogEnabled {
                 String fname = fontInfo.fontLookup("sans-serif", "normal", Document.NORMAL);
                 FontMetrics metrics = fontInfo.getMetricsFor(fname);
                 currentFontState =
-                    new FontState(fname, metrics, 12000);
+                    new Font(fname, metrics, 12000);
 
                 ch.setWidth(currentFontState.getWidth(ch.getChar()));
                 ch.setOffset(currentFontState.getCapHeight());
@@ -587,7 +587,7 @@ class TreeLoader extends AbstractLogEnabled {
                 String fname = fontInfo.fontLookup("sans-serif", "normal", Document.NORMAL);
                 FontMetrics metrics = fontInfo.getMetricsFor(fname);
                 currentFontState =
-                    new FontState(fname, metrics, 12000);
+                    new Font(fname, metrics, 12000);
                 Word word = getWord((Element) obj);
 
                 word.addTrait(Trait.FONT_NAME, fname);
index 80fd7aba2c5deacd58a495ab6e2b354f3c8e5762..0703deaf3b287c045125e83dad93934e3567fae7 100644 (file)
@@ -50,7 +50,7 @@
  */ 
 package org.apache.fop.util;
 
-import org.apache.fop.layout.FontState;
+import org.apache.fop.fonts.Font;
 
 /**
  * This class provides utilities to distinguish various kinds of Unicode
@@ -117,7 +117,7 @@ public class CharUtilities {
      * @param fs FontState to use
      * @return the width of the character
      */
-    public static int getCharWidth(char c, FontState fs) {
+    public static int getCharWidth(char c, Font fs) {
         int width;
 
         if ((c == '\n') || (c == '\r') || (c == '\t') || (c == '\u00A0')) {