// The exception is when ?em? occurs in the value of
// the ?font-size? property itself, in which case it refers
// to the calculated font size of the parent element
// http://www.w3.org/TR/CSS21/fonts.html#font-size-props
if (cssName == CSSName.FONT_SIZE) {
FontSpecification parentFont = style.getParent().getFont(ctx);
//font size and FontSize2D should be identical
absVal = relVal * parentFont.size;//ctx.getFontSize2D(parentFont);
} else {
absVal = relVal * style.getFont(ctx).size;//ctx.getFontSize2D(style.getFont(ctx));
}
break;
case CSSPrimitiveValue.CSS_EXS:
// To convert EMS to pixels, we need the height of the lowercase 'Xx' character in the current
// element...
// to the font size of the parent element (spec: 4.3.2)
float xHeight;
if (cssName == CSSName.FONT_SIZE) {
FontSpecification parentFont = style.getParent().getFont(ctx);
xHeight = ctx.getXHeight(parentFont);
} else {
FontSpecification font = style.getFont(ctx);
xHeight = ctx.getXHeight(font);
}
absVal = relVal * xHeight;
break;
case CSSPrimitiveValue.CSS_PERCENTAGE:
// percentage depends on the property this value belongs to
if (cssName == CSSName.VERTICAL_ALIGN) {
baseValue = style.getParent().getLineHeight(ctx);
} else if (cssName == CSSName.FONT_SIZE) {
// same as with EM
FontSpecification parentFont = style.getParent().getFont(ctx);
baseValue = ctx.getFontSize2D(parentFont);
} else if (cssName == CSSName.LINE_HEIGHT) {
FontSpecification font = style.getFont(ctx);
baseValue = ctx.getFontSize2D(font);
}
absVal = (relVal / 100F) * baseValue;
break;