[FOray-commit] SF.net SVN: foray: [7724] trunk/foray/foray-pdf/src/java/org/foray/pdf/object
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-06-20 00:10:26
|
Revision: 7724 Author: victormote Date: 2006-06-19 17:10:18 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7724&view=rev Log Message: ----------- Dig the font and font-size information out of the AttributedCharacterIterator instead of getting it as constructor parameters. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2006-06-19 23:41:17 UTC (rev 7723) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2006-06-20 00:10:18 UTC (rev 7724) @@ -367,7 +367,7 @@ builder = null; PDFGraphics2D graphics = new PDFGraphics2D(true, this.getPDFDocument(), - contentRectangle, font, svgDocument); + contentRectangle, svgDocument, font.getFontConsumer()); graphics.setGraphicContext(new GraphicContext()); try { Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-06-19 23:41:17 UTC (rev 7723) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-06-20 00:10:18 UTC (rev 7724) @@ -32,7 +32,6 @@ import org.foray.ps.PSReal; import org.axsl.fontR.FontConsumer; -import org.axsl.fontR.FontException; import org.axsl.pdfW.PDFException; import org.apache.batik.ext.awt.g2d.GraphicContext; @@ -77,29 +76,6 @@ throws PDFException { super(textAsShapes); -/* - * TODO: Before the refactoring related to FOrayFont, the following essentially - * created an independent FontInfo object (now FontServer). FontServer is a - * singleton, so this is no longer independent. However, FontServer responds to - * requests from a FontConsumer, which interface keeps tracks of the needs of - * the various clients of FontServer. So, if it is desirable to have separate - * management of fonts used from those used in the main document, set up a - * different FontConsumer, perhaps this PDFDocumentGraphics2D object itself. - * (Victor Mote, 6-2-04) - */ - if (!textAsShapes) { - try { - this.font = fontConsumer.selectFontXSL( - org.axsl.fontR.Font.FONT_SELECTION_AUTO, - new String[] {"Helvetica"}, - org.axsl.fontR.Font.FONT_STYLE_NORMAL, - org.axsl.fontR.Font.FONT_WEIGHT_NORMAL, - org.axsl.fontR.Font.FONT_VARIANT_NORMAL, - org.axsl.fontR.Font.FONT_STRETCH_NORMAL, - 12, - ' '); - } catch (FontException e) {} - } standalone = true; this.stream = stream; this.pdfDoc = new PDFDocument(getLogger()); Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-06-19 23:41:17 UTC (rev 7723) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFGraphics2D.java 2006-06-20 00:10:18 UTC (rev 7724) @@ -67,6 +67,7 @@ import java.awt.Stroke; import java.awt.TexturePaint; import java.awt.color.ColorSpace; +import java.awt.font.TextAttribute; import java.awt.geom.AffineTransform; import java.awt.geom.PathIterator; import java.awt.geom.Point2D; @@ -109,7 +110,6 @@ */ PDFAnnotList currentAnnotList = null; - protected org.axsl.fontR.FontUse font; protected org.axsl.fontR.FontUse overrideFont = null; protected float overrideFontSize; @@ -135,16 +135,19 @@ private PDFXObject xObject; + private FontConsumer fontConsumer; + /** * Create a new PDFGraphics2D with the given pdf document info. * This is used to create a Graphics object for use inside an already * existing document. */ public PDFGraphics2D(boolean textAsShapes, PDFDocument doc, - Rectangle2D.Float contentRectangle, org.axsl.fontR.FontUse font, - SVGDocument svgDocument) { + Rectangle2D.Float contentRectangle, + SVGDocument svgDocument, FontConsumer fontConsumer) { super(textAsShapes); pdfDoc = doc; + this.fontConsumer = fontConsumer; org.axsl.pdfW.PDFFont pdfFont = doc.getCurrentGraphicsState().getFont(); if (pdfFont == null) { this.currentFont = null; @@ -152,7 +155,6 @@ this.currentFont = pdfFont.getFontUse(); } currentFontSize = doc.getCurrentGraphicsState().getFontSize(); - this.font = font; initGraphicalEnvironment(); transformCoordinates(contentRectangle, svgDocument); } @@ -453,7 +455,6 @@ */ public void dispose() { pdfDoc = null; - this.font = null; currentStream = null; currentFont = null; currentColour = null; @@ -930,11 +931,22 @@ for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator.next()) { - org.axsl.fontR.FontUse font = this.font; - /* TODO: It looks like currentFont and currentFontSize should - * come from the PDFDocuments GraphicsState, and that the comparison - * items should come from the SVG itself. */ - float size = -1; + /* TODO: All of this should be integrated with the regular methods + * in PDFContentStream. */ + String[] fontFamily = new String[1]; + fontFamily[0] = (String) iterator.getAttribute( + TextAttribute.FAMILY); + Float fontSize = (Float) iterator.getAttribute( + TextAttribute.FAMILY); + org.axsl.fontR.FontUse font; + try { + font = this.fontConsumer.selectFontCSS( + fontFamily, 0, 0, 0, 0, 0, ch); + } catch (FontException e) { + /* We can't find a font for this character, so skip it. */ + continue; + } + float size = fontSize.floatValue(); if ((font != this.currentFont) || (size != this.currentFontSize)) { this.currentFont = font; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |