final LayoutElement currentNode,
final StyleKey key)
{
//Log.debug ("Processing: " + currentNode);
final LayoutContext layoutContext = currentNode.getLayoutContext();
final FontSpecification fs =
layoutContext.getFontSpecification();
final OutputProcessorMetaData outputMetaData = process.getOutputMetaData();
final CSSValue cssValue = layoutContext.getValue(key);
if (cssValue instanceof CSSValueList)
{
final CSSValueList list = (CSSValueList) cssValue;
for (int i = 0; i < list.getLength(); i++)
{
final CSSValue item = list.getItem(i);
if (item instanceof CSSConstant)
{
final CSSConstant c = (CSSConstant) lookupValue((CSSConstant) item);
final FontFamily family = outputMetaData.getFontFamilyForGenericName(c);
fs.setFontFamily(family.getFamilyName());
if (process.getOutputMetaData().isValid(fs))
{
return;
}
// Ignore, although this is not ok.
DebugLog.log ("Invalid state after setting predefined font family.");
}
else if (item instanceof CSSStringValue)
{
final CSSStringValue sval = (CSSStringValue) item;
final String fontName = sval.getValue();
fs.setFontFamily(fontName);
if (process.getOutputMetaData().isValid(fs))
{
return;
}
}
}
}
else if (cssValue instanceof CSSConstant)
{
if (FontFamilyValues.NONE.equals(cssValue))
{
fs.setFontFamily(null);
return;
}
}
final FontFamily family = outputMetaData.getDefaultFontFamily();
fs.setFontFamily(family.getFamilyName());
if (process.getOutputMetaData().isValid(fs) == false)
{
throw new IllegalStateException
("Invalid state after setting the default font family.");
}