You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2002/02/06 17:43:03 UTC

cvs commit: xml-batik/sources/org/apache/batik/gvt/font FontFamilyResolver.java

vhardy      02/02/06 08:43:03

  Modified:    sources/org/apache/batik/bridge SVGFontUtilities.java
               sources/org/apache/batik/gvt/font FontFamilyResolver.java
  Log:
  Made font-family selection case-insensitive to match other implementation's
  behavior. See new test case in samples/tests/spec/font
  
  Revision  Changes    Path
  1.9       +3 -3      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SVGFontUtilities.java	18 Oct 2001 12:30:22 -0000	1.8
  +++ SVGFontUtilities.java	6 Feb 2002 16:43:02 -0000	1.9
  @@ -28,7 +28,7 @@
    * Utility class for SVG fonts.
    *
    * @author <a href="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
  - * @version $Id: SVGFontUtilities.java,v 1.8 2001/10/18 12:30:22 hillion Exp $
  + * @version $Id: SVGFontUtilities.java,v 1.9 2002/02/06 16:43:02 vhardy Exp $
    */
   public abstract class SVGFontUtilities implements SVGConstants {
   
  @@ -74,7 +74,7 @@
               currentDocument = textElement.getOwnerDocument();
           }
   
  -        String fontKeyName = fontFamilyName + " " + fontWeight + " " + fontStyle;
  +        String fontKeyName = fontFamilyName.toLowerCase() + " " + fontWeight + " " + fontStyle;
   
           // check fontFamilyMap to see if we have already created an FontFamily
           // that matches
  @@ -96,7 +96,7 @@
               String elemFamilyName
                       = fontFaceElement.getAttribute(SVG_FONT_FAMILY_ATTRIBUTE);
   
  -            if (elemFamilyName.indexOf(fontFamilyName) == 0) {  // found one
  +            if (elemFamilyName.toLowerCase().indexOf(fontFamilyName.toLowerCase()) == 0) {  // found one
   
                   // find matching font element
   
  
  
  
  1.6       +11 -10    xml-batik/sources/org/apache/batik/gvt/font/FontFamilyResolver.java
  
  Index: FontFamilyResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/font/FontFamilyResolver.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FontFamilyResolver.java	29 Jan 2002 16:19:00 -0000	1.5
  +++ FontFamilyResolver.java	6 Feb 2002 16:43:03 -0000	1.6
  @@ -20,7 +20,7 @@
    * The is a utility class that is used for resolving UnresolvedFontFamilies.
    *
    * @author <a href="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
  - * @version $Id: FontFamilyResolver.java,v 1.5 2002/01/29 16:19:00 deweese Exp $
  + * @version $Id: FontFamilyResolver.java,v 1.6 2002/02/06 16:43:03 vhardy Exp $
    */
   public class FontFamilyResolver {
   
  @@ -45,13 +45,13 @@
       static {
           fonts.put("sans-serif",      "SansSerif");
           fonts.put("serif",           "Serif");
  -        fonts.put("Times",           "Serif");
  -        fonts.put("Times New Roman", "Serif");
  +        fonts.put("times",           "Serif");
  +        fonts.put("times new roman", "Serif");
           fonts.put("cursive",         "Dialog");
           fonts.put("fantasy",         "Symbol");
           fonts.put("monospace",       "Monospaced");
           fonts.put("monospaced",      "Monospaced");
  -        fonts.put("Courier",         "Monospaced");
  +        fonts.put("courier",         "Monospaced");
   
           //
           // Load all fonts. Work around
  @@ -62,7 +62,7 @@
           String fontNames[] = env.getAvailableFontFamilyNames();
           int nFonts = fontNames != null ? fontNames.length : 0;
           for(int i=0; i<nFonts; i++){
  -            fonts.put(fontNames[i], fontNames[i]);
  +            fonts.put(fontNames[i].toLowerCase(), fontNames[i]);
   
               // also add the font name with the spaces removed
               StringTokenizer st = new StringTokenizer(fontNames[i]);
  @@ -70,12 +70,12 @@
               while (st.hasMoreTokens()) {
                   fontNameWithoutSpaces += st.nextToken();
               }
  -            fonts.put(fontNameWithoutSpaces, fontNames[i]);
  +            fonts.put(fontNameWithoutSpaces.toLowerCase(), fontNames[i]);
   
               // also add the font name with spaces replaced by dashes
               String fontNameWithDashes = fontNames[i].replace(' ', '-');
               if (!fontNameWithDashes.equals(fontNames[i])) {
  -               fonts.put(fontNameWithDashes, fontNames[i]);
  +               fonts.put(fontNameWithDashes.toLowerCase(), fontNames[i]);
               }
           }
   
  @@ -121,16 +121,16 @@
   
           // first see if this font family has already been resolved
           String familyName = fontFamily.getFamilyName();
  -        GVTFontFamily resolvedFontFamily = (GVTFontFamily)resolvedFontFamilies.get(familyName);
  +        GVTFontFamily resolvedFontFamily = (GVTFontFamily)resolvedFontFamilies.get(familyName.toLowerCase());
   
           if (resolvedFontFamily == null) { // hasn't been resolved yet
               // try to find a matching family name in the list of available fonts
  -            String awtFamilyName = (String) fonts.get(familyName);
  +            String awtFamilyName = (String) fonts.get(familyName.toLowerCase());
               if (awtFamilyName != null) {
                   resolvedFontFamily = new AWTFontFamily(awtFamilyName);
               }
   
  -            resolvedFontFamilies.put(familyName, resolvedFontFamily);
  +            resolvedFontFamilies.put(familyName.toLowerCase(), resolvedFontFamily);
           }
         //  if (resolvedFontFamily != null) {
         //      System.out.println("resolved " + fontFamily.getFamilyName() + " to " + resolvedFontFamily.getFamilyName());
  @@ -149,6 +149,7 @@
                   return fontFamily;
               }
           }
  +
           return null;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org