Program: 39514
Project: 39514
Buggy source:
public static void applyFontStyles(Map<String,String> cssProps,ProcessorContext context,IPropertyContainer element){
  if (cssProps.get(CssConstants.FONT_FAMILY) != null) {
    try {
      element.setProperty(Property.FONT,context.getFontResolver().getFont(cssProps.get(CssConstants.FONT_FAMILY)));
    }
 catch (    IOException exc) {
      logger.error(LogMessageConstant.ERROR_LOADING_FONT,exc);
    }
  }
  float em=CssUtils.parseAbsoluteLength(cssProps.get(CssConstants.FONT_SIZE));
  if (em != 0) {
    element.setProperty(Property.FONT_SIZE,em);
  }
  if (cssProps.get(CssConstants.FONT_WEIGHT) != null) {
    String fontWeight=cssProps.get(CssConstants.FONT_WEIGHT);
    if (CssConstants.BOLD.equalsIgnoreCase(fontWeight)) {
      element.setProperty(Property.BOLD_SIMULATION,true);
    }
 else     if (CssConstants.NORMAL.equalsIgnoreCase(fontWeight)) {
      element.setProperty(Property.BOLD_SIMULATION,false);
    }
  }
  if (cssProps.get(CssConstants.FONT_STYLE) != null) {
    String fontStyle=cssProps.get(CssConstants.FONT_STYLE);
    if (CssConstants.ITALIC.equalsIgnoreCase(fontStyle)) {
      element.setProperty(Property.ITALIC_SIMULATION,true);
    }
 else     if (CssConstants.ITALIC.equalsIgnoreCase(fontStyle)) {
      element.setProperty(Property.ITALIC_SIMULATION,false);
    }
  }
  if (cssProps.get(CssConstants.COLOR) != null) {
    element.setProperty(Property.FONT_COLOR,WebColors.getRGBColor(cssProps.get(CssConstants.COLOR)));
  }
  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);
  }
  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);
  }
  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);
    if (textIndentValue.isPointValue()) {
      element.setProperty(Property.FIRST_LINE_INDENT,textIndentValue.getValue());
    }
 else {
      logger.error(LogMessageConstant.TEXT_INDENT_IN_PERCENTS_IS_NOT_SUPPORTED);
    }
  }
  String letterSpacing=cssProps.get(CssConstants.LETTER_SPACING);
  if (letterSpacing != null) {
    UnitValue letterSpacingValue=CssUtils.parseLengthValueToPt(letterSpacing,em);
    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);
    if (wordSpacingValue.isPointValue()) {
      element.setProperty(Property.WORD_SPACING,wordSpacingValue.getValue());
    }
 else {
    }
  }
  String lineHeight=cssProps.get(CssConstants.LINE_HEIGHT);
  if (lineHeight != null) {
    UnitValue lineHeightValue=CssUtils.parseLengthValueToPt(lineHeight,em);
    if (CssUtils.isNumericValue(lineHeight)) {
      element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,lineHeightValue.getValue()));
    }
 else     if (lineHeightValue.isPointValue()) {
      element.setProperty(Property.LEADING,new Leading(Leading.FIXED,lineHeightValue.getValue()));
    }
 else {
      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):
public static void applyFontStyles(Map<String,String> cssProps,ProcessorContext context,IPropertyContainer element){
  if (cssProps.get(CssConstants.FONT_FAMILY) != null) {
    try {
      element.setProperty(Property.FONT,context.getFontResolver().getFont(cssProps.get(CssConstants.FONT_FAMILY)));
    }
 catch (    IOException exc) {
      logger.error(LogMessageConstant.ERROR_LOADING_FONT,exc);
    }
  }
  float em=CssUtils.parseAbsoluteLength(cssProps.get(CssConstants.FONT_SIZE));
  if (em != 0) {
    element.setProperty(Property.FONT_SIZE,em);
  }
  if (cssProps.get(CssConstants.FONT_WEIGHT) != null) {
    String fontWeight=cssProps.get(CssConstants.FONT_WEIGHT);
    if (CssConstants.BOLD.equalsIgnoreCase(fontWeight)) {
      element.setProperty(Property.BOLD_SIMULATION,true);
    }
 else     if (CssConstants.NORMAL.equalsIgnoreCase(fontWeight)) {
      element.setProperty(Property.BOLD_SIMULATION,false);
    }
  }
  if (cssProps.get(CssConstants.FONT_STYLE) != null) {
    String fontStyle=cssProps.get(CssConstants.FONT_STYLE);
    if (CssConstants.ITALIC.equalsIgnoreCase(fontStyle)) {
      element.setProperty(Property.ITALIC_SIMULATION,true);
    }
 else     if (CssConstants.NORMAL.equalsIgnoreCase(fontStyle)) {
      element.setProperty(Property.ITALIC_SIMULATION,false);
    }
  }
  if (cssProps.get(CssConstants.COLOR) != null) {
    element.setProperty(Property.FONT_COLOR,WebColors.getRGBColor(cssProps.get(CssConstants.COLOR)));
  }
  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);
  }
  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);
  }
  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);
    if (textIndentValue.isPointValue()) {
      element.setProperty(Property.FIRST_LINE_INDENT,textIndentValue.getValue());
    }
 else {
      logger.error(LogMessageConstant.TEXT_INDENT_IN_PERCENTS_IS_NOT_SUPPORTED);
    }
  }
  String letterSpacing=cssProps.get(CssConstants.LETTER_SPACING);
  if (letterSpacing != null) {
    UnitValue letterSpacingValue=CssUtils.parseLengthValueToPt(letterSpacing,em);
    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);
    if (wordSpacingValue.isPointValue()) {
      element.setProperty(Property.WORD_SPACING,wordSpacingValue.getValue());
    }
 else {
    }
  }
  String lineHeight=cssProps.get(CssConstants.LINE_HEIGHT);
  if (lineHeight != null) {
    UnitValue lineHeightValue=CssUtils.parseLengthValueToPt(lineHeight,em);
    if (CssUtils.isNumericValue(lineHeight)) {
      element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,lineHeightValue.getValue()));
    }
 else     if (lineHeightValue.isPointValue()) {
      element.setProperty(Property.LEADING,new Leading(Leading.FIXED,lineHeightValue.getValue()));
    }
 else {
      element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,lineHeightValue.getValue() / 100));
    }
  }
 else {
    element.setProperty(Property.LEADING,new Leading(Leading.MULTIPLIED,1.2f));
  }
}