vhardy      02/02/19 10:30:53

  Modified:    sources/org/apache/batik/bridge BridgeContext.java
                        SVGFontUtilities.java
  Log:
  Fixed bug reported by Keiron Liddle (#6536) after discussion with Thierry.
  
  Revision  Changes    Path
  1.35      +22 -1     xml-batik/sources/org/apache/batik/bridge/BridgeContext.java
  
  Index: BridgeContext.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- BridgeContext.java        15 Feb 2002 14:58:44 -0000      1.34
  +++ BridgeContext.java        19 Feb 2002 18:30:53 -0000      1.35
  @@ -47,7 +47,7 @@
    * a SVG DOM tree such as the current viewport or the user agent.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: BridgeContext.java,v 1.34 2002/02/15 14:58:44 tkormann Exp $
  + * @version $Id: BridgeContext.java,v 1.35 2002/02/19 18:30:53 vhardy Exp $
    */
   public class BridgeContext implements ErrorConstants {
   
  @@ -69,6 +69,13 @@
       protected Map interpreterMap = new HashMap(7);
   
       /**
  +     * A hash map of all the font families already matched. This is
  +     * to reduce the number of instances of GVTFontFamilies and to
  +     * hopefully reduce the time taken to search for a matching SVG font.
  +     */
  +    private static HashMap fontFamilyMap;
  +
  +    /**
        * The viewports.
        * key is an Element -
        * value is a Viewport
  @@ -209,6 +216,17 @@
       }
   
       /**
  +     * Returns the map of font families
  +     */
  +    public HashMap getFontFamilyMap(){
  +        if (fontFamilyMap == null){
  +            fontFamilyMap = new HashMap();
  +        }
  +
  +        return fontFamilyMap;
  +    }
  +
  +    /**
        * Returns the text painter that will be used be text nodes.
        */
       public TextPainter getTextPainter() {
  @@ -228,6 +246,9 @@
        * @param document the document
        */
       protected void setDocument(Document document) {
  +        if (this.document != document){
  +            fontFamilyMap = null;
  +        }
           this.document = document;
       }
   
  
  
  
  1.10      +3 -24     xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java
  
  Index: SVGFontUtilities.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGFontUtilities.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SVGFontUtilities.java     6 Feb 2002 16:43:02 -0000       1.9
  +++ SVGFontUtilities.java     19 Feb 2002 18:30:53 -0000      1.10
  @@ -1,5 +1,5 @@
   /*****************************************************************************
  - * Copyright (C) The Apache Software Foundation. All rights reserved.        *
  + * Copyrightp (C) The Apache Software Foundation. All rights reserved.        *
    * ------------------------------------------------------------------------- *
    * This software is published under the terms of the Apache Software License *
    * version 1.1, a copy of which has been included with this distribution in  *
  @@ -28,24 +28,9 @@
    * Utility class for SVG fonts.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Bella Robinson</a>
  - * @version $Id: SVGFontUtilities.java,v 1.9 2002/02/06 16:43:02 vhardy Exp $
  + * @version $Id: SVGFontUtilities.java,v 1.10 2002/02/19 18:30:53 vhardy Exp $
    */
   public abstract class SVGFontUtilities implements SVGConstants {
  -
  -
  -    /**
  -     * A hash map of all the font families already matched. This is
  -     * to reduce the number of instances of GVTFontFamilies and to
  -     * hopefully reduce the time taken to search for a matching SVG font.
  -     */
  -    private static HashMap fontFamilyMap;
  -
  -    /**
  -     * Keeps track of the currentDocument. This is used to detect when a new
  -     * document has been loaded.
  -     */
  -    private static Document currentDocument = null;
  -
       /**
        * Given a font family name tries to find a matching SVG font object.
        * If finds one, returns an SVGFontFamily otherwise returns an
  @@ -67,17 +52,11 @@
                                                String fontStyle) {
   
           // TODO: should match against font-variant as well
  -
  -        // if this is a new document reset the fontFamilyMap
  -        if (fontFamilyMap == null || textElement.getOwnerDocument() != 
currentDocument) {
  -            fontFamilyMap = new HashMap();
  -            currentDocument = textElement.getOwnerDocument();
  -        }
  -
           String fontKeyName = fontFamilyName.toLowerCase() + " " + fontWeight + " " 
+ fontStyle;
   
           // check fontFamilyMap to see if we have already created an FontFamily
           // that matches
  +        HashMap fontFamilyMap = ctx.getFontFamilyMap();
           GVTFontFamily fontFamily = (GVTFontFamily)fontFamilyMap.get(fontKeyName);
           if (fontFamily != null) {
               return fontFamily;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to