pbwest 2004/05/27 08:27:19
Modified: src/java/org/apache/fop/render/awt Tag:
FOP_0-20-0_Alt-Design Fonts.java
Log:
Extracted makeFontAttributes from getFont and getGenericFont
Added getFont(Map, int) and getGenericFont(Map)
Revision Changes Path
No revision
No revision
1.1.2.4 +36 -59 xml-fop/src/java/org/apache/fop/render/awt/Attic/Fonts.java
Index: Fonts.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/awt/Attic/Fonts.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- Fonts.java 25 May 2004 15:25:59 -0000 1.1.2.3
+++ Fonts.java 27 May 2004 15:27:19 -0000 1.1.2.4
@@ -588,20 +588,8 @@
}
}
- /**
- * Gets a java.awt.Font matching the given criteria.
- * @param family the font family
- * @param style only NORMAL, ITALIC and OBLIQUE are supported
- * @param variant only NORMAL is supported
- * @param weight only NORMAL and BOLD are supported
- * @param stretch only NORMAL is supported
- * @param size the size of the font in fractional points
- * @param strategy currently ignored
- * @return
- */
- public Font getFont(
- String family, int style, int variant, int weight,
- int stretch, float size, int strategy)
+ public Map makeFontAttributes(String family, int style, int variant,
+ int weight, int stretch, float size)
throws FontException {
HashMap attributes = new HashMap();
attributes.put(TextAttribute.FAMILY, family);
@@ -645,6 +633,31 @@
throw new FontException("Only NORMAL supported for stretch");
}
attributes.put(TextAttribute.SIZE, new Float(size));
+ return attributes;
+ }
+
+ /**
+ * Gets a java.awt.Font matching the given criteria.
+ * @param family the font family
+ * @param style only NORMAL, ITALIC and OBLIQUE are supported
+ * @param variant only NORMAL is supported
+ * @param weight only NORMAL and BOLD are supported
+ * @param stretch only NORMAL is supported
+ * @param size the size of the font in fractional points
+ * @param strategy currently ignored
+ * @return
+ */
+ public Font getFont(
+ String family, int style, int variant, int weight,
+ int stretch, float size, int strategy)
+ throws FontException {
+ Map attributes = makeFontAttributes(family, style, variant, weight,
+ stretch, size);
+ return new Font(attributes);
+ }
+
+ public Font getFont(Map attributes, int strategy) {
+ // strategy currently ignored
return new Font(attributes);
}
@@ -663,50 +676,14 @@
String type, int style, int variant, int weight,
int stretch, float size)
throws FontException {
- HashMap attributes = new HashMap();
- attributes.put(TextAttribute.FAMILY, type);
- switch (style) {
- case FontStyle.NORMAL:
- attributes.put(
- TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
- break;
- case FontStyle.ITALIC:
- case FontStyle.OBLIQUE:
- attributes.put(
- TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
- break;
- default:
- throw new FontException(
- "Only NORMAL, OBLIQUE and ITALIC supported for style");
- }
- switch (variant) {
- case FontVariant.NORMAL:
- break;
- default:
- throw new FontException("Only NORMAL supported for variant");
- }
- switch (weight) {
- case FontWeight.NORMAL:
- attributes.put(
- TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR);
- break;
- case FontWeight.BOLD:
- attributes.put(
- TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
- break;
- default:
- throw new FontException(
- "Only NORMAL and BOLD supported for weight");
- }
- switch (stretch) {
- case FontStretch.NORMAL:
- break;
- default:
- throw new FontException("Only NORMAL supported for stretch");
- }
- attributes.put(TextAttribute.SIZE, new Float(size));
+ Map attributes = makeFontAttributes(type, style, variant, weight,
+ stretch, size);
return new Font(attributes);
+ }
+
+ public Font getGenericFont(Map attributes) {
+ return new Font(attributes);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]