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

2003-01-08 Thread jeremias
jeremias2003/01/08 05:56:37

  Modified:src/org/apache/fop/layout FontInfo.java FontState.java
  Removed: src/org/apache/fop/layout FontDescriptor.java
FontMetric.java
  Log:
  Adjustments for the font refactoring
  Removal/commenting out of some dead code
  Lots of Javadocs
  Fixed Checkstyle errors
  
  Revision  ChangesPath
  1.19  +92 -28xml-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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- FontInfo.java 19 Dec 2002 00:35:31 -  1.18
  +++ FontInfo.java 8 Jan 2003 13:56:37 -   1.19
  @@ -1,41 +1,70 @@
   /*
* $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
   
   package org.apache.fop.layout;
   
  -import java.util.HashMap;
  +// Java
  +import java.util.Map;
  +
  +// FOP
  +import org.apache.fop.fonts.FontMetrics;
   
   /**
  - * The fontinfo for the layout and rendering of a fo document.
  + * The FontInfo for the layout and rendering of a fo document.
* This stores the list of available fonts that are setup by
* the renderer. The font name can be retrieved for the
* family style and weight.
  + * br
* Currently font supported font-variant small-caps is not
* implemented.
*/
   public class FontInfo {
  +
  +/** Default fallback key */
   public static final String DEFAULT_FONT = any,normal,400;
  +/** Normal font weight */
   public static final int NORMAL = 400;
  +/** Bold font weight */
   public static final int BOLD = 700;
   
  -private HashMap usedFonts;
  -private HashMap triplets;// look up a font-triplet to find a font-name
  -private HashMap fonts;// look up a font-name to get a font (that implements 
FontMetric at least)
  +/** Map containing fonts that have been used */
  +private Map usedFonts;
  +
  +/** look up a font-triplet to find a font-name */
  +private Map triplets;
  +
  +/** look up a font-name to get a font (that implements FontMetrics at least) */
  +private Map fonts;
   
  +/**
  + * Main constructor
  + */
   public FontInfo() {
  -this.triplets = new HashMap();
  -this.fonts = new HashMap();
  -this.usedFonts = new HashMap();
  +this.triplets = new java.util.HashMap();
  +this.fonts = new java.util.HashMap();
  +this.usedFonts = new java.util.HashMap();
   }
   
  +/**
  + * Checks if the font setup is valid (At least the ultimate fallback font 
  + * must be registered.)
  + * @return True if valid
  + */
   public boolean isSetupValid() {
   return triplets.containsKey(DEFAULT_FONT);
   }
   
  +/**
  + * Adds a new font triplet.
  + * @param name internal key
  + * @param family font family name
  + * @param style font style (normal, italic, oblique...)
  + * @param weight font weight
  + */
   public void addFontProperties(String name, String family, String style,
 int weight) {
   /*
  @@ -47,7 +76,12 @@
   this.triplets.put(key, name);
   }
   
  -public void addMetrics(String name, FontMetric metrics) {
  +/**
  + * Adds font metrics for a specific font.
  + * @param name internal key
  + * @param metrics metrics to register
  + */
  +public void addMetrics(String name, FontMetrics metrics) {
   // add the given metrics as a font with the given name
   
   this.fonts.put(name, metrics);
  @@ -55,10 +89,15 @@
   
   /**
* Lookup a font.
  - * Locate the font name for a given familyi, style and weight.
  + * br
  + * Locate the font name for a given family, style and weight.
* The font name can then be used as a key as it is unique for
* the associated document.
* This also adds the font to the list of used fonts.
  + * @param family font family
  + * @param style font style
  + * @param weight font weight
  + * @return internal key
*/
   public String fontLookup(String family, String style,
int weight) {
  @@ -66,18 +105,18 @@
   // first try given parameters
   key = createFontKey(family, style, weight);
   String f = (String)triplets.get(key);
  -if(f == null) {
  +if (f == null) {
   // then adjust weight, favouring normal or bold
   f = findAdjustWeight(family, style, weight);
   
   // then 

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

2002-06-10 Thread chrisg

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 [EMAIL PROTECTED]
  
  Revision  ChangesPath
  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 -  1.10.2.18
  +++ CHANGES   10 Jun 2002 23:56:30 -  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 [EMAIL PROTECTED]
  +
   
   ==
   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 -  1.12
  +++ FontInfo.java 10 Jun 2002 23:56:30 -  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.java12 Feb 2002 01:02:24 -  1.14.2.3
  +++ FontState.java10 Jun 2002 23:56:30 -  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; itoken.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