// 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;
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;
* @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;
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;
}
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;
*/
public class TextInfo {
/** object containing the font information */
- public FontState fs;
+ public Font fs;
/** fo:color property */
public ColorType color;
/** fo:wrap-option property */
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;
/** FontInfo for this object */
protected Document fontInfo = null;
/** FontState for this object */
- protected FontState fontState;
+ protected Font fontState;
protected InlineArea leaderArea = null;
/**
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;
/** FontInfo for this object */
protected Document fontInfo = null;
/** FontState for this object */
- protected FontState fontState;
+ protected Font fontState;
private float red;
private float green;
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;
/** FontInfo for this object **/
protected Document fontInfo = null;
/** Fontstate for this object **/
- protected FontState fontState;
+ protected Font fontState;
private float red;
private float green;
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;
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();
--- /dev/null
+/*
+ * $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();
+ }
+}
+
+
+
+++ /dev/null
-/*
- * $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();
- }
-}
-
-
-
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.
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
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;
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);
* @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 ? "> " : ") ";
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;
// 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;
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
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";
* Sets the overrideing font state.
* @param infont FontState to set
*/
- public void setOverrideFontState(FontState infont) {
+ public void setOverrideFontState(Font infont) {
overrideFontState = infont;
}
* @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);
}
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 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;
/**
&& (taWeight.floatValue() > 1.0)) ? Document.BOLD
: Document.NORMAL;
- FontState fontState = null;
+ Font fontState = null;
Document fi = fontInfo;
boolean found = false;
String fontFamily = null;
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;
}
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);
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(' '));
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;
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;
* 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
*
* @param infont the font state to use
*/
- public void setOverrideFontState(FontState infont) {
+ public void setOverrideFontState(Font infont) {
ovFontState = infont;
}
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";
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;
}
float y) {
System.err.println("drawString(AttributedCharacterIterator)");
- FontState fontState = null;
+ Font fontState = null;
Shape imclip = getClip();
writeClip(imclip);
* @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);
}
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;
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;
/**
&& (taWeight.floatValue() > 1.0)) ? Document.BOLD
: Document.NORMAL;
- FontState fontState = null;
+ Font fontState = null;
Document fi = fontInfo;
boolean found = false;
String fontFamily = null;
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;
}
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);
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(' '));
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;
private AreaTree areaTree;
private AreaTreeModel model;
private Document fontInfo;
- private FontState currentFontState;
+ private Font currentFontState;
TreeLoader(Document fi) {
fontInfo = fi;
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());
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);
*/
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
* @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')) {