You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ch...@apache.org on 2002/06/11 01:56:30 UTC

cvs commit: xml-fop/src/org/apache/fop/layout FontInfo.java FontState.java

chrisg      2002/06/10 16:56:30

  Modified:    .        Tag: fop-0_20_2-maintain CHANGES
               src/org/apache/fop/layout Tag: fop-0_20_2-maintain
                        FontInfo.java FontState.java
  Log:
  added support for comma-separated values for the font-family property
  Submitted by: Oleg Tkachenko <ol...@multiconn.com>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.10.2.19 +3 -0      xml-fop/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/xml-fop/CHANGES,v
  retrieving revision 1.10.2.18
  retrieving revision 1.10.2.19
  diff -u -r1.10.2.18 -r1.10.2.19
  --- CHANGES	10 Jun 2002 22:10:30 -0000	1.10.2.18
  +++ CHANGES	10 Jun 2002 23:56:30 -0000	1.10.2.19
  @@ -51,6 +51,9 @@
   - Fixed letter-spacing (Jeremias Maerki)
   - BaseDir property is now used for loading custom fonts (Bug #7608)
     (thanks to Arnd Beissner and Brian O'Kelley)
  +- Added support for comma-separated values for the font-family property
  +  Submitted by: Oleg Tkachenko <ol...@multiconn.com>
  +
   
   ==============================================================================
   Done since 0.20.2 release
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.12.2.1  +5 -1      xml-fop/src/org/apache/fop/layout/FontInfo.java
  
  Index: FontInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/FontInfo.java,v
  retrieving revision 1.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- FontInfo.java	11 Sep 2001 10:04:25 -0000	1.12
  +++ FontInfo.java	10 Jun 2002 23:56:30 -0000	1.12.2.1
  @@ -73,6 +73,10 @@
           return this.triplets.get(key) != null;
       }
   
  +    public boolean hasFont(String key) {
  +        return this.triplets.get(key) != null;
  +    }
  +
       /**
        * Creates a key from the given strings
        */
  
  
  
  1.14.2.4  +47 -2     xml-fop/src/org/apache/fop/layout/FontState.java
  
  Index: FontState.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/FontState.java,v
  retrieving revision 1.14.2.3
  retrieving revision 1.14.2.4
  diff -u -r1.14.2.3 -r1.14.2.4
  --- FontState.java	12 Feb 2002 01:02:24 -0000	1.14.2.3
  +++ FontState.java	10 Jun 2002 23:56:30 -0000	1.14.2.4
  @@ -8,6 +8,7 @@
   package org.apache.fop.layout;
   
   import java.util.Hashtable;
  +import java.util.StringTokenizer;
   
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.properties.FontVariant;
  @@ -37,7 +38,43 @@
           _fontStyle = fontStyle;
           _fontWeight = fontWeight;
           _fontSize = fontSize;
  -        _fontName = fontInfo.fontLookup(fontFamily, fontStyle, fontWeight);
  +        String _fontKey = FontInfo.createFontKey(_fontFamily, _fontStyle, _fontWeight);
  +        //Quick check-out for simple font family
  +        if (!fontInfo.hasFont(_fontKey)) {
  +            //Tokenizes font-family list
  +            StringTokenizer st = new StringTokenizer(_fontFamily, ",");
  +            while (st.hasMoreTokens()) {
  +                String token = st.nextToken().trim();
  +                //Checks for quoted font family name
  +                if (token.charAt(0) == '"' || token.charAt(0) == '\'')
  +                    token = token.substring(1, token.length()-1);
  +                else {
  +                    //In a nonquoted font family name any sequence of whitespace
  +                    //inside should be converted to a single space
  +                    StringBuffer sb = new StringBuffer();
  +                    boolean spaced = false;
  +                    for (int i=0; i<token.length(); i++) {
  +                        char c = token.charAt(i);
  +                        if (!isWhitespace(c)) {
  +                            sb.append(c);
  +                            spaced = false;
  +                        }
  +                        else if (!spaced) {
  +                            sb.append(c);
  +                            spaced = true;
  +                        }
  +                    }
  +                    token = sb.toString();
  +                }
  +                //Checks found font family name for existence
  +                _fontKey = FontInfo.createFontKey(token, _fontStyle, _fontWeight);
  +                if (fontInfo.hasFont(_fontKey)) {
  +                    _fontFamily = token;
  +                    break;
  +                }
  +            }
  +        }
  +        _fontName = fontInfo.fontLookup(_fontKey);
           _metric = fontInfo.getMetricsFor(_fontName);
           _fontVariant = fontVariant;
           _letterSpacing = 0;
  @@ -51,6 +88,14 @@
           _letterSpacing = letterSpacing;
       }
   
  +    private static boolean isWhitespace(char ch) {
  +        return (ch <= 0x0020) &&
  +            (((((1L << 0x0009) |
  +            (1L << 0x000A) |
  +            (1L << 0x000C) |
  +            (1L << 0x000D) |
  +            (1L << 0x0020)) >> ch) & 1L) != 0);
  +    }
   
       public int getAscender() {
           return _metric.getAscender(_fontSize) / 1000;
  
  
  

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