Program: 39496
Project: 39496
Buggy source:
/** 
 * Applies font styles to an element.
 * @param cssProps the CSS props
 * @param context the processor context
 * @param stylesContainer the styles container
 * @param element the element
 */
public static void applyFontStyles(Map<String,String> cssProps,ProcessorContext context,IStylesContainer stylesContainer,IPropertyContainer element){
  float em=CssUtils.parseAbsoluteLength(cssProps.get(CssConstants.FONT_SIZE));
  float rem=context.getCssContext().getRootFontSize();
  if (em != 0) {
    element.setProperty(Property.FONT_SIZE,em);
  }
  if (cssProps.get(CssConstants.FONT_FAMILY) != null) {
    element.setProperty(Property.FONT,cssProps.get(CssConstants.FONT_FAMILY));
  }
  if (cssProps.get(CssConstants.FONT_WEIGHT) != null) {
    element.setProperty(Property.FONT_WEIGHT,cssProps.get(CssConstants.FONT_WEIGHT));
  }
  if (cssProps.get(CssConstants.FONT_STYLE) != null) {
    element.setProperty(Property.FONT_STYLE,cssProps.get(CssConstants.FONT_STYLE));
  }
  String cssColorPropValue=cssProps.get(CssConstants.COLOR);
  if (cssColorPropValue != null) {
    TransparentColor transparentColor;
    if (!CssConstants.TRANSPARENT.equals(cssColorPropValue)) {
      float[] rgbaColor=CssUtils.parseRgbaColor(cssColorPropValue);
      Color color=new DeviceRgb(rgbaColor[0],rgbaColor[1],rgbaColor[2]);
      float opacity=rgbaColor[3];
      transparentColor=new TransparentColor(color,opacity);
    }
 else {
      transparentColor=new TransparentColor(Color.BLACK,0f);
    }
    element.setProperty(Property.FONT_COLOR,transparentColor);
  }
  String direction=cssProps.get(CssConstants.DIRECTION);
  if (CssConstants.RTL.equals(direction)) {
    element.setProperty(Property.BASE_DIRECTION,BaseDirection.RIGHT_TO_LEFT);
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.RIGHT);
  }
 else   if (CssConstants.LTR.equals(direction)) {
    element.setProperty(Property.BASE_DIRECTION,BaseDirection.LEFT_TO_RIGHT);
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.LEFT);
  }
  if (stylesContainer instanceof IElementNode && ((IElementNode)stylesContainer).parentNode() instanceof IElementNode && CssConstants.RTL.equals(((IElementNode)((IElementNode)stylesContainer).parentNode()).getStyles().get(CssConstants.DIRECTION))) {
    element.setProperty(Property.HORIZONTAL_ALIGNMENT,HorizontalAlignment.RIGHT);
  }
  String align=cssProps.get(CssConstants.TEXT_ALIGN);
  if (CssConstants.LEFT.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.LEFT);
  }
 else   if (CssConstants.RIGHT.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.RIGHT);
  }
 else   if (CssConstants.CENTER.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.CENTER);
  }
 else   if (CssConstants.JUSTIFY.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.JUSTIFIED);
    element.setProperty(Property.SPACING_RATIO,1f);
  }
  String textDecorationProp=cssProps.get(CssConstants.TEXT_DECORATION);
  if (textDecorationProp != null) {
    String[] textDecorations=textDecorationProp.split("String_Node_Str");
    List<Underline> underlineList=new ArrayList<>();
    for (    String textDecoration : textDecorations) {
      if (CssConstants.BLINK.equals(textDecoration)) {
        logger.error(LogMessageConstant.TEXT_DECORATION_BLINK_NOT_SUPPORTED);
      }
 else       if (CssConstants.LINE_THROUGH.equals(textDecoration)) {
        underlineList.add(new Underline(null,.75f,0,0,1 / 4f,PdfCanvasConstants.LineCapStyle.BUTT));
      }
 else       if (CssConstants.OVERLINE.equals(textDecoration)) {
        underlineList.add(new Underline(null,.75f,0,0,9 / 10f,PdfCanvasConstants.LineCapStyle.BUTT));
      }
 else       if (CssConstants.UNDERLINE.equals(textDecoration)) {
        underlineList.add(new Underline(null,.75f,0,0,-1 / 10f,PdfCanvasConstants.LineCapStyle.BUTT));
      }
 else       if (CssConstants.NONE.equals(textDecoration)) {
        underlineList=null;
        break;
      }
    }
    element.setProperty(Property.UNDERLINE,underlineList);
  }
  String textIndent=cssProps.get(CssConstants.TEXT_INDENT);
  if (textIndent != null) {
    UnitValue textIndentValue=CssUtils.parseLengthValueToPt(textIndent,em,rem);
    if (textIndentValue != null) {
      if (textIndentValue.isPointValue()) {
        element.setProperty(Property.FIRST_LINE_INDENT,textIndentValue.getValue());
      }
 else {
        logger.error(MessageFormat.format(LogMessageConstant.CSS_PROPERTY_IN_PERCENTS_NOT_SUPPORTED,CssConstants.TEXT_INDENT));
      }
    }
  }
  String letterSpacing=cssProps.get(CssConstants.LETTER_SPACING);
  if (letterSpacing != null && !letterSpacing.equals(CssConstants.NORMAL)) {
    UnitValue letterSpacingValue=CssUtils.parseLengthValueToPt(letterSpacing,em,rem);
    if (letterSpacingValue.isPointValue()) {
      element.setProperty(Property.CHARACTER_SPACING,letterSpacingValue.getValue());
    }
 else {
    }
  }
  String wordSpacing=cssProps.get(CssConstants.WORD_SPACING);
  if (wordSpacing != null) {
    UnitValue wordSpacingValue=CssUtils.parseLengthValueToPt(wordSpacing,em,rem);
    if (wordSpacingValue != null) {
      if (wordSpacingValue.isPointValue()) {
        element.setProperty(Property.WORD_SPACING,wordSpacingValue.getValue());
      }
 else {
      }
    }
  }
  String lineHeight=cssProps.get(CssConstants.LINE_HEIGHT);
  if (lineHeight != null && !CssConstants.NORMAL.equals(lineHeight)) {
    UnitValue lineHeightValue=CssUtils.parseLengthValueToPt(lineHeight,em,rem);
    if (CssUtils.isNumericValue(lineHeight)) {
      element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,lineHeightValue.getValue()));
    }
 else     if (lineHeightValue != null && lineHeightValue.isPointValue()) {
      element.setProperty(Property.LEADING,new Leading(Leading.FIXED,lineHeightValue.getValue()));
    }
 else     if (lineHeightValue != null) {
      element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,lineHeightValue.getValue() / 100));
    }
  }
 else {
    element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,1.2f));
  }
}

