if (spaceIndex == -1
|| (quoteIndex != -1 && spaceIndex > quoteIndex)) {
/* no spaces or first space appears after the first
* single/double quote, so malformed value string
*/
throw new PropertyException("Invalid property value: "
+ "font=\"" + value + "\"");
}
PropertyMaker m = null;
int fromIndex = spaceIndex + 1;
int toIndex = specVal.length();
/* at least one space that appears before the first
* single/double quote, so extract the individual properties
*/
boolean fontFamilyParsed = false;
int commaIndex = value.indexOf(',');
while (!fontFamilyParsed) {
/* value contains a (list of) possibly quoted
* font-family name(s)
*/
if (commaIndex == -1) {
/* no list, just a single name
* (or first name in the list)
*/
if (quoteIndex != -1) {
/* a single name, quoted
*/
fromIndex = quoteIndex;
}
m = FObj.getPropertyMakerFor(PROP_IDS[1]);
prop = m.make(propertyList, specVal.substring(fromIndex), fo);
newProp.addProperty(prop, 1);
fontFamilyParsed = true;
} else {
if (quoteIndex != -1 && quoteIndex < commaIndex) {
/* a quoted font-family name as first name
* in the comma-separated list
* fromIndex = index of the first quote
*/
fromIndex = quoteIndex;
quoteIndex = -1;
} else {
fromIndex = value.lastIndexOf(' ', commaIndex) + 1;
}
commaIndex = -1;
}
}
toIndex = fromIndex - 1;
fromIndex = value.lastIndexOf(' ', toIndex - 1) + 1;
value = specVal.substring(fromIndex, toIndex);
int slashIndex = value.indexOf('/');
String fontSize = value.substring(0,
(slashIndex == -1) ? value.length() : slashIndex);
m = FObj.getPropertyMakerFor(PROP_IDS[0]);
prop = m.make(propertyList, fontSize, fo);
/* need to make sure subsequent call to LineHeightPropertyMaker.make()
* doesn't generate the default font-size property...
*/
propertyList.putExplicit(PROP_IDS[0], prop);
newProp.addProperty(prop, 0);
if (slashIndex != -1) {
/* line-height */
String lineHeight = value.substring(slashIndex + 1);
m = FObj.getPropertyMakerFor(PROP_IDS[2]);
prop = m.make(propertyList, lineHeight, fo);
newProp.addProperty(prop, 2);
}
if (fromIndex != 0) {
toIndex = fromIndex - 1;
value = specVal.substring(0, toIndex);
fromIndex = 0;
spaceIndex = value.indexOf(' ');
do {
toIndex = (spaceIndex == -1) ? value.length() : spaceIndex;
String val = value.substring(fromIndex, toIndex);
for (int i = 6; --i >= 3;) {
if (newProp.list.get(i) == null) {
/* not set */
m = FObj.getPropertyMakerFor(PROP_IDS[i]);
val = m.checkValueKeywords(val);
prop = m.checkEnumValues(val);
if (prop != null) {
newProp.addProperty(prop, i);
}
}
}
fromIndex = toIndex + 1;
spaceIndex = value.indexOf(' ', fromIndex);
} while (toIndex != value.length());
}
} else {
//TODO: implement enum values
log.warn("Enum values other than \"inherit\""
+ " not yet supported for the font shorthand.");
return null;
}
}
if (newProp.list.get(0) == null || newProp.list.get(1) == null) {
throw new PropertyException("Invalid property value: "
+ "font-size and font-family are required for the font shorthand"
+ "\nfont=\"" + value + "\"");
}
return newProp;
} catch (PropertyException pe) {