--- /dev/null
+/*
+ * $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 <jtauber@jtauber.com>. For more information on the Apache
+ * Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.control;
+
+// Java
+import java.util.Map;
+
+// FOP
+import org.apache.fop.fonts.FontMetrics;
+
+/**
+ * The FontInfo for the layout and rendering of a fo document.
+ * This stores the list of available fonts that are setup by
+ * the renderer. The font name can be retrieved for the
+ * family style and weight.
+ * <br>
+ * Currently font supported font-variant small-caps is not
+ * implemented.
+ */
+public class Document {
+
+ /** Default fallback key */
+ public static final String DEFAULT_FONT = "any,normal,400";
+ /** Normal font weight */
+ public static final int NORMAL = 400;
+ /** Bold font weight */
+ public static final int BOLD = 700;
+
+ /** Map containing fonts that have been used */
+ private Map usedFonts;
+
+ /** look up a font-triplet to find a font-name */
+ private Map triplets;
+
+ /** look up a font-name to get a font (that implements FontMetrics at least) */
+ private Map fonts;
+
+ /**
+ * Main constructor
+ */
+ public Document() {
+ this.triplets = new java.util.HashMap();
+ this.fonts = new java.util.HashMap();
+ this.usedFonts = new java.util.HashMap();
+ }
+
+ /**
+ * Checks if the font setup is valid (At least the ultimate fallback font
+ * must be registered.)
+ * @return True if valid
+ */
+ public boolean isSetupValid() {
+ return triplets.containsKey(DEFAULT_FONT);
+ }
+
+ /**
+ * Adds a new font triplet.
+ * @param name internal key
+ * @param family font family name
+ * @param style font style (normal, italic, oblique...)
+ * @param weight font weight
+ */
+ public void addFontProperties(String name, String family, String style,
+ int weight) {
+ /*
+ * add the given family, style and weight as a lookup for the font
+ * with the given name
+ */
+
+ String key = createFontKey(family, style, weight);
+ this.triplets.put(key, name);
+ }
+
+ /**
+ * Adds font metrics for a specific font.
+ * @param name internal key
+ * @param metrics metrics to register
+ */
+ public void addMetrics(String name, FontMetrics metrics) {
+ // add the given metrics as a font with the given name
+
+ this.fonts.put(name, metrics);
+ }
+
+ /**
+ * Lookup a font.
+ * <br>
+ * Locate the font name for a given family, style and weight.
+ * The font name can then be used as a key as it is unique for
+ * the associated document.
+ * This also adds the font to the list of used fonts.
+ * @param family font family
+ * @param style font style
+ * @param weight font weight
+ * @return internal key
+ */
+ public String fontLookup(String family, String style,
+ int weight) {
+ String key;
+ // first try given parameters
+ key = createFontKey(family, style, weight);
+ String f = (String)triplets.get(key);
+ if (f == null) {
+ // then adjust weight, favouring normal or bold
+ f = findAdjustWeight(family, style, weight);
+
+ // then try any family with orig weight
+ if (f == null) {
+ 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(DEFAULT_FONT);
+ }
+
+ }
+
+ usedFonts.put(f, fonts.get(f));
+ return f;
+ }
+
+ /**
+ * Find a font with a given family and style by trying
+ * different font weights according to the spec.
+ * @param family font family
+ * @param style font style
+ * @param weight font weight
+ * @return internal key
+ */
+ public String findAdjustWeight(String family, String style,
+ int weight) {
+ String key;
+ String f = null;
+ int newWeight = weight;
+ if (newWeight < 400) {
+ while (f == null && newWeight > 0) {
+ newWeight -= 100;
+ key = createFontKey(family, style, newWeight);
+ f = (String)triplets.get(key);
+ }
+ } else if (newWeight == 500) {
+ key = createFontKey(family, style, 400);
+ f = (String)triplets.get(key);
+ } else if (newWeight > 500) {
+ while (f == null && newWeight < 1000) {
+ newWeight += 100;
+ key = createFontKey(family, style, newWeight);
+ f = (String)triplets.get(key);
+ }
+ newWeight = weight;
+ while (f == null && newWeight > 400) {
+ newWeight -= 100;
+ key = createFontKey(family, style, newWeight);
+ f = (String)triplets.get(key);
+ }
+ }
+ if (f == null) {
+ key = createFontKey(family, style, 400);
+ f = (String)triplets.get(key);
+ }
+
+ return f;
+ }
+
+ /**
+ * Determines if a particular font is available.
+ * @param family font family
+ * @param style font style
+ * @param weight font weight
+ * @return True if available
+ */
+ public boolean hasFont(String family, String style, int weight) {
+ String key = createFontKey(family, style, weight);
+ return this.triplets.containsKey(key);
+ }
+
+ /**
+ * Creates a key from the given strings.
+ * @param family font family
+ * @param style font style
+ * @param weight font weight
+ * @return internal key
+ */
+ public static String createFontKey(String family, String style,
+ int weight) {
+ return family + "," + style + "," + weight;
+ }
+
+ /**
+ * Gets a Map of all registred fonts.
+ * @return a read-only Map with font key/FontMetrics pairs
+ */
+ public Map getFonts() {
+ return java.util.Collections.unmodifiableMap(this.fonts);
+ }
+
+ /**
+ * This is used by the renderers to retrieve all the
+ * fonts used in the document.
+ * This is for embedded font or creating a list of used fonts.
+ * @return a read-only Map with font key/FontMetrics pairs
+ */
+ public Map getUsedFonts() {
+ return this.usedFonts;
+ }
+
+ /**
+ * Returns the FontMetrics for a particular font
+ * @param fontName internal key
+ * @return font metrics
+ */
+ public FontMetrics getMetricsFor(String fontName) {
+ usedFonts.put(fontName, fonts.get(fontName));
+ return (FontMetrics)fonts.get(fontName);
+ }
+}
+
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.xml.sax.SAXException;
* Returns the FontInfo object associated with this FOInputHandler.
* @return the FontInof object
*/
- public FontInfo getFontInfo() {
+ public Document getFontInfo() {
return null;
}
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.render.Renderer;
/**
/**
* The FontInfo for this renderer.
*/
- private FontInfo fontInfo = new FontInfo();
+ private Document fontInfo = new Document();
/**
* Collection of objects that have registered to be notified about
*
* @return the font information
*/
- public FontInfo getFontInfo() {
+ public Document getFontInfo() {
return this.fontInfo;
}
*/
package org.apache.fop.fo;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
import org.apache.fop.layoutmgr.LMiter;
/** TextInfo for this object */
protected TextInfo textInfo = null;
/** FontInfo for this object */
- protected FontInfo fontInfo = null;
+ protected Document fontInfo = null;
/**
* @param parent FONode that is the parent of this object
import org.apache.fop.area.CTM;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.layout.FontState;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.CommonMarginInline;
public class PropertyManager {
private PropertyList properties;
- private FontInfo fontInfo = null;
+ private Document fontInfo = null;
private FontState fontState = null;
private CommonBorderAndPadding borderAndPadding = null;
private CommonHyphenation hyphProps = null;
* available.
* @param fontInfo available fonts
*/
- public void setFontInfo(FontInfo fontInfo) {
+ public void setFontInfo(Document fontInfo) {
this.fontInfo = fontInfo;
}
* @param fontInfo FontInfo to work with
* @return a FontState object
*/
- public FontState getFontState(FontInfo fontInfo) {
+ public FontState getFontState(Document fontInfo) {
if (fontState == null) {
if (fontInfo == null) {
fontInfo = this.fontInfo;
* @param fontInfo available fonts
* @return a TextInfo object
*/
- public TextInfo getTextLayoutProps(FontInfo fontInfo) {
+ public TextInfo getTextLayoutProps(Document fontInfo) {
if (textInfo == null) {
textInfo = new TextInfo();
textInfo.fs = getFontState(fontInfo);
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.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layout.FontState;
import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.CommonRelativePosition;
private int leaderPattern;
private int patternWidth;
/** FontInfo for this object */
- protected FontInfo fontInfo = null;
+ protected Document fontInfo = null;
/** FontState for this object */
protected FontState fontState;
protected InlineArea leaderArea = null;
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.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layout.FontState;
import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.CommonRelativePosition;
*/
public class PageNumber extends FObj {
/** FontInfo for this object */
- protected FontInfo fontInfo = null;
+ protected Document fontInfo = null;
/** FontState for this object */
protected FontState fontState;
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.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layout.FontState;
import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.CommonRelativePosition;
*/
public class PageNumberCitation extends FObj {
/** FontInfo for this object **/
- protected FontInfo fontInfo = null;
+ protected Document fontInfo = null;
/** Fontstate for this object **/
protected FontState fontState;
+++ /dev/null
-/*
- * $Id: FontInfo.java,v 1.20 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;
-
-// Java
-import java.util.Map;
-
-// FOP
-import org.apache.fop.fonts.FontMetrics;
-
-/**
- * The FontInfo for the layout and rendering of a fo document.
- * This stores the list of available fonts that are setup by
- * the renderer. The font name can be retrieved for the
- * family style and weight.
- * <br>
- * Currently font supported font-variant small-caps is not
- * implemented.
- */
-public class FontInfo {
-
- /** Default fallback key */
- public static final String DEFAULT_FONT = "any,normal,400";
- /** Normal font weight */
- public static final int NORMAL = 400;
- /** Bold font weight */
- public static final int BOLD = 700;
-
- /** Map containing fonts that have been used */
- private Map usedFonts;
-
- /** look up a font-triplet to find a font-name */
- private Map triplets;
-
- /** look up a font-name to get a font (that implements FontMetrics at least) */
- private Map fonts;
-
- /**
- * Main constructor
- */
- public FontInfo() {
- this.triplets = new java.util.HashMap();
- this.fonts = new java.util.HashMap();
- this.usedFonts = new java.util.HashMap();
- }
-
- /**
- * Checks if the font setup is valid (At least the ultimate fallback font
- * must be registered.)
- * @return True if valid
- */
- public boolean isSetupValid() {
- return triplets.containsKey(DEFAULT_FONT);
- }
-
- /**
- * Adds a new font triplet.
- * @param name internal key
- * @param family font family name
- * @param style font style (normal, italic, oblique...)
- * @param weight font weight
- */
- public void addFontProperties(String name, String family, String style,
- int weight) {
- /*
- * add the given family, style and weight as a lookup for the font
- * with the given name
- */
-
- String key = createFontKey(family, style, weight);
- this.triplets.put(key, name);
- }
-
- /**
- * Adds font metrics for a specific font.
- * @param name internal key
- * @param metrics metrics to register
- */
- public void addMetrics(String name, FontMetrics metrics) {
- // add the given metrics as a font with the given name
-
- this.fonts.put(name, metrics);
- }
-
- /**
- * Lookup a font.
- * <br>
- * Locate the font name for a given family, style and weight.
- * The font name can then be used as a key as it is unique for
- * the associated document.
- * This also adds the font to the list of used fonts.
- * @param family font family
- * @param style font style
- * @param weight font weight
- * @return internal key
- */
- public String fontLookup(String family, String style,
- int weight) {
- String key;
- // first try given parameters
- key = createFontKey(family, style, weight);
- String f = (String)triplets.get(key);
- if (f == null) {
- // then adjust weight, favouring normal or bold
- f = findAdjustWeight(family, style, weight);
-
- // then try any family with orig weight
- if (f == null) {
- 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(DEFAULT_FONT);
- }
-
- }
-
- usedFonts.put(f, fonts.get(f));
- return f;
- }
-
- /**
- * Find a font with a given family and style by trying
- * different font weights according to the spec.
- * @param family font family
- * @param style font style
- * @param weight font weight
- * @return internal key
- */
- public String findAdjustWeight(String family, String style,
- int weight) {
- String key;
- String f = null;
- int newWeight = weight;
- if (newWeight < 400) {
- while (f == null && newWeight > 0) {
- newWeight -= 100;
- key = createFontKey(family, style, newWeight);
- f = (String)triplets.get(key);
- }
- } else if (newWeight == 500) {
- key = createFontKey(family, style, 400);
- f = (String)triplets.get(key);
- } else if (newWeight > 500) {
- while (f == null && newWeight < 1000) {
- newWeight += 100;
- key = createFontKey(family, style, newWeight);
- f = (String)triplets.get(key);
- }
- newWeight = weight;
- while (f == null && newWeight > 400) {
- newWeight -= 100;
- key = createFontKey(family, style, newWeight);
- f = (String)triplets.get(key);
- }
- }
- if (f == null) {
- key = createFontKey(family, style, 400);
- f = (String)triplets.get(key);
- }
-
- return f;
- }
-
- /**
- * Determines if a particular font is available.
- * @param family font family
- * @param style font style
- * @param weight font weight
- * @return True if available
- */
- public boolean hasFont(String family, String style, int weight) {
- String key = createFontKey(family, style, weight);
- return this.triplets.containsKey(key);
- }
-
- /**
- * Creates a key from the given strings.
- * @param family font family
- * @param style font style
- * @param weight font weight
- * @return internal key
- */
- public static String createFontKey(String family, String style,
- int weight) {
- return family + "," + style + "," + weight;
- }
-
- /**
- * Gets a Map of all registred fonts.
- * @return a read-only Map with font key/FontMetrics pairs
- */
- public Map getFonts() {
- return java.util.Collections.unmodifiableMap(this.fonts);
- }
-
- /**
- * This is used by the renderers to retrieve all the
- * fonts used in the document.
- * This is for embedded font or creating a list of used fonts.
- * @return a read-only Map with font key/FontMetrics pairs
- */
- public Map getUsedFonts() {
- return this.usedFonts;
- }
-
- /**
- * Returns the FontMetrics for a particular font
- * @param fontName internal key
- * @return font metrics
- */
- public FontMetrics getMetricsFor(String fontName) {
- usedFonts.put(fontName, fonts.get(fontName));
- return (FontMetrics)fonts.get(fontName);
- }
-}
-
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.PageSequenceMaster;
import org.apache.fop.fo.pagination.SimplePageMaster;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.InstreamForeignObject;
protected MIFFile mifFile;
/** the OutputStream to write to */
protected OutputStream outStream;
- private FontInfo fontInfo = new FontInfo();
+ private Document fontInfo = new Document();
// current state elements
private MIFElement textFlow;
/**
* @see org.apache.fop.fo.FOInputHandler#getFontInfo()
*/
- public FontInfo getFontInfo() {
+ public Document getFontInfo() {
return fontInfo;
}
import org.apache.fop.area.inline.Word;
import org.apache.fop.area.inline.Character;
import org.apache.fop.fo.FOUserAgent;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
// Avalon
import org.apache.avalon.framework.logger.AbstractLogEnabled;
}
/** @see org.apache.fop.render.Renderer */
- public abstract void setupFontInfo(FontInfo fontInfo);
+ public abstract void setupFontInfo(Document fontInfo);
/** @see org.apache.fop.render.Renderer */
public void setUserAgent(FOUserAgent agent) {
// FOP
import org.apache.fop.render.pdf.FontSetup;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
// Java
import java.util.List;
public abstract class PrintRenderer extends AbstractRenderer {
/** Font configuration */
- protected FontInfo fontInfo;
+ protected Document fontInfo;
/** list of fonts */
protected List fontList = null;
*
* @param fontInfo font info to set up
*/
- public void setupFontInfo(FontInfo fontInfo) {
+ public void setupFontInfo(Document fontInfo) {
this.fontInfo = fontInfo;
FontSetup.setup(fontInfo, fontList);
}
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.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.fo.FOUserAgent;
/**
*
* @param fontInfo The fonts
*/
- void setupFontInfo(FontInfo fontInfo);
+ void setupFontInfo(Document fontInfo);
/**
* Set up renderer options.
// FOP
import org.apache.fop.apps.InputHandler;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.viewer.PreviewDialog;
import org.apache.fop.viewer.Translator;
return 0;
}
- public void setupFontInfo(FontInfo fontInfo) {
+ public void setupFontInfo(Document fontInfo) {
// create a temp Image to test font metrics on
BufferedImage fontImage =
new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
package org.apache.fop.render.awt;
// FOP
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
// Java
import java.awt.Graphics2D;
* @param fontInfo the font info object to set up
* @param graphics needed for acces to font metrics
*/
- public static void setup(FontInfo fontInfo, Graphics2D graphics) {
+ public static void setup(Document fontInfo, Graphics2D graphics) {
FontMetricsMapper metric;
int normal, bold, bolditalic, italic;
// fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
/* any is treated as serif */
- fontInfo.addFontProperties("F5", "any", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "any", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "any", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "any", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "any", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "any", "oblique", FontInfo.BOLD);
-
- fontInfo.addFontProperties("F1", "sans-serif", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F3", "sans-serif", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F5", "serif", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "serif", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "serif", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "serif", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "serif", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "serif", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F9", "monospace", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F11", "monospace", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "monospace", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "monospace", "italic", FontInfo.BOLD);
-
- fontInfo.addFontProperties("F1", "Helvetica", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F3", "Helvetica", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F5", "Times", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "Times", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F9", "Courier", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F11", "Courier", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "Courier", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "Courier", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F13", "Symbol", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", FontInfo.NORMAL);
+ fontInfo.addFontProperties("F5", "any", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "any", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "any", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "any", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "any", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F8", "any", "oblique", Document.BOLD);
+
+ fontInfo.addFontProperties("F1", "sans-serif", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F3", "sans-serif", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F5", "serif", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "serif", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "serif", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "serif", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "serif", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "serif", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F9", "monospace", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F11", "monospace", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F12", "monospace", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F12", "monospace", "italic", Document.BOLD);
+
+ fontInfo.addFontProperties("F1", "Helvetica", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F3", "Helvetica", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F5", "Times", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "Times", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F9", "Courier", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F11", "Courier", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F12", "Courier", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F12", "Courier", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F13", "Symbol", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Document.NORMAL);
// Custom type 1 fonts step 2/2
// fontInfo.addFontProperties("F15", "OMEP", "normal", FontInfo.NORMAL);
// fontInfo.addFontProperties("F17", "BauerBodoni", "italic", FontInfo.BOLD);
/* for compatibility with PassiveTex */
- fontInfo.addFontProperties("F5", "Times-Roman", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "Times-Roman", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F5", "Times Roman", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "Times Roman", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "italic", FontInfo.BOLD);
+ fontInfo.addFontProperties("F5", "Times-Roman", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "Times-Roman", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F5", "Times Roman", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "Times Roman", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", "italic", Document.BOLD);
fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
- "normal", FontInfo.NORMAL);
+ "normal", Document.NORMAL);
}
}
import org.apache.fop.fonts.FontDescriptor;
import org.apache.fop.fonts.FontUtil;
import org.apache.fop.fonts.LazyFont;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.pdf.PDFResources;
// FOP (base 14 fonts)
* @param fontInfo the font info object to set up
* @param embedList ???
*/
- public static void setup(FontInfo fontInfo, List embedList) {
+ public static void setup(Document fontInfo, List embedList) {
fontInfo.addMetrics("F1", new Helvetica());
fontInfo.addMetrics("F2", new HelveticaOblique());
// fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
/* any is treated as serif */
- fontInfo.addFontProperties("F5", "any", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "any", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "any", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "any", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "any", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "any", "oblique", FontInfo.BOLD);
+ fontInfo.addFontProperties("F5", "any", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "any", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "any", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "any", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "any", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F8", "any", "oblique", Document.BOLD);
- fontInfo.addFontProperties("F1", "sans-serif", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F3", "sans-serif", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F5", "serif", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "serif", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "serif", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "serif", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "serif", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "serif", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F9", "monospace", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F11", "monospace", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "monospace", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "monospace", "italic", FontInfo.BOLD);
+ fontInfo.addFontProperties("F1", "sans-serif", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F3", "sans-serif", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F5", "serif", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "serif", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "serif", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "serif", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "serif", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "serif", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F9", "monospace", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F11", "monospace", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F12", "monospace", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F12", "monospace", "italic", Document.BOLD);
- fontInfo.addFontProperties("F1", "Helvetica", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F3", "Helvetica", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F5", "Times", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "Times", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F9", "Courier", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F11", "Courier", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "Courier", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F12", "Courier", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F13", "Symbol", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", FontInfo.NORMAL);
+ fontInfo.addFontProperties("F1", "Helvetica", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F3", "Helvetica", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F5", "Times", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "Times", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F9", "Courier", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F11", "Courier", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F12", "Courier", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F12", "Courier", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F13", "Symbol", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Document.NORMAL);
// Custom type 1 fonts step 2/2
// fontInfo.addFontProperties("F15", "OMEP", "normal", FontInfo.NORMAL);
// fontInfo.addFontProperties("F17", "BauerBodoni", "italic", FontInfo.BOLD);
/* for compatibility with PassiveTex */
- fontInfo.addFontProperties("F5", "Times-Roman", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "Times-Roman", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "italic", FontInfo.BOLD);
- fontInfo.addFontProperties("F5", "Times Roman", "normal", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "oblique", FontInfo.NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "italic", FontInfo.NORMAL);
- fontInfo.addFontProperties("F7", "Times Roman", "normal", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "oblique", FontInfo.BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "italic", FontInfo.BOLD);
+ fontInfo.addFontProperties("F5", "Times-Roman", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "Times-Roman", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", "italic", Document.BOLD);
+ fontInfo.addFontProperties("F5", "Times Roman", "normal", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", "oblique", Document.NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", "italic", Document.NORMAL);
+ fontInfo.addFontProperties("F7", "Times Roman", "normal", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", "oblique", Document.BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", "italic", Document.BOLD);
fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
- "normal", FontInfo.NORMAL);
+ "normal", Document.NORMAL);
/* Add configured fonts */
addConfiguredFonts(fontInfo, embedList, 15);
* @param fontInfos ???
* @param num starting index for internal font numbering
*/
- public static void addConfiguredFonts(FontInfo fontInfo, List fontInfos, int num) {
+ public static void addConfiguredFonts(Document fontInfo, List fontInfos, int num) {
if (fontInfos == null) {
return; //No fonts to process
}
* @param resources PDFResources object to attach the font to
* @param fontInfo font info object to get font information from
*/
- public static void addToResources(PDFDocument doc, PDFResources resources, FontInfo fontInfo) {
+ public static void addToResources(PDFDocument doc, PDFResources resources, Document fontInfo) {
Map fonts = fontInfo.getUsedFonts();
Iterator e = fonts.keySet().iterator();
while (e.hasNext()) {
* ============================================================================
* 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
* (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.render.pdf;
// Java
this.pdfDoc.setCreator(creator);
this.pdfDoc.setFilterMap(filterMap);
this.pdfDoc.outputHeader(stream);
-
+
//Setup encryption if necessary
PDFEncryptionManager.setupPDFEncryption(userAgent, this.pdfDoc, getLogger());
}
renderOutline(outline.getSubData(i), pdfOutline);
}
}
-
+
/** Saves the graphics state of the rendering engine. */
protected void saveGraphicsState() {
currentStream.add("q\n");
}
-
+
/** Restores the last graphics state of the rendering engine. */
protected void restoreGraphicsState() {
currentStream.add("Q\n");
}
-
+
/** Indicates the beginning of a text object. */
protected void beginTextObject() {
currentStream.add("BT\n");
}
-
+
/** Indicates the end of a text object. */
protected void endTextObject() {
currentStream.add("ET\n");
}
-
+
/**
* Start the next page sequence.
* For the pdf renderer there is no concept of page sequences
* immediately to the output stream.
* @see org.apache.fop.render.Renderer#renderPage(PageViewport)
*/
- public void renderPage(PageViewport page)
+ public void renderPage(PageViewport page)
throws IOException, FOPException {
if (pages != null
&& (currentPage = (PDFPage) pages.get(page)) != null) {
* @param width the width of the area
* @param height the height of the area
*/
- protected void drawBackAndBorders(Area block,
- float startx, float starty,
+ protected void drawBackAndBorders(Area block,
+ float startx, float starty,
float width, float height) {
// draw background then border
context.setProperty(PDFXMLHandler.OUTPUT_STREAM, ostream);
context.setProperty(PDFXMLHandler.PDF_STATE, currentState);
context.setProperty(PDFXMLHandler.PDF_PAGE, currentPage);
- context.setProperty(PDFXMLHandler.PDF_CONTEXT,
+ context.setProperty(PDFXMLHandler.PDF_CONTEXT,
currentContext == null ? currentPage : currentContext);
context.setProperty(PDFXMLHandler.PDF_CONTEXT, currentContext);
context.setProperty(PDFXMLHandler.PDF_STREAM, currentStream);
}
}
-
+
restoreGraphicsState();
beginTextObject();
super.renderLeader(area);
* ============================================================================
* 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
* (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.render.pdf;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.svg.PDFAElementBridge;
import org.apache.fop.svg.PDFGraphics2D;
import org.apache.fop.svg.SVGUserAgent;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
-import org.w3c.dom.Document;
+/* org.w3c.dom.Document is not imported to avoid conflict with
+ org.apache.fop.control.Document */
import java.io.OutputStream;
* @param ns the namespace of the XML document
* @throws Exception any sort of exception could be thrown and shuld be handled
*/
- public void handleXML(RendererContext context, Document doc,
+ public void handleXML(RendererContext context, org.w3c.dom.Document doc,
String ns) throws Exception {
PDFInfo pdfi = getPDFInfo(context);
pdfi.currentStream = (PDFStream)context.getProperty(PDF_STREAM);
pdfi.width = ((Integer)context.getProperty(PDF_WIDTH)).intValue();
pdfi.height = ((Integer)context.getProperty(PDF_HEIGHT)).intValue();
- pdfi.fi = (FontInfo)context.getProperty(PDF_FONT_INFO);
+ pdfi.fi = (Document)context.getProperty(PDF_FONT_INFO);
pdfi.currentFontName = (String)context.getProperty(PDF_FONT_NAME);
pdfi.currentFontSize = ((Integer)context.getProperty(PDF_FONT_SIZE)).intValue();
pdfi.currentXPosition = ((Integer)context.getProperty(PDF_XPOS)).intValue();
/** see PDF_HEIGHT */
public int height;
/** see PDF_FONT_INFO */
- public FontInfo fi;
+ public Document fi;
/** see PDF_FONT_NAME */
public String currentFontName;
/** see PDF_FONT_SIZE */
* @param doc the svg document
* @param pdfInfo the pdf information of the current context
*/
- protected void renderSVGDocument(RendererContext context, Document doc, PDFInfo pdfInfo) {
+ protected void renderSVGDocument(RendererContext context,
+ org.w3c.dom.Document doc, PDFInfo pdfInfo) {
int xOffset = pdfInfo.currentXPosition;
int yOffset = pdfInfo.currentYPosition;
//FOP
import org.apache.fop.render.pdf.FontSetup;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
/**
* This class is a wrapper for the <tt>PSGraphics2D</tt> that
super(textAsShapes);
if (!textAsShapes) {
- fontInfo = new FontInfo();
+ fontInfo = new Document();
FontSetup.setup(fontInfo, null);
//FontState fontState = new FontState("Helvetica", "normal",
// FontInfo.NORMAL, 12, 0);
* Get the font info for this PostScript document.
* @return the font information
*/
- public FontInfo getFontInfo() {
+ public Document getFontInfo() {
return fontInfo;
}
* ============================================================================
* 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
* (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.render.ps;
//Java
import java.io.IOException;
// FOP
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layout.FontState;
// Batik
/** Currently valid FontState */
protected FontState fontState;
-
+
/** Overriding FontState */
protected FontState overrideFontState = null;
-
+
/**
* the current (internal) font name
*/
protected Color currentColour = new Color(0, 0, 0);
/** FontInfo containing all available fonts */
- protected FontInfo fontInfo;
+ protected Document fontInfo;
/**
* Create a new Graphics2D that generates PostScript code.
Shape imclip = getClip();
writeClip(imclip);
Color c = getColor();
- gen.writeln(gen.formatDouble(c.getRed() / 255.0) + " "
- + gen.formatDouble(c.getGreen() / 255.0) + " "
+ gen.writeln(gen.formatDouble(c.getRed() / 255.0) + " "
+ + gen.formatDouble(c.getGreen() / 255.0) + " "
+ gen.formatDouble(c.getBlue() / 255.0) + " setrgbcolor");
-
+
applyPaint(getPaint(), false);
applyStroke(getStroke());
-
+
gen.writeln("newpath");
PathIterator iter = s.getPathIterator(getTransform());
while (!iter.isDone()) {
+ " M");
break;
case PathIterator.SEG_QUADTO:
- gen.writeln(gen.formatDouble(1000 * vals[0]) + " "
- + gen.formatDouble(1000 * vals[1]) + " "
- + gen.formatDouble(1000 * vals[2]) + " "
+ gen.writeln(gen.formatDouble(1000 * vals[0]) + " "
+ + gen.formatDouble(1000 * vals[1]) + " "
+ + gen.formatDouble(1000 * vals[2]) + " "
+ gen.formatDouble(1000 * vals[3]) + " QUADTO ");
break;
case PathIterator.SEG_CLOSE:
+ " M");
break;
case PathIterator.SEG_QUADTO:
- gen.writeln(gen.formatDouble(1000 * vals[0]) + " "
- + gen.formatDouble(1000 * vals[1]) + " "
- + gen.formatDouble(1000 * vals[2]) + " "
+ gen.writeln(gen.formatDouble(1000 * vals[0]) + " "
+ + gen.formatDouble(1000 * vals[1]) + " "
+ + gen.formatDouble(1000 * vals[2]) + " "
+ gen.formatDouble(1000 * vals[3]) + " QUADTO ");
break;
case PathIterator.SEG_CLOSE:
try {
if (stroke instanceof BasicStroke) {
BasicStroke bs = (BasicStroke)stroke;
-
+
float[] da = bs.getDashArray();
if (da != null) {
gen.writeln("[");
gen.writeln(2 + " setlinecap");
break;
}
-
+
int lj = bs.getLineJoin();
switch (lj) {
case BasicStroke.JOIN_MITER:
}
float lw = bs.getLineWidth();
gen.writeln(gen.formatDouble(1000 * lw) + " setlinewidth");
-
+
float ml = bs.getMiterLimit();
gen.writeln(gen.formatDouble(1000 * ml) + " setmiterlimit");
}
int siz = gFont.getSize();
String style = gFont.isItalic() ? "italic" : "normal";
String weight = gFont.isBold() ? "bold" : "normal";
-
+
//try {
//fontState = new FontState(n, fontState.getFontMetrics(),siz);
//} catch (org.apache.fop.apps.FOPException fope) {
Shape imclip = getClip();
writeClip(imclip);
Color c = getColor();
- gen.writeln(c.getRed() / 255.0 + " "
- + c.getGreen() / 255.0 + " "
+ gen.writeln(c.getRed() / 255.0 + " "
+ + c.getGreen() / 255.0 + " "
+ c.getBlue() / 255.0 + " setrgbcolor");
-
+
AffineTransform trans = getTransform();
trans.translate(x, y);
double[] vals = new double[6];
+ gen.formatDouble(1000 * vals[5]) + " moveto ");
//String fontWeight = fontState.getFontWeight();
StringBuffer sb = new StringBuffer();
-
+
int l = s.length();
- if ((currentFontName != fontState.getFontName())
+ if ((currentFontName != fontState.getFontName())
|| (currentFontSize != fontState.getFontSize())) {
gen.writeln(fontState.getFontName() + " " + fontState.getFontSize() + " F");
currentFontName = fontState.getFontName();
psString = " (" + sb.toString() + ") " + " t ";
gen.writeln(" 1.0 -1.0 scale");
- gen.writeln(psString);
+ gen.writeln(psString);
gen.writeln(" 1.0 -1.0 scale");
} catch (IOException ioe) {
handleIOException(ioe);
float y) {
try {
System.err.println("drawString(AttributedCharacterIterator)");
-
+
gen.writeln("BT");
Shape imclip = getClip();
writeClip(imclip);
c = getBackground();
Color col = new Color(c.getRed(), c.getGreen(), c.getBlue());
//gen.writeln(col.getColorSpaceOut(false));
-
+
AffineTransform trans = getTransform();
trans.translate(x, y);
double[] vals = new double[6];
trans.getMatrix(vals);
-
+
for (char ch = iterator.first(); ch != CharacterIterator.DONE;
ch = iterator.next()) {
//Map attr = iterator.getAttributes();
-
+
gen.writeln(gen.formatDouble(vals[0]) + " "
+ gen.formatDouble(vals[1]) + " "
+ gen.formatDouble(vals[2]) + " "
+ gen.formatDouble(vals[6]) + " Tm [" + ch
+ "]");
}
-
+
gen.writeln("ET");
} catch (IOException ioe) {
handleIOException(ioe);
gen.writeln(gen.formatDouble(c.getRed() / 255.0) + " "
+ gen.formatDouble(c.getGreen() / 255.0) + " "
+ gen.formatDouble(c.getBlue() / 255.0) + " setrgbcolor");
-
+
applyPaint(getPaint(), true);
-
+
gen.writeln("newpath");
PathIterator iter = s.getPathIterator(getTransform());
while (!iter.isDone()) {
+ " M");
break;
case PathIterator.SEG_QUADTO:
- gen.writeln(gen.formatDouble(1000 * vals[0]) + " "
- + gen.formatDouble(1000 * vals[1]) + " "
- + gen.formatDouble(1000 * vals[2]) + " "
+ gen.writeln(gen.formatDouble(1000 * vals[0]) + " "
+ + gen.formatDouble(1000 * vals[1]) + " "
+ + gen.formatDouble(1000 * vals[2]) + " "
+ gen.formatDouble(1000 * vals[3]) + " QUADTO ");
break;
case PathIterator.SEG_CLOSE:
* @param nonzero ???
* @exception IOException In case of an I/O problem
*/
- protected void doDrawing(boolean fill, boolean stroke, boolean nonzero)
+ protected void doDrawing(boolean fill, boolean stroke, boolean nonzero)
throws IOException {
if (fill) {
if (stroke) {
public void setOverrideFontState(FontState infont) {
overrideFontState = infont;
}
-
+
/**
* Gets the font metrics for the specified font.
* @return the font metrics for the specified font.
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.Glyphs;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
/**
* This class defines the basic resources (procsets) used by FOP's PostScript
* @param fontInfo available fonts
* @throws IOException in case of an I/O problem
*/
- public static void writeFontDict(PSGenerator gen, FontInfo fontInfo)
+ public static void writeFontDict(PSGenerator gen, Document fontInfo)
throws IOException {
gen.writeln("%%BeginResource: procset FOPFonts");
gen.writeln("%%Title: Font setup (shortcuts) for this file");
* ============================================================================
* 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
* (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.render.ps;
// Java
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.fonts.Font;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.image.ImageFactory;
import org.apache.fop.traits.BorderProps;
-import org.w3c.dom.Document;
+/* org.w3c.dom.Document is not imported to avoid conflict with
+ org.apache.fop.control.Document */
+
/**
* Renderer that renders to PostScript.
* <br>
* <br>
* The PS renderer operates in millipoints as the layout engine. Since PostScript
* initially uses points, scaling is applied as needed.
- *
+ *
* @author <a href="mailto:fop-dev@xml.apache.org">Apache XML FOP Development Team</a>
* @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
* @version $Id: PSRenderer.java,v 1.31 2003/03/11 08:42:24 jeremias Exp $
private float currGreen;
private float currBlue;
- private FontInfo fontInfo;
+ private Document fontInfo;
/**
* @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
super.configure(cfg);
this.autoRotateLandscape = cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false);
}
-
+
/**
* @see org.apache.fop.render.Renderer#setUserAgent(FOUserAgent)
*/
handleIOTrouble(ioe);
}
}
-
+
/** Restores the last graphics state of the rendering engine. */
public void restoreGraphicsState() {
try {
handleIOTrouble(ioe);
}
}
-
+
/** Indicates the beginning of a text object. */
protected void beginTextObject() {
writeln("BT");
}
-
+
/** Indicates the end of a text object. */
protected void endTextObject() {
writeln("ET");
* @param f F part
*/
protected void concatMatrix(double a, double b,
- double c, double d,
+ double c, double d,
double e, double f) {
try {
gen.concatMatrix(a, b, c, d, e, f);
handleIOTrouble(ioe);
}
}
-
+
/**
* Concats the transformations matrix.
* @param matrix Matrix to use
handleIOTrouble(ioe);
}
}
-
+
/**
* Set up the font info
*
* @param fontInfo the font info object to set up
*/
- public void setupFontInfo(FontInfo fontInfo) {
+ public void setupFontInfo(Document fontInfo) {
/* use PDF's font setup to get PDF metrics */
org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
this.fontInfo = fontInfo;
//Setup for PostScript generation
this.gen = new PSGenerator(outputStream);
this.currentPageNumber = 0;
-
+
//PostScript Header
writeln(DSCConstants.PS_ADOBE_30);
gen.writeDSCComment(DSCConstants.CREATOR, new String[] {"FOP " + this.producer});
gen.writeDSCComment(DSCConstants.CREATION_DATE, new Object[] {new java.util.Date()});
gen.writeDSCComment(DSCConstants.PAGES, new Object[] {PSGenerator.ATEND});
gen.writeDSCComment(DSCConstants.END_COMMENTS);
-
+
//Defaults
gen.writeDSCComment(DSCConstants.BEGIN_DEFAULTS);
gen.writeDSCComment(DSCConstants.END_DEFAULTS);
-
+
//Prolog
gen.writeDSCComment(DSCConstants.BEGIN_PROLOG);
gen.writeDSCComment(DSCConstants.END_PROLOG);
-
+
//Setup
gen.writeDSCComment(DSCConstants.BEGIN_SETUP);
PSProcSets.writeFOPStdProcSet(gen);
public void renderPage(PageViewport page)
throws IOException, FOPException {
getLogger().debug("renderPage(): " + page);
-
+
this.currentPageNumber++;
- gen.writeDSCComment(DSCConstants.PAGE, new Object[]
+ gen.writeDSCComment(DSCConstants.PAGE, new Object[]
{page.getPageNumber(),
new Integer(this.currentPageNumber)});
final Integer zero = new Integer(0);
new Double(pspageheight)});
if (this.autoRotateLandscape) {
gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Portrait");
- }
+ }
}
- gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
+ gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
if (rotate) {
gen.writeln(Math.round(pspageheight) + " 0 translate");
gen.writeln("90 rotate");
}
gen.writeln("0.001 0.001 scale");
concatMatrix(1, 0, 0, -1, 0, pageheight);
-
- gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);
-
+
+ gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);
+
//Process page
super.renderPage(page);
-
- writeln("showpage");
+
+ writeln("showpage");
gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
gen.writeDSCComment(DSCConstants.END_PAGE);
}
protected void paintText(int rx, int bl, String text, Font font) {
saveGraphicsState();
writeln("1 0 0 -1 " + rx + " " + bl + " Tm");
-
+
int initialSize = text.length();
initialSize += initialSize / 2;
StringBuffer sb = new StringBuffer(initialSize);
// This assumes that *all* CIDFonts use a /ToUnicode mapping
Font f = (Font)fontInfo.getFonts().get(fontname);
-
+
//Determine position
int rx = currentBlockIPPosition;
int bl = currentBPPosition + area.getOffset();
useFont(fontname, fontsize);
-
+
paintText(rx, bl, area.getWord(), f);
/*
String psString = null;
if (area.getFontState().getLetterSpacing() > 0) {
- //float f = area.getFontState().getLetterSpacing()
+ //float f = area.getFontState().getLetterSpacing()
// * 1000 / this.currentFontSize;
float f = area.getFontState().getLetterSpacing();
psString = (new StringBuffer().append(f).append(" 0.0 (")
}
currentFontName = saveFontName;
}
-
+
/**
* @see org.apache.fop.render.AbstractRenderer#startVParea(CTM)
*/
// Set the given CTM in the graphics state
//currentState.push();
//currentState.setTransform(new AffineTransform(CTMHelper.toPDFArray(ctm)));
-
+
saveGraphicsState();
// multiply with current CTM
//writeln(CTMHelper.toPDFString(ctm) + " cm\n");
final double[] matrix = ctm.toArray();
concatMatrix(matrix);
-
+
// Set clip?
- beginTextObject();
+ beginTextObject();
}
/**
* @param height the height of the area
*/
protected void drawBackAndBorders(Area block,
- float startx, float starty,
+ float startx, float starty,
float width, float height) {
// draw background then border
writeln(startx + " " + starty + " M ");
writeln(endx + " " + endy + " lineto");
}
-
+
private void updateColor(ColorType col, boolean fill, StringBuffer pdf) {
- writeln(gen.formatDouble(col.getRed()) + " "
- + gen.formatDouble(col.getGreen()) + " "
+ writeln(gen.formatDouble(col.getRed()) + " "
+ + gen.formatDouble(col.getGreen()) + " "
+ gen.formatDouble(col.getBlue()) + " setrgbcolor");
}
* @see org.apache.fop.render.AbstractRenderer#renderForeignObject(ForeignObject, Rectangle2D)
*/
public void renderForeignObject(ForeignObject fo, Rectangle2D pos) {
- Document doc = fo.getDocument();
+ org.w3c.dom.Document doc = fo.getDocument();
String ns = fo.getNameSpace();
renderDocument(doc, ns, pos);
}
* @param ns Namespace for the XML document
* @param pos Position for the generated graphic/image
*/
- public void renderDocument(Document doc, String ns, Rectangle2D pos) {
+ public void renderDocument(org.w3c.dom.Document doc, String ns, Rectangle2D pos) {
RendererContext context;
context = new RendererContext(MIME_TYPE);
context.setUserAgent(userAgent);
context.setProperty(PSXMLHandler.PS_YPOS,
new Integer(currentBPPosition + (int) pos.getY()));
//context.setProperty("strokeSVGText", options.get("strokeSVGText"));
-
+
/*
context.setProperty(PDFXMLHandler.PDF_DOCUMENT, pdfDoc);
context.setProperty(PDFXMLHandler.OUTPUT_STREAM, ostream);
context.setProperty(PDFXMLHandler.PDF_STATE, currentState);
context.setProperty(PDFXMLHandler.PDF_PAGE, currentPage);
- context.setProperty(PDFXMLHandler.PDF_CONTEXT,
+ context.setProperty(PDFXMLHandler.PDF_CONTEXT,
currentContext == null ? currentPage: currentContext);
context.setProperty(PDFXMLHandler.PDF_CONTEXT, currentContext);
context.setProperty(PDFXMLHandler.PDF_STREAM, currentStream);
new Integer((int) pos.getWidth()));
context.setProperty(PDFXMLHandler.PDF_HEIGHT,
new Integer((int) pos.getHeight()));
- */
+ */
userAgent.renderXML(context, doc, ns);
}
-
+
}
* ============================================================================
* 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
* (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.render.ps;
//import org.apache.batik.gvt.TextNode;
//import org.apache.batik.bridge.TextUtilities;
import org.apache.batik.gvt.GraphicsNode;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
* @version $Id: PSTextElementBridge.java,v 1.2 2003/03/07 09:46:30 jeremias Exp $
*/
public class PSTextElementBridge extends SVGTextElementBridge {
-
+
//private PSTextPainter textPainter;
/**
* Constructs a new bridge for the <text> element.
* @param fi the font infomration
*/
- public PSTextElementBridge(FontInfo fi) {
+ public PSTextElementBridge(Document fi) {
//textPainter = new PSTextPainter(fi);
}
}
*/
-
+
for (Node n = element.getFirstChild();
n != null;
n = n.getNextSibling()) {
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.layout.FontState;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
/**
* Renders the attributed character iterator of a <tt>TextNode</tt>.
* @version $Id: PSTextPainter.java,v 1.15 2003/01/08 14:03:55 jeremias Exp $
*/
public class PSTextPainter implements TextPainter {
- private FontInfo fontInfo;
+ private Document fontInfo;
/**
* Use the stroking text painter to get the bounds and shape.
* Create a new PS text painter with the given font information.
* @param fi the fint info
*/
- public PSTextPainter(FontInfo fi) {
+ public PSTextPainter(Document fi) {
fontInfo = fi;
}
String style = ((posture != null) && (posture.floatValue() > 0.0))
? "italic" : "normal";
int weight = ((taWeight != null)
- && (taWeight.floatValue() > 1.0)) ? FontInfo.BOLD
- : FontInfo.NORMAL;
+ && (taWeight.floatValue() > 1.0)) ? Document.BOLD
+ : Document.NORMAL;
FontState fontState = null;
- FontInfo fi = fontInfo;
+ Document fi = fontInfo;
boolean found = false;
String fontFamily = null;
if (gvtFonts != null) {
}
if (!found) {
String fname =
- fontInfo.fontLookup("any", style, FontInfo.NORMAL);
+ fontInfo.fontLookup("any", style, Document.NORMAL);
FontMetrics metrics = fontInfo.getMetricsFor(fname);
int fsize = (int)(size.floatValue() * 1000);
fontState = new FontState(fname, metrics, fsize);
}
}
int fStyle = Font.PLAIN;
- if (weight == FontInfo.BOLD) {
+ if (weight == Document.BOLD) {
if (style.equals("italic")) {
fStyle = Font.BOLD | Font.ITALIC;
} else {
* ============================================================================
* 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
* (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.render.ps;
//AffineTransform currentTransform = new AffineTransform(1, 0, 0, 1, 0, 0);
//pdfAElementBridge.setCurrentTransform(currentTransform);
//ctx.putBridge(pdfAElementBridge);
-
+
//ctx.putBridge(new PSImageElementBridge());
GraphicsNode gvtRoot;
try {
try {
graphics.setupDocument(output.getOutputStream(), w, h);
graphics.setSVGDimension(docWidth, docHeight);
-
+
if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) {
graphics.setBackgroundColor((Color)hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR));
}
graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
graphics.setTransform(px);
-
+
gvtRoot.paint(graphics);
graphics.finish();
* ============================================================================
* 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
* (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.render.ps;
// Java
import java.io.IOException;
// DOM
-import org.w3c.dom.Document;
+/* org.w3c.dom.Document is not imported to avoid conflict with
+ org.apache.fop.control.Document */
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
import org.apache.batik.gvt.TextPainter;
// FOP
+import org.apache.fop.control.Document;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.render.RendererContext;
import org.apache.fop.svg.SVGUserAgent;
-import org.apache.fop.layout.FontInfo;
/**
* PostScript XML handler.
* @param ns the namespace of the XML document
* @throws Exception any sort of exception could be thrown and shuld be handled
*/
- public void handleXML(RendererContext context, Document doc,
+ public void handleXML(RendererContext context, org.w3c.dom.Document doc,
String ns) throws Exception {
PSInfo psi = getPSInfo(context);
public static PSInfo getPSInfo(RendererContext context) {
PSInfo psi = new PSInfo();
psi.psGenerator = (PSGenerator)context.getProperty(PS_GENERATOR);
- psi.fontInfo = (FontInfo)context.getProperty(PS_FONT_INFO);
+ psi.fontInfo = (org.apache.fop.control.Document)context.getProperty(PS_FONT_INFO);
psi.width = ((Integer)context.getProperty(PS_WIDTH)).intValue();
psi.height = ((Integer)context.getProperty(PS_HEIGHT)).intValue();
psi.currentXPosition = ((Integer)context.getProperty(PS_XPOS)).intValue();
* PostScript information structure for drawing the XML document.
*/
public static class PSInfo {
-
+
/** see PS_GENERATOR */
private PSGenerator psGenerator;
/** see PS_FONT_INFO */
- private FontInfo fontInfo;
+ private org.apache.fop.control.Document fontInfo;
/** see PS_PAGE_WIDTH */
private int width;
/** see PS_PAGE_HEIGHT */
* Returns the fontInfo.
* @return FontInfo
*/
- public FontInfo getFontInfo() {
+ public org.apache.fop.control.Document getFontInfo() {
return fontInfo;
}
* Sets the fontInfo.
* @param fontInfo The fontInfo to set
*/
- public void setFontInfo(FontInfo fontInfo) {
+ public void setFontInfo(org.apache.fop.control.Document fontInfo) {
this.fontInfo = fontInfo;
}
* @param doc the svg document
* @param psInfo the pdf information of the current context
*/
- protected void renderSVGDocument(RendererContext context, Document doc, PSInfo psInfo) {
+ protected void renderSVGDocument(RendererContext context,
+ org.w3c.dom.Document doc, PSInfo psInfo) {
int xOffset = psInfo.currentXPosition;
int yOffset = psInfo.currentYPosition;
PSGenerator gen = psInfo.psGenerator;
transform.translate(xOffset / 1000f, yOffset / 1000f);
//aBridge.setCurrentTransform(transform);
//ctx.putBridge(aBridge);
-
+
TextPainter textPainter = new PSTextPainter(psInfo.getFontInfo());
- ctx.setTextPainter(textPainter);
+ ctx.setTextPainter(textPainter);
GraphicsNode root;
try {
root = builder.build(ctx, doc);
// and positive is down and to the right. (0,0) is where the
// viewBox puts it.
gen.concatMatrix(sx, 0, 0, sy, xOffset, yOffset);
-
+
SVGSVGElement svg = ((SVGDocument)doc).getRootElement();
- AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
+ AffineTransform at = ViewBox.getPreserveAspectRatioTransform(svg,
w / 1000f, h / 1000f);
if (!at.isIdentity()) {
double[] vals = new double[6];
at.getMatrix(vals);
gen.concatMatrix(vals);
}
-
+
/*
if (psInfo.pdfContext == null) {
psInfo.pdfContext = psInfo.pdfPage;
context.getUserAgent().getLogger().error("SVG graphic could not be rendered: "
+ e.getMessage(), e);
}
-
+
psInfo.psGenerator.restoreGraphicsState();
//psInfo.pdfState.pop();
gen.writeln("%SVG graphic end ---");
* ============================================================================
* 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
* (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.render.svg;
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.Word;
import org.apache.fop.svg.SVGUtilities;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.fo.FOUserAgent;
import org.apache.fop.fo.properties.RuleStyle;
import org.w3c.dom.Node;
import org.w3c.dom.svg.SVGSVGElement;
import org.w3c.dom.svg.SVGDocument;
-import org.w3c.dom.Document;
+/* org.w3c.dom.Document is not imported to avoid conflict with
+ org.apache.fop.control.Document */
import org.w3c.dom.Element;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Text;
* This is the SVG renderer.
*/
public class SVGRenderer extends AbstractRenderer implements XMLHandler {
-
+
/** SVG MIME type */
public static final String SVG_MIME_TYPE = "image/svg+xml";
-
+
/** SVG namespace */
public static final String SVG_NAMESPACE = SVGDOMImplementation.SVG_NAMESPACE_URI;
-
- private Document svgDocument;
+
+ private org.w3c.dom.Document svgDocument;
private Element svgRoot;
private Element currentPageG = null;
private Element lastLink = null;
/**
* @see org.apache.fop.render.Renderer#setupFontInfo(FontInfo)
*/
- public void setupFontInfo(FontInfo fontInfo) {
+ public void setupFontInfo(Document fontInfo) {
// create a temp Image to test font metrics on
BufferedImage fontImage =
new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
svgRoot = svgDocument.getDocumentElement();
/*
ProcessingInstruction pi =
- svgDocument.createProcessingInstruction("xml",
+ svgDocument.createProcessingInstruction("xml",
" version=\"1.0\" encoding=\"ISO-8859-1\"");
svgDocument.insertBefore(pi, svgRoot);
*/
// if there is a link from the last page
if (lastLink != null) {
- lastLink.setAttributeNS(null, "xlink:href", "#svgView(viewBox("
+ lastLink.setAttributeNS(null, "xlink:href", "#svgView(viewBox("
+ totalWidth + ", "
+ sequenceHeight + ", "
+ pageWidth + ", "
lastPageLink.setAttributeNS(null, "xlink:href", lastViewbox);
} else {
lastPageLink.setAttributeNS(null, "xlink:href",
- "#svgView(viewBox("
+ "#svgView(viewBox("
+ totalWidth + ", "
- + (sequenceHeight - pageHeight) + ", "
- + pageWidth + ", "
+ + (sequenceHeight - pageHeight) + ", "
+ + pageWidth + ", "
+ pageHeight + "))");
}
pagesGroup.appendChild(lastPageLink);
rect.setAttributeNS(null, "style", "fill:blue;visibility:hidden");
lastLink.appendChild(rect);
- lastViewbox = "#svgView(viewBox("
- + totalWidth + ", "
- + (sequenceHeight - pageHeight) + ", "
- + pageWidth + ", "
+ lastViewbox = "#svgView(viewBox("
+ + totalWidth + ", "
+ + (sequenceHeight - pageHeight) + ", "
+ + pageWidth + ", "
+ pageHeight + "))";
pageNumber++;
* @param fo the foreign object
*/
public void renderForeignObject(ForeignObject fo) {
- Document doc = fo.getDocument();
+ org.w3c.dom.Document doc = fo.getDocument();
String ns = fo.getNameSpace();
userAgent.renderXML(context, doc, ns);
}
/**
* @see org.apache.fop.render.XMLHandler#handleXML(RendererContext, Document, String)
*/
- public void handleXML(RendererContext context, Document doc,
+ public void handleXML(RendererContext context, org.w3c.dom.Document doc,
String ns) throws Exception {
if (SVG_NAMESPACE.equals(ns)) {
if (!(doc instanceof SVGDocument)) {
* ============================================================================
* 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
* (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.render.xml;
// Java
import java.awt.geom.Rectangle2D;
// XML
-import org.w3c.dom.Document;
+/* org.w3c.dom.Document is not imported to avoid conflict with
+ org.apache.fop.control.Document */
// FOP
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.fo.FOUserAgent;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.BeforeFloat;
import org.apache.fop.area.Block;
* which can be rendered to any renderer.
*/
public class XMLRenderer extends AbstractRenderer {
-
+
/** XML MIME type */
public static final String XML_MIME_TYPE = "text/xml";
*
* @param fontInfo the font info object to set up
*/
- public void setupFontInfo(FontInfo fontInfo) {
+ public void setupFontInfo(Document fontInfo) {
/* use PDF's font setup to get PDF metrics */
org.apache.fop.render.pdf.FontSetup.setup(fontInfo, null);
*/
public void renderForeignObject(ForeignObject fo) {
writeStartTag("<foreignObject>");
- Document doc = fo.getDocument();
+ org.w3c.dom.Document doc = fo.getDocument();
String ns = fo.getNameSpace();
context.setProperty(XMLXMLHandler.WRITER, writer);
userAgent.renderXML(context, doc, ns);
style = "ridge";
break;
}
- writeElement("<leader width=\"" + area.getWidth()
+ writeElement("<leader width=\"" + area.getWidth()
+ "\" ruleStyle=\"" + style
- + "\" ruleThickness=\"" + area.getRuleThickness()
+ + "\" ruleThickness=\"" + area.getRuleThickness()
+ "\"/>");
super.renderLeader(area);
}
import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.properties.Constants;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfColorTable;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
*/
public class RTFHandler extends FOInputHandler {
- private FontInfo fontInfo = new FontInfo();
+ private Document fontInfo = new Document();
private RtfFile rtfFile;
private final OutputStream os;
private RtfSection sect;
/**
* @see org.apache.fop.fo.FOInputHandler#getFontInfo()
*/
- public FontInfo getFontInfo() {
+ public Document getFontInfo() {
return this.fontInfo;
}
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import java.awt.Graphics;
import java.awt.Font;
super(textAsShapes);
if (!textAsShapes) {
- fontInfo = new FontInfo();
+ fontInfo = new Document();
FontSetup.setup(fontInfo, null);
//FontState fontState = new FontState("Helvetica", "normal",
// FontInfo.NORMAL, 12, 0);
*/
public void initialize() throws Exception {
if (this.fontInfo == null) {
- fontInfo = new FontInfo();
+ fontInfo = new Document();
FontSetup.setup(fontInfo, this.fontList);
//FontState fontState = new FontState("Helvetica", "normal",
// FontInfo.NORMAL, 12, 0);
* Get the font info for this pdf document.
* @return the font information
*/
- public FontInfo getFontInfo() {
+ public Document getFontInfo() {
return fontInfo;
}
* ============================================================================
* 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
* (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.svg;
import org.apache.fop.pdf.PDFResourceContext;
import org.apache.fop.pdf.PDFLink;
import org.apache.fop.pdf.PDFAnnotList;
import org.apache.fop.pdf.BitmapImage;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layout.FontState;
import org.apache.fop.render.pdf.FontSetup;
import org.apache.fop.fonts.FontMetrics;
/**
* The current font information.
*/
- protected FontInfo fontInfo;
+ protected Document fontInfo;
/**
* The override font state used when drawing text and the font cannot be
* @param font the current font name
* @param size the current font size
*/
- public PDFGraphics2D(boolean textAsShapes, FontInfo fi, PDFDocument doc,
+ public PDFGraphics2D(boolean textAsShapes, Document fi, PDFDocument doc,
PDFResourceContext page, String pref, String font, float size) {
super(textAsShapes);
pdfDoc = doc;
b = trans.createTransformedShape(b);
if (b != null) {
Rectangle rect = b.getBounds();
-
+
if (linkType != PDFLink.EXTERNAL) {
String pdfdest = "/FitR " + dest;
resourceContext.addAnnotation(
private void createPattern(PatternPaint pp, boolean fill) {
Rectangle2D rect = pp.getPatternRect();
- FontInfo fi = new FontInfo();
+ Document fi = new Document();
FontSetup.setup(fi, null);
PDFResources res = pdfDoc.getFactory().makeResources();
}
int siz = gFont.getSize();
String style = gFont.isItalic() ? "italic" : "normal";
- int weight = gFont.isBold() ? FontInfo.BOLD : FontInfo.NORMAL;
+ 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);
* ============================================================================
* 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
* (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.svg;
import org.apache.batik.gvt.TextNode;
import org.apache.batik.bridge.TextUtilities;
import org.apache.batik.gvt.GraphicsNode;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
* Constructs a new bridge for the <text> element.
* @param fi the font infomration
*/
- public PDFTextElementBridge(FontInfo fi) {
+ public PDFTextElementBridge(Document fi) {
pdfTextPainter = new PDFTextPainter(fi);
}
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.layout.FontState;
-import org.apache.fop.layout.FontInfo;
+import org.apache.fop.control.Document;
/**
* Renders the attributed character iterator of a <tt>TextNode</tt>.
* @version $Id: PDFTextPainter.java,v 1.16 2003/03/07 09:51:25 jeremias Exp $
*/
public class PDFTextPainter implements TextPainter {
- private FontInfo fontInfo;
+ private Document fontInfo;
/**
* Use the stroking text painter to get the bounds and shape.
* Create a new PDF text painter with the given font information.
* @param fi the fint info
*/
- public PDFTextPainter(FontInfo fi) {
+ public PDFTextPainter(Document fi) {
fontInfo = fi;
}
String style = ((posture != null) && (posture.floatValue() > 0.0))
? "italic" : "normal";
int weight = ((taWeight != null)
- && (taWeight.floatValue() > 1.0)) ? FontInfo.BOLD
- : FontInfo.NORMAL;
+ && (taWeight.floatValue() > 1.0)) ? Document.BOLD
+ : Document.NORMAL;
FontState fontState = null;
- FontInfo fi = fontInfo;
+ Document fi = fontInfo;
boolean found = false;
String fontFamily = null;
if (gvtFonts != null) {
}
if (!found) {
String fname =
- fontInfo.fontLookup("any", style, FontInfo.NORMAL);
+ fontInfo.fontLookup("any", style, Document.NORMAL);
FontMetrics metrics = fontInfo.getMetricsFor(fname);
int fsize = (int)(size.floatValue() * 1000);
fontState = new FontState(fname, metrics, fsize);
}
}
int fStyle = Font.PLAIN;
- if (weight == FontInfo.BOLD) {
+ if (weight == Document.BOLD) {
if (style.equals("italic")) {
fStyle = Font.BOLD | Font.ITALIC;
} else {
* ============================================================================
* 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
* (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.svg;
import java.awt.Color;
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
* @version $Id: PDFTranscoder.java,v 1.24 2003/03/07 09:51:26 jeremias Exp $
*/
-public class PDFTranscoder extends AbstractFOPTranscoder
+public class PDFTranscoder extends AbstractFOPTranscoder
implements Configurable {
private Configuration cfg;
public PDFTranscoder() {
super();
this.handler = new FOPErrorHandler();
-
+
}
/**
* ============================================================================
* 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
* (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.tools;
// Java
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
-import org.w3c.dom.Document;
+/* org.w3c.dom.Document is not imported to avoid conflict with
+ org.apache.fop.control.Document */
// Batik
import org.apache.batik.dom.svg.SVGDOMImplementation;
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.layout.FontInfo;
+import org.apache.fop.control.Document;
import org.apache.fop.layout.FontState;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.pdf.PDFRenderer;
rend = new SVGRenderer();
}
setupLogger(rend);
- FontInfo fi = new FontInfo();
+ Document fi = new Document();
rend.setupFontInfo(fi);
FOUserAgent ua = new FOUserAgent();
setupLogger(ua);
class TreeLoader extends AbstractLogEnabled {
private AreaTree areaTree;
private AreaTreeModel model;
- private FontInfo fontInfo;
+ private Document fontInfo;
private FontState currentFontState;
- TreeLoader(FontInfo fi) {
+ TreeLoader(Document fi) {
fontInfo = fi;
}
}
public void buildAreaTree(InputStream is) {
- Document doc = null;
+ org.w3c.dom.Document doc = null;
try {
DocumentBuilderFactory fact =
DocumentBuilderFactory.newInstance();
Character ch =
new Character(getString((Element) obj).charAt(0));
addTraits((Element) obj, ch);
- String fname = fontInfo.fontLookup("sans-serif", "normal", FontInfo.NORMAL);
+ String fname = fontInfo.fontLookup("sans-serif", "normal", Document.NORMAL);
FontMetrics metrics = fontInfo.getMetricsFor(fname);
currentFontState =
new FontState(fname, metrics, 12000);
list.add(leader);
}
} else if (obj.getNodeName().equals("word")) {
- String fname = fontInfo.fontLookup("sans-serif", "normal", FontInfo.NORMAL);
+ String fname = fontInfo.fontLookup("sans-serif", "normal", Document.NORMAL);
FontMetrics metrics = fontInfo.getMetricsFor(fname);
currentFontState =
new FontState(fname, metrics, 12000);
}
ForeignObject getForeignObject(Element root) {
- Document doc;
+ org.w3c.dom.Document doc;
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
NodeList childs = root.getChildNodes();