final StyleKey key)
{
final LayoutContext layoutContext = currentNode.getLayoutContext();
final CSSValue value = layoutContext.getValue(key);
final LayoutElement parent = currentNode.getParent();
final FontSpecification fontSpecification =
currentNode.getLayoutContext().getFontSpecification();
if (value instanceof CSSNumericValue == false)
{
if (parent == null)
{
fontSpecification.setFontSize(this.baseFontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, baseFontSize));
}
else
{
final LayoutContext parentContext = parent.getLayoutContext();
final FontSpecification parentFont = parentContext.getFontSpecification();
final double fontSize = parentFont.getFontSize();
fontSpecification.setFontSize(fontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
}
return;
}
final CSSNumericValue nval = (CSSNumericValue) value;
if (CSSValueResolverUtility.isAbsoluteValue(nval))
{
final CSSNumericValue fsize = CSSValueResolverUtility.convertLength
(nval, currentNode.getLayoutContext(), process.getOutputMetaData());
final double fontSize = fsize.getValue();
fontSpecification.setFontSize(fontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
}
// we encountered one of the relative values.
else if (CSSNumericType.EM.equals(nval.getType()))
{
final double parentSize;
if (parent == null)
{
parentSize = this.baseFontSize;
}
else
{
final LayoutContext parentContext = parent.getLayoutContext();
final FontSpecification parentFont = parentContext.getFontSpecification();
parentSize = parentFont.getFontSize();
}
final double fontSize = parentSize * nval.getValue();
fontSpecification.setFontSize(fontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
}
else if (CSSNumericType.EX.equals(nval.getType()))
{
final double parentSize;
if (parent == null)
{
// if we have no parent, we create a fixed default value.
parentSize = this.baseFontSize * LibFontsDefaults.DEFAULT_XHEIGHT_SIZE / LibFontsDefaults.DEFAULT_ASCENT_SIZE;
}
else
{
final LayoutContext parentContext = parent.getLayoutContext();
final FontSpecification parentFont = parentContext.getFontSpecification();
parentSize = parentFont.getFontSize();
}
final double fontSize = parentSize * nval.getValue();
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
fontSpecification.setFontSize(fontSize);
}
else if (CSSNumericType.PERCENTAGE.equals(nval.getType()))
{
final double parentSize;
if (parent == null)
{
// if we have no parent, we create a fixed default value.
parentSize = this.baseFontSize;
}
else
{
final LayoutContext parentContext = parent.getLayoutContext();
final FontSpecification parentFont = parentContext.getFontSpecification();
parentSize = parentFont.getFontSize();
}
final double fontSize = parentSize * nval.getValue() / 100.0d;
fontSpecification.setFontSize(fontSize);
layoutContext.setValue(key, CSSNumericValue.createValue(CSSNumericType.PT, fontSize));
}