src/java/org/apache/fop/afp/svg/AFPTextHandler.java
@Override
    public void drawString(Graphics2D g, String str, float x, float y) {
        if (log.isDebugEnabled()) {
            log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y);
        }
        if (g instanceof AFPGraphics2D) {
            AFPGraphics2D g2d = (AFPGraphics2D)g;
            GraphicsObject graphicsObj = g2d.getGraphicsObject();
            Color color = g2d.getColor();

            // set the color
            AFPPaintingState paintingState = g2d.getPaintingState();
            paintingState.setColor(color);
            graphicsObj.setColor(color);

            // set the character set
            int fontReference = 0;
            int fontSize;
            String internalFontName;
            AFPPageFonts pageFonts = paintingState.getPageFonts();
            if (overrideFont != null) {
                internalFontName = overrideFont.getFontName();
                fontSize = overrideFont.getFontSize();
                if (log.isDebugEnabled()) {
                    log.debug("  with overriding font: " + internalFontName + ", " + fontSize);
                }
                fontSize = (int) Math.round(g2d.convertToAbsoluteLength(fontSize));
                fontReference = registerPageFont(pageFonts, internalFontName, fontSize);
                // TODO: re-think above registerPageFont code...
                AFPFont afpFont = (AFPFont) fontInfo.getFonts().get(internalFontName);
                final CharacterSet charSet = afpFont.getCharacterSet(fontSize);
                // Work-around for InfoPrint's AFP which loses character set state
                // over Graphics Data
                // boundaries.
                graphicsObj.setCharacterSet(fontReference);
                // add the character string
                graphicsObj.addString(str, Math.round(x), Math.round(y), charSet);
            }
        } else {
            //Inside Batik's SVG filter operations, you won't get an AFPGraphics2D
            g.drawString(str, x, y);
        }
    }
/**
     * Add a text string to the current data object of the AFP datastream.
     * The text is painted using text operations.
     *
     * {@inheritDoc}
     */
Add a text string to the current data object of the AFP datastream.
The text is painted using text operations.


Add a text string to the current data object of the AFP datastream . The text is painted using text operations .
@Override
    public void drawString(Graphics2D g, String str, float x, float y) {
        if (log.isDebugEnabled()) {
            log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y);
        }
        if (g instanceof AFPGraphics2D) {
            AFPGraphics2D g2d = (AFPGraphics2D)g;
            GraphicsObject graphicsObj = g2d.getGraphicsObject();
            Color color = g2d.getColor();
            AFPPaintingState paintingState = g2d.getPaintingState();
            paintingState.setColor(color);
            graphicsObj.setColor(color);
            int fontReference = 0;
            int fontSize;
            String internalFontName;
            AFPPageFonts pageFonts = paintingState.getPageFonts();
            if (overrideFont != null) {
                internalFontName = overrideFont.getFontName();
                fontSize = overrideFont.getFontSize();
                if (log.isDebugEnabled()) {
                    log.debug("  with overriding font: " + internalFontName + ", " + fontSize);
                }
                fontSize = (int) Math.round(g2d.convertToAbsoluteLength(fontSize));
                fontReference = registerPageFont(pageFonts, internalFontName, fontSize);
                AFPFont afpFont = (AFPFont) fontInfo.getFonts().get(internalFontName);
                final CharacterSet charSet = afpFont.getCharacterSet(fontSize);
                graphicsObj.setCharacterSet(fontReference);
                graphicsObj.addString(str, Math.round(x), Math.round(y), charSet);
            }
        } else {
            g.drawString(str, x, y);
        }
    }
@ Override public void drawString ( Graphics2D g , String str , float x , float y ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "drawString() str=" + str + ", x=" + x + ", y=" + y ) ; } if ( g instanceof AFPGraphics2D ) { AFPGraphics2D g2d = ( AFPGraphics2D ) g ; GraphicsObject graphicsObj = g2d . getGraphicsObject ( ) ; Color color = g2d . getColor ( ) ; AFPPaintingState paintingState = g2d . getPaintingState ( ) ; paintingState . setColor ( color ) ; graphicsObj . setColor ( color ) ; int fontReference = 0 ; int fontSize ; String internalFontName ; AFPPageFonts pageFonts = paintingState . getPageFonts ( ) ; if ( overrideFont != null ) { internalFontName = overrideFont . getFontName ( ) ; fontSize = overrideFont . getFontSize ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "  with overriding font: " + internalFontName + ", " + fontSize ) ; } fontSize = ( int ) Math . round ( g2d . convertToAbsoluteLength ( fontSize ) ) ; fontReference = registerPageFont ( pageFonts , internalFontName , fontSize ) ; AFPFont afpFont = ( AFPFont ) fontInfo . getFonts ( ) . get ( internalFontName ) ; final CharacterSet charSet = afpFont . getCharacterSet ( fontSize ) ; graphicsObj . setCharacterSet ( fontReference ) ; graphicsObj . addString ( str , Math . round ( x ) , Math . round ( y ) , charSet ) ; } } else { g . drawString ( str , x , y ) ; } }
Add a text string to the current data object of the AFP datastream.
Add a text string to the current data object of the AFP datastream .
// set the color // set the character set // TODO: re-think above registerPageFont code... // Work-around for InfoPrint's AFP which loses character set state // over Graphics Data // boundaries. // add the character string //Inside Batik's SVG filter operations, you won't get an AFPGraphics2D