1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id: PDFSVGFlowRootElementBridge.java 1664570 2015-03-06 09:41:07Z lbernardo $ */ 19 20 package org.apache.fop.svg; 21 22 import org.apache.batik.bridge.TextNode; 23 import org.apache.batik.bridge.TextPainter; 24 import org.apache.batik.bridge.svg12.SVGFlowRootElementBridge; 25 import org.apache.batik.gvt.GraphicsNode; 26 27 import org.apache.fop.fonts.FontInfo; 28 29 /** 30 * Element Bridge for SVG 1.2 flow text, so those texts can be painted using 31 * PDF primitives. 32 */ 33 public class PDFSVGFlowRootElementBridge extends SVGFlowRootElementBridge { 34 35 private PDFTextPainter textPainter; 36 37 /** 38 * Main Constructor. 39 * @param fontInfo the font directory 40 */ PDFSVGFlowRootElementBridge(FontInfo fontInfo)41 public PDFSVGFlowRootElementBridge(FontInfo fontInfo) { 42 this.textPainter = new PDFFlowTextPainter(fontInfo); 43 } 44 45 /** {@inheritDoc} */ instantiateGraphicsNode()46 protected GraphicsNode instantiateGraphicsNode() { 47 GraphicsNode node = super.instantiateGraphicsNode(); 48 if (node != null) { 49 //Set our own text painter 50 ((TextNode)node).setTextPainter(getTextPainter()); 51 } 52 return node; 53 } 54 55 /** 56 * Returns the text painter used by this bridge. 57 * @return the text painter 58 */ getTextPainter()59 public TextPainter getTextPainter() { 60 return this.textPainter; 61 } 62 63 } 64