Fixed version (ground truth):
/** 
 * Applies font styles to an element.
 * @param cssProps the CSS props
 * @param context the processor context
 * @param stylesContainer the styles container
 * @param element the element
 */
public static void applyFontStyles(Map<String,String> cssProps,ProcessorContext context,IStylesContainer stylesContainer,IPropertyContainer element){
  float em=CssUtils.parseAbsoluteLength(cssProps.get(CssConstants.FONT_SIZE));
  float rem=context.getCssContext().getRootFontSize();
  if (em != 0) {
    element.setProperty(Property.FONT_SIZE,em);
  }
  if (cssProps.get(CssConstants.FONT_FAMILY) != null) {
    element.setProperty(Property.FONT,cssProps.get(CssConstants.FONT_FAMILY));
  }
  if (cssProps.get(CssConstants.FONT_WEIGHT) != null) {
    element.setProperty(Property.FONT_WEIGHT,cssProps.get(CssConstants.FONT_WEIGHT));
  }
  if (cssProps.get(CssConstants.FONT_STYLE) != null) {
    element.setProperty(Property.FONT_STYLE,cssProps.get(CssConstants.FONT_STYLE));
  }
  String cssColorPropValue=cssProps.get(CssConstants.COLOR);
  if (cssColorPropValue != null) {
    TransparentColor transparentColor;
    if (!CssConstants.TRANSPARENT.equals(cssColorPropValue)) {
      float[] rgbaColor=CssUtils.parseRgbaColor(cssColorPropValue);
      Color color=new DeviceRgb(rgbaColor[0],rgbaColor[1],rgbaColor[2]);
      float opacity=rgbaColor[3];
      transparentColor=new TransparentColor(color,opacity);
    }
 else {
      transparentColor=new TransparentColor(Color.BLACK,0f);
    }
    element.setProperty(Property.FONT_COLOR,transparentColor);
  }
  String direction=cssProps.get(CssConstants.DIRECTION);
  if (CssConstants.RTL.equals(direction)) {
    element.setProperty(Property.BASE_DIRECTION,BaseDirection.RIGHT_TO_LEFT);
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.RIGHT);
  }
 else   if (CssConstants.LTR.equals(direction)) {
    element.setProperty(Property.BASE_DIRECTION,BaseDirection.LEFT_TO_RIGHT);
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.LEFT);
  }
  if (stylesContainer instanceof IElementNode && ((IElementNode)stylesContainer).parentNode() instanceof IElementNode && CssConstants.RTL.equals(((IElementNode)((IElementNode)stylesContainer).parentNode()).getStyles().get(CssConstants.DIRECTION))) {
    element.setProperty(Property.HORIZONTAL_ALIGNMENT,HorizontalAlignment.RIGHT);
  }
  String align=cssProps.get(CssConstants.TEXT_ALIGN);
  if (CssConstants.LEFT.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.LEFT);
  }
 else   if (CssConstants.RIGHT.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.RIGHT);
  }
 else   if (CssConstants.CENTER.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.CENTER);
  }
 else   if (CssConstants.JUSTIFY.equals(align)) {
    element.setProperty(Property.TEXT_ALIGNMENT,TextAlignment.JUSTIFIED);
    element.setProperty(Property.SPACING_RATIO,1f);
  }
  String textDecorationProp=cssProps.get(CssConstants.TEXT_DECORATION);
  if (textDecorationProp != null) {
    String[] textDecorations=textDecorationProp.split("String_Node_Str");
    List<Underline> underlineList=new ArrayList<>();
    for (    String textDecoration : textDecorations) {
      if (CssConstants.BLINK.equals(textDecoration)) {
        logger.error(LogMessageConstant.TEXT_DECORATION_BLINK_NOT_SUPPORTED);
      }
 else       if (CssConstants.LINE_THROUGH.equals(textDecoration)) {
        underlineList.add(new Underline(null,.75f,0,0,1 / 4f,PdfCanvasConstants.LineCapStyle.BUTT));
      }
 else       if (CssConstants.OVERLINE.equals(textDecoration)) {
        underlineList.add(new Underline(null,.75f,0,0,9 / 10f,PdfCanvasConstants.LineCapStyle.BUTT));
      }
 else       if (CssConstants.UNDERLINE.equals(textDecoration)) {
        underlineList.add(new Underline(null,.75f,0,0,-1 / 10f,PdfCanvasConstants.LineCapStyle.BUTT));
      }
 else       if (CssConstants.NONE.equals(textDecoration)) {
        underlineList=null;
        break;
      }
    }
    element.setProperty(Property.UNDERLINE,underlineList);
  }
  String textIndent=cssProps.get(CssConstants.TEXT_INDENT);
  if (textIndent != null) {
    UnitValue textIndentValue=CssUtils.parseLengthValueToPt(textIndent,em,rem);
    if (textIndentValue != null) {
      if (textIndentValue.isPointValue()) {
        element.setProperty(Property.FIRST_LINE_INDENT,textIndentValue.getValue());
      }
 else {
        logger.error(MessageFormat.format(LogMessageConstant.CSS_PROPERTY_IN_PERCENTS_NOT_SUPPORTED,CssConstants.TEXT_INDENT));
      }
    }
  }
  String letterSpacing=cssProps.get(CssConstants.LETTER_SPACING);
  if (letterSpacing != null && !letterSpacing.equals(CssConstants.NORMAL)) {
    UnitValue letterSpacingValue=CssUtils.parseLengthValueToPt(letterSpacing,em,rem);
    if (letterSpacingValue.isPointValue()) {
      element.setProperty(Property.CHARACTER_SPACING,letterSpacingValue.getValue());
    }
 else {
    }
  }
  String wordSpacing=cssProps.get(CssConstants.WORD_SPACING);
  if (wordSpacing != null) {
    UnitValue wordSpacingValue=CssUtils.parseLengthValueToPt(wordSpacing,em,rem);
    if (wordSpacingValue != null) {
      if (wordSpacingValue.isPointValue()) {
        element.setProperty(Property.WORD_SPACING,wordSpacingValue.getValue());
      }
 else {
      }
    }
  }
  String lineHeight=cssProps.get(CssConstants.LINE_HEIGHT);
  if (lineHeight != null && !CssConstants.NORMAL.equals(lineHeight)) {
    if (CssUtils.isNumericValue(lineHeight)) {
      Float mult=CssUtils.parseFloat(lineHeight);
      if (mult != null) {
        element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,(float)mult));
      }
    }
 else {
      UnitValue lineHeightValue=CssUtils.parseLengthValueToPt(lineHeight,em,rem);
      if (lineHeightValue != null && lineHeightValue.isPointValue()) {
        element.setProperty(Property.LEADING,new Leading(Leading.FIXED,lineHeightValue.getValue()));
      }
 else       if (lineHeightValue != null) {
        element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,lineHeightValue.getValue() / 100));
      }
    }
  }
 else {
    element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,1.2f));
  }
}