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