diff options
author | Glen Mazza <gmazza@apache.org> | 2004-04-22 21:38:41 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-04-22 21:38:41 +0000 |
commit | 5f10d185607e02344e132f258cad975e0e0b2d06 (patch) | |
tree | 747d7ce01542f00167bc3e8cd0117b9a2358b24e /src/java/org/apache/fop/render | |
parent | 480a7d7c4949203e119c2b07f53ef333cbba2f69 (diff) | |
download | xmlgraphics-fop-5f10d185607e02344e132f258cad975e0e0b2d06.tar.gz xmlgraphics-fop-5f10d185607e02344e132f258cad975e0e0b2d06.zip |
PR:
Obtained from:
Submitted by:
Reviewed by:
Patch #28525 applied -- new FontInfo class.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197531 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render')
18 files changed, 53 insertions, 57 deletions
diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index cc4781649..c76b8f3b6 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -61,7 +61,7 @@ import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.Character; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.FOTreeControl; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.fo.pagination.Region; import org.apache.commons.logging.Log; @@ -170,7 +170,7 @@ public abstract class AbstractRenderer /** * @see org.apache.fop.render.Renderer */ - public abstract void setupFontInfo(FOTreeControl foTreeControl); + public abstract void setupFontInfo(FontInfo fontInfo); /** * @see org.apache.fop.render.Renderer diff --git a/src/java/org/apache/fop/render/PrintRenderer.java b/src/java/org/apache/fop/render/PrintRenderer.java index edeb1b542..c12d52465 100644 --- a/src/java/org/apache/fop/render/PrintRenderer.java +++ b/src/java/org/apache/fop/render/PrintRenderer.java @@ -20,7 +20,7 @@ package org.apache.fop.render; // FOP import org.apache.fop.apps.Document; -import org.apache.fop.fo.FOTreeControl; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontSetup; // Java @@ -30,7 +30,7 @@ import java.util.List; public abstract class PrintRenderer extends AbstractRenderer { /** Font configuration */ - protected FOTreeControl fontInfo; + protected FontInfo fontInfo; /** list of fonts */ protected List fontList = null; @@ -40,9 +40,9 @@ public abstract class PrintRenderer extends AbstractRenderer { * * @param fontInfo font info to set up */ - public void setupFontInfo(FOTreeControl foTreeControl) { - this.fontInfo = foTreeControl; - FontSetup.setup((Document)fontInfo, fontList); + public void setupFontInfo(FontInfo inFontInfo) { + this.fontInfo = inFontInfo; + FontSetup.setup(fontInfo, fontList); } } diff --git a/src/java/org/apache/fop/render/Renderer.java b/src/java/org/apache/fop/render/Renderer.java index 62446bf0b..d977e6a40 100644 --- a/src/java/org/apache/fop/render/Renderer.java +++ b/src/java/org/apache/fop/render/Renderer.java @@ -35,7 +35,7 @@ import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.Viewport; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.fo.FOTreeControl; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.apps.FOUserAgent; import org.apache.commons.logging.Log; @@ -92,9 +92,9 @@ public interface Renderer { /** * Set up the given FontInfo. * - * @param fontInfo The fonts + * @param fontInfo The font information */ - void setupFontInfo(FOTreeControl foTreeControl); + void setupFontInfo(FontInfo fontInfo); /** * Set up renderer options. diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java index 684c2a549..552e59bcf 100644 --- a/src/java/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java @@ -45,7 +45,7 @@ import java.io.OutputStream; import java.util.Map; import java.util.Vector; -import org.apache.fop.apps.Document; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.InputHandler; import org.apache.fop.area.Area; @@ -79,7 +79,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable private BufferedImage currentPageImage = null; /** Font configuration */ - protected Document fontInfo; + protected FontInfo fontInfo; /** The InputHandler associated with this Renderer. @@ -125,9 +125,9 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable return translator; } - public void setupFontInfo(FOTreeControl foTreeControl) { + public void setupFontInfo(FontInfo inFontInfo) { // create a temp Image to test font metrics on - fontInfo = (Document) foTreeControl; + fontInfo = inFontInfo; BufferedImage fontImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); FontSetup.setup(fontInfo, fontImage.createGraphics()); diff --git a/src/java/org/apache/fop/render/awt/FontSetup.java b/src/java/org/apache/fop/render/awt/FontSetup.java index cdac2ddb8..0c7811003 100644 --- a/src/java/org/apache/fop/render/awt/FontSetup.java +++ b/src/java/org/apache/fop/render/awt/FontSetup.java @@ -19,7 +19,7 @@ package org.apache.fop.render.awt; // FOP -import org.apache.fop.apps.Document; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.Font; // Java @@ -43,7 +43,7 @@ public class FontSetup { * @param fontInfo the font info object to set up * @param graphics needed for acces to font metrics */ - public static void setup(Document fontInfo, Graphics2D graphics) { + public static void setup(FontInfo fontInfo, Graphics2D graphics) { FontMetricsMapper metric; int normal, bold, bolditalic, italic; diff --git a/src/java/org/apache/fop/render/mif/MIFHandler.java b/src/java/org/apache/fop/render/mif/MIFHandler.java index f8814d77d..c4283f566 100644 --- a/src/java/org/apache/fop/render/mif/MIFHandler.java +++ b/src/java/org/apache/fop/render/mif/MIFHandler.java @@ -75,7 +75,7 @@ public class MIFHandler extends FOInputHandler { public MIFHandler(Document doc, OutputStream os) { super(doc); outStream = os; - FontSetup.setup(doc, null); + FontSetup.setup(doc.getFontInfo(), null); } /** diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 52ded5175..c8729ee05 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -262,8 +262,7 @@ public class PDFRenderer extends PrintRenderer { * @see org.apache.fop.render.Renderer#stopRenderer() */ public void stopRenderer() throws IOException { - pdfDoc.getResources().addFonts(pdfDoc, - (org.apache.fop.apps.Document) fontInfo); + pdfDoc.getResources().addFonts(pdfDoc, fontInfo); pdfDoc.outputTrailer(ostream); this.pdfDoc = null; diff --git a/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java b/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java index 04d38ecf0..38d28e90b 100644 --- a/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFXMLHandler.java @@ -30,7 +30,7 @@ import org.apache.fop.svg.PDFTextElementBridge; import org.apache.fop.svg.PDFAElementBridge; import org.apache.fop.svg.PDFGraphics2D; import org.apache.fop.svg.SVGUserAgent; -import org.apache.fop.apps.Document; +import org.apache.fop.fonts.FontInfo; /* org.w3c.dom.Document is not imported to avoid conflict with org.apache.fop.control.Document */ @@ -163,7 +163,7 @@ public class PDFXMLHandler implements XMLHandler { 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 = (Document)context.getProperty(PDF_FONT_INFO); + pdfi.fi = (FontInfo) 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(); @@ -192,7 +192,7 @@ public class PDFXMLHandler implements XMLHandler { /** see PDF_HEIGHT */ public int height; /** see PDF_FONT_INFO */ - public Document fi; + public FontInfo fi; /** see PDF_FONT_NAME */ public String currentFontName; /** see PDF_FONT_SIZE */ diff --git a/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java index ed3e57385..f8ffd9938 100644 --- a/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/AbstractPSDocumentGraphics2D.java @@ -69,7 +69,7 @@ public abstract class AbstractPSDocumentGraphics2D extends PSGraphics2D { if (!textAsShapes) { this.document = new Document(null); - FontSetup.setup(this.document, null); + FontSetup.setup(this.document.getFontInfo(), null); } } diff --git a/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java index 340ac85de..73f7b3fac 100644 --- a/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/EPSDocumentGraphics2D.java @@ -70,7 +70,7 @@ public class EPSDocumentGraphics2D extends AbstractPSDocumentGraphics2D { PSProcSets.writeFOPStdProcSet(gen); PSProcSets.writeFOPEPSProcSet(gen); if (document != null) { - PSProcSets.writeFontDict(gen, document); + PSProcSets.writeFontDict(gen, document.getFontInfo()); } gen.writeDSCComment(DSCConstants.END_PROLOG); } diff --git a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java index ce419f722..73da1b243 100644 --- a/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSDocumentGraphics2D.java @@ -57,7 +57,7 @@ public class PSDocumentGraphics2D extends AbstractPSDocumentGraphics2D { if (!textAsShapes) { this.document = new Document(null); - FontSetup.setup(this.document, null); + FontSetup.setup(this.document.getFontInfo(), null); } } @@ -114,7 +114,7 @@ public class PSDocumentGraphics2D extends AbstractPSDocumentGraphics2D { PSProcSets.writeFOPStdProcSet(gen); PSProcSets.writeFOPEPSProcSet(gen); if (document != null) { - PSProcSets.writeFontDict(gen, document); + PSProcSets.writeFontDict(gen, document.getFontInfo()); } gen.writeDSCComment(DSCConstants.END_SETUP); } diff --git a/src/java/org/apache/fop/render/ps/PSGraphics2D.java b/src/java/org/apache/fop/render/ps/PSGraphics2D.java index e527450d7..587cf2acf 100644 --- a/src/java/org/apache/fop/render/ps/PSGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/PSGraphics2D.java @@ -873,12 +873,12 @@ public class PSGraphics2D extends AbstractGraphics2D { String style = f.isItalic() ? "italic" : "normal"; int weight = f.isBold() ? Font.BOLD : Font.NORMAL; - String fontKey = this.document.findAdjustWeight(fontFamily, style, weight); + String fontKey = this.document.getFontInfo().findAdjustWeight(fontFamily, style, weight); if (fontKey == null) { - fontKey = this.document.findAdjustWeight("sans-serif", style, weight); + fontKey = this.document.getFontInfo().findAdjustWeight("sans-serif", style, weight); } return new Font(fontKey, - this.document.getMetricsFor(fontKey), + this.document.getFontInfo().getMetricsFor(fontKey), fontSize); } diff --git a/src/java/org/apache/fop/render/ps/PSProcSets.java b/src/java/org/apache/fop/render/ps/PSProcSets.java index b6f6916d8..604239da1 100644 --- a/src/java/org/apache/fop/render/ps/PSProcSets.java +++ b/src/java/org/apache/fop/render/ps/PSProcSets.java @@ -24,7 +24,7 @@ import java.util.Map; import org.apache.fop.fonts.Typeface; import org.apache.fop.fonts.Glyphs; -import org.apache.fop.apps.Document; +import org.apache.fop.fonts.FontInfo; /** * This class defines the basic resources (procsets) used by FOP's PostScript @@ -185,7 +185,7 @@ public final class PSProcSets { * @param fontInfo available fonts * @throws IOException in case of an I/O problem */ - public static void writeFontDict(PSGenerator gen, Document fontInfo) + public static void writeFontDict(PSGenerator gen, FontInfo fontInfo) throws IOException { gen.writeln("%%BeginResource: procset FOPFonts"); gen.writeln("%%Title: Font setup (shortcuts) for this file"); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index ef39dcc5f..caf6654ea 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -41,7 +41,7 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fonts.FontSetup; import org.apache.fop.fonts.Typeface; -import org.apache.fop.apps.Document; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.render.AbstractRenderer; import org.apache.fop.render.RendererContext; import org.apache.fop.fo.FOTreeControl; @@ -50,8 +50,7 @@ import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; import org.apache.fop.traits.BorderProps; -/* org.w3c.dom.Document is not imported to avoid conflict with - org.apache.fop.control.Document */ +import org.w3c.dom.Document; /** * Renderer that renders to PostScript. @@ -93,7 +92,7 @@ public class PSRenderer extends AbstractRenderer { private float currGreen; private float currBlue; - private Document fontInfo; + private FontInfo fontInfo; /** * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) @@ -229,9 +228,9 @@ public class PSRenderer extends AbstractRenderer { * * @param foTreeControl the font info object to set up */ - public void setupFontInfo(FOTreeControl foTreeControl) { - FontSetup.setup((Document) foTreeControl, null); - this.fontInfo = (Document) foTreeControl; + public void setupFontInfo(FontInfo inFontInfo) { + this.fontInfo = inFontInfo; + FontSetup.setup(fontInfo, null); } /** @@ -451,7 +450,7 @@ public class PSRenderer extends AbstractRenderer { int fontsize = area.getTraitAsInteger(Trait.FONT_SIZE); // This assumes that *all* CIDFonts use a /ToUnicode mapping - Typeface f = (Typeface)fontInfo.getFonts().get(fontname); + Typeface f = (Typeface) fontInfo.getFonts().get(fontname); //Determine position int rx = currentBlockIPPosition; @@ -809,7 +808,7 @@ public class PSRenderer extends AbstractRenderer { * @see org.apache.fop.render.AbstractRenderer#renderForeignObject(ForeignObject, Rectangle2D) */ public void renderForeignObject(ForeignObject fo, Rectangle2D pos) { - org.w3c.dom.Document doc = fo.getDocument(); + Document doc = fo.getDocument(); String ns = fo.getNameSpace(); renderDocument(doc, ns, pos); } @@ -820,7 +819,7 @@ public class PSRenderer extends AbstractRenderer { * @param ns Namespace for the XML document * @param pos Position for the generated graphic/image */ - public void renderDocument(org.w3c.dom.Document doc, String ns, Rectangle2D pos) { + public void renderDocument(Document doc, String ns, Rectangle2D pos) { RendererContext context; context = new RendererContext(MIME_TYPE); context.setUserAgent(userAgent); diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java index 2c58813cc..89cb0cfae 100644 --- a/src/java/org/apache/fop/render/ps/PSTextPainter.java +++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java @@ -386,18 +386,18 @@ public class PSTextPainter implements TextPainter { return; }*/ fontFamily = fam.getFamilyName(); - if (document.hasFont(fontFamily, style, weight)) { - String fname = document.fontLookup( + if (document.getFontInfo().hasFont(fontFamily, style, weight)) { + String fname = document.getFontInfo().fontLookup( fontFamily, style, weight); - FontMetrics metrics = document.getMetricsFor(fname); + FontMetrics metrics = document.getFontInfo().getMetricsFor(fname); int fsize = (int)(fontSize.floatValue() * 1000); return new Font(fname, metrics, fsize); } } } - String fname = document.fontLookup( + String fname = document.getFontInfo().fontLookup( "any", style, Font.NORMAL); - FontMetrics metrics = document.getMetricsFor(fname); + FontMetrics metrics = document.getFontInfo().getMetricsFor(fname); int fsize = (int)(fontSize.floatValue() * 1000); return new Font(fname, metrics, fsize); } diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index a5d9c4796..f0b89f709 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -131,7 +131,7 @@ public class RTFHandler extends FOInputHandler { bDefer = false; bDeferredExecution = false; iNestCount=0; - FontSetup.setup(doc, null); + FontSetup.setup(doc.getFontInfo(), null); log.warn(ALPHA_WARNING); } diff --git a/src/java/org/apache/fop/render/svg/SVGRenderer.java b/src/java/org/apache/fop/render/svg/SVGRenderer.java index 4929d3166..3473a0087 100644 --- a/src/java/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/java/org/apache/fop/render/svg/SVGRenderer.java @@ -25,7 +25,7 @@ import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Leader; import org.apache.fop.area.inline.TextArea; import org.apache.fop.svg.SVGUtilities; -import org.apache.fop.apps.Document; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FOTreeControl; @@ -134,11 +134,11 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { /** * @see org.apache.fop.render.Renderer#setupFontInfo(FOTreeControl) */ - public void setupFontInfo(FOTreeControl foTreeControl) { + public void setupFontInfo(FontInfo fontInfo) { // create a temp Image to test font metrics on BufferedImage fontImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); - org.apache.fop.render.awt.FontSetup.setup((Document)foTreeControl, + org.apache.fop.render.awt.FontSetup.setup(fontInfo, fontImage.createGraphics()); } diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index bb5805284..c50bf4398 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -27,16 +27,13 @@ import java.util.Map; import java.util.Iterator; import java.awt.geom.Rectangle2D; -// XML -/* org.w3c.dom.Document is not imported to avoid conflict with - org.apache.fop.control.Document */ +import org.w3c.dom.Document; // FOP import org.apache.fop.render.AbstractRenderer; import org.apache.fop.render.RendererContext; import org.apache.fop.render.XMLHandler; import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Document; import org.apache.fop.apps.FOPException; import org.apache.fop.area.BeforeFloat; import org.apache.fop.area.Block; @@ -61,6 +58,7 @@ import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.Viewport; import org.apache.fop.area.inline.TextArea; import org.apache.fop.fonts.FontSetup; +import org.apache.fop.fonts.FontInfo; import org.apache.fop.fo.FOTreeControl; import org.apache.fop.fo.pagination.Region; @@ -178,8 +176,8 @@ public class XMLRenderer extends AbstractRenderer { * * @param fontInfo the font info object to set up */ - public void setupFontInfo(FOTreeControl foTreeControl) { - FontSetup.setup((Document) foTreeControl, null); + public void setupFontInfo(FontInfo fontInfo) { + FontSetup.setup(fontInfo, null); } private boolean isCoarseXml() { @@ -393,7 +391,7 @@ public class XMLRenderer extends AbstractRenderer { */ public void renderForeignObject(ForeignObject fo) { writeStartTag("<foreignObject>"); - org.w3c.dom.Document doc = fo.getDocument(); + Document doc = fo.getDocument(); String ns = fo.getNameSpace(); context.setProperty(XMLXMLHandler.WRITER, writer); renderXML(userAgent, context, doc, ns); |