int EN_X_FILL = 162;
/** Enumeration constant - non-standard for display-align */
int EN_X_DISTRIBUTE = 163;
+ /** Enumeration constant */
+ int EN_ITALIC = 164;
+ /** Enumeration constant */
+ int EN_OBLIQUE = 165;
+ /** Enumeration constant */
+ int EN_BACKSLANT = 166;
+ /** Enumeration constant */
+ int EN_BOLDER = 167;
+ /** Enumeration constant */
+ int EN_LIGHTER = 168;
+ /** Enumeration constant */
+ int EN_100 = 168;
+ /** Enumeration constant */
+ int EN_200 = 169;
+ /** Enumeration constant */
+ int EN_300 = 170;
+ /** Enumeration constant */
+ int EN_400 = 171;
+ /** Enumeration constant */
+ int EN_500 = 172;
+ /** Enumeration constant */
+ int EN_600 = 173;
+ /** Enumeration constant */
+ int EN_700 = 174;
+ /** Enumeration constant */
+ int EN_800 = 175;
+ /** Enumeration constant */
+ int EN_900 = 176;
/** Number of enumeration constants defined */
- int ENUM_COUNT = 163;
+ int ENUM_COUNT = 176;
}
addPropertyMaker("font-size-adjust", m);
// font-style
- m = new StringProperty.Maker(PR_FONT_STYLE);
+ m = new EnumProperty.Maker(PR_FONT_STYLE);
m.setInherited(true);
+ m.addEnum("normal", getEnumProperty(EN_NORMAL, "NORMAL"));
+ m.addEnum("italic", getEnumProperty(EN_ITALIC, "ITALIC"));
+ m.addEnum("oblique", getEnumProperty(EN_OBLIQUE, "OBLIQUE"));
+ m.addEnum("backslant", getEnumProperty(EN_BACKSLANT, "BACKSLANT"));
+
m.setDefault("normal");
addPropertyMaker("font-style", m);
addPropertyMaker("font-variant", m);
// font-weight
- m = new StringProperty.Maker(PR_FONT_WEIGHT);
+ m = new EnumProperty.Maker(PR_FONT_WEIGHT);
m.setInherited(true);
m.addKeyword("normal", "400");
m.addKeyword("bold", "700");
+ m.addEnum("bolder",getEnumProperty(EN_BOLDER, "BOLDER"));
+ m.addEnum("lighter",getEnumProperty(EN_LIGHTER, "LIGHTER"));
+ m.addEnum("100",getEnumProperty(EN_100, "100"));
+ m.addEnum("200",getEnumProperty(EN_200, "200"));
+ m.addEnum("300",getEnumProperty(EN_300, "300"));
+ m.addEnum("400",getEnumProperty(EN_400, "400"));
+ m.addEnum("500",getEnumProperty(EN_500, "500"));
+ m.addEnum("600",getEnumProperty(EN_600, "600"));
+ m.addEnum("700",getEnumProperty(EN_700, "700"));
+ m.addEnum("800",getEnumProperty(EN_800, "800"));
+ m.addEnum("900",getEnumProperty(EN_900, "900"));
m.setDefault("400");
addPropertyMaker("font-weight", m);
}
/**
* The "font-style" property.
*/
- public String fontStyle;
+ public int fontStyle;
/**
* The "font-variant" property.
/**
* The "font-weight" property.
*/
- public String fontWeight;
+ public int fontWeight;
private Font fontState;
fontSize = pList.get(Constants.PR_FONT_SIZE).getLength();
fontStretch = pList.get(Constants.PR_FONT_STRETCH).getEnum();
fontSizeAdjust = pList.get(Constants.PR_FONT_SIZE_ADJUST).getNumeric();
- fontStyle = pList.get(Constants.PR_FONT_STYLE).getString();
+ fontStyle = pList.get(Constants.PR_FONT_STYLE).getEnum();
fontVariant = pList.get(Constants.PR_FONT_VARIANT).getEnum();
- fontWeight = pList.get(Constants.PR_FONT_WEIGHT).getString();
+ fontWeight = pList.get(Constants.PR_FONT_WEIGHT).getEnum();
}
/**
/**@todo this is ugly. need to improve. */
int font_weight = 400;
- if (fontWeight.equals("bolder")) {
+ if (fontWeight == Constants.EN_BOLDER) {
// +100 from inherited
- } else if (fontWeight.equals("lighter")) {
+ } else if (fontWeight == Constants.EN_LIGHTER) {
// -100 from inherited
} else {
- try {
- font_weight = Integer.parseInt(fontWeight);
- } catch (NumberFormatException nfe) {
- } /** TODO: log that exception */
- }
- font_weight = ((int) font_weight / 100) * 100;
- if (font_weight < 100) {
- font_weight = 100;
- } else if (font_weight > 900) {
- font_weight = 900;
+ switch (fontWeight) {
+ case Constants.EN_100: font_weight = 100; break;
+ case Constants.EN_200: font_weight = 200; break;
+ case Constants.EN_300: font_weight = 300; break;
+ case Constants.EN_400: font_weight = 400; break;
+ case Constants.EN_500: font_weight = 500; break;
+ case Constants.EN_600: font_weight = 600; break;
+ case Constants.EN_700: font_weight = 700; break;
+ case Constants.EN_800: font_weight = 800; break;
+ case Constants.EN_900: font_weight = 900; break;
+ }
}
+ String style = "normal";
+ switch (fontStyle) {
+ case Constants.EN_ITALIC:
+ style = "italic";
+ break;
+ case Constants.EN_OBLIQUE:
+ style = "oblique";
+ break;
+ case Constants.EN_BACKSLANT:
+ style = "backslant";
+ break;
+ }
// NOTE: this is incomplete. font-size may be specified with
// various kinds of keywords too
//int fontVariant = propertyList.get("font-variant").getEnum();
- String fname = fontInfo.fontLookup(fontFamily, fontStyle,
+ String fname = fontInfo.fontLookup(fontFamily, style,
font_weight);
FontMetrics metrics = fontInfo.getMetricsFor(fname);
fontState = new Font(fname, metrics, fontSize.getValue(context));
RtfFontManager.getInstance().getFontNumber(font.fontFamily));
rtfAttr.setHalfPoints(RtfText.ATTR_FONT_SIZE, font.fontSize);
- if (font.fontWeight.equals("bold") || font.fontWeight.equals("700")) {
+ if (font.fontWeight == Constants.EN_700) {
rtfAttr.set("b", 1);
} else {
rtfAttr.set("b", 0);
}
- if (font.fontStyle.equals("italic")) {
+ if (font.fontStyle == Constants.EN_ITALIC) {
rtfAttr.set(RtfText.ATTR_ITALIC, 1);
} else {
rtfAttr.set(RtfText.ATTR_ITALIC, 0);