Program: 67718
Project: 67718
Buggy source:
/** 
 * Use this optimized routine for rendering horizontal ONLY text
 * @param gc
 * @param la
 * @param lo
 */
private final void renderHorizontalText(IChartComputation cComp,GC gc,Label la,double dX,double dY){
  final FontDefinition fd=la.getCaption().getFont();
  final Color clrText=(Color)_sxs.getColor(la.getCaption().getColor());
  final ITextMetrics itm=cComp.getTextMetrics(_sxs,la,0);
  final double dFW=itm.getFullWidth();
  final double dH=itm.getHeight();
  final double dFH=itm.getFullHeight();
  double dXOffset=0;
  double dW=0;
  final Insets ins=goFactory.scaleInsets(la.getInsets(),_sxs.getDpiResolution() / 72d);
  final HorizontalAlignment ha=la.getCaption().getFont().getAlignment().getHorizontalAlignment();
  final boolean bRightAligned=ha.getValue() == HorizontalAlignment.RIGHT;
  final boolean bCenterAligned=ha.getValue() == HorizontalAlignment.CENTER;
  final Rectangle r;
  Transform tr=null;
  Transform trOld=new Transform(getDevice());
  gc.getTransform(trOld);
  Region previousClipping=null;
  if (R31Enhance.isR31Available()) {
    r=new Rectangle(0,0,(int)dFW,(int)dFH);
    tr=new Transform(getDevice());
    gc.getTransform(tr);
    if (la.getCaption().getFont().getRotation() != 0) {
      float rotate=(float)la.getCaption().getFont().getRotation();
      double dAngleInRadians=((-rotate * Math.PI) / 180.0);
      double dSineTheta=Math.sin(dAngleInRadians);
      float tTx=(float)(dX - dFW / 2);
      float tTy=(float)(dY - dFH / 2);
      if (rotate > 0)       tTy+=dFW * Math.abs(dSineTheta);
 else       tTx+=dFH * Math.abs(dSineTheta);
      tr.translate((float)(dFW / 2),(float)(dFH / 2));
      tr.translate(tTx,tTy);
      tr.rotate(-rotate);
    }
 else {
      R31Enhance.translate(gc,tr,(float)dX,(float)dY);
    }
    previousClipping=new Region();
    gc.getClipping(previousClipping);
    R31Enhance.setTransform(gc,tr);
  }
 else {
    r=new Rectangle((int)dX,(int)dY,(int)dFW,(int)dFH);
  }
  boolean bFullyTransparent=true;
  if (la.getBackground() != null) {
    bFullyTransparent=(((ColorDefinition)la.getBackground()).getTransparency() == 0);
    R31Enhance.setAlpha(gc,255);
  }
  if (!bFullyTransparent) {
    final Color clrBackground=(Color)_sxs.getColor((ColorDefinition)la.getBackground());
    final Color clrPreviousBackground=gc.getBackground();
    if (((ColorDefinition)la.getBackground()).isSetTransparency()) {
      R31Enhance.setAlpha(gc,(ColorDefinition)la.getBackground());
    }
    gc.setBackground(clrBackground);
    gc.fillRectangle(r);
    clrBackground.dispose();
    gc.setBackground(clrPreviousBackground);
  }
  gc.setForeground(clrText);
  R31Enhance.setAlpha(gc,la.getCaption().getColor());
  final Font f=(Font)_sxs.createFont(fd);
  gc.setFont(f);
  if (fd.isUnderline() || fd.isStrikethrough()) {
    int lineWidth=(int)(fd.getSize() / 12);
    gc.setLineWidth(lineWidth);
  }
  if (R31Enhance.isR31Available()) {
    for (int i=0; i < itm.getLineCount(); i++) {
      String oText=itm.getLine(i);
      dW=gc.textExtent(oText).x;
      if (bRightAligned) {
        dXOffset=-ins.getLeft() + dFW - dW - ins.getRight();
      }
 else       if (bCenterAligned) {
        dXOffset=-ins.getLeft() + (dFW - dW) / 2;
      }
      gc.drawText(oText,(int)(dXOffset + ins.getLeft()),(int)(dH * i + ins.getTop()),true);
      if (fd.isUnderline()) {
        gc.drawLine((int)(dXOffset + ins.getLeft()),(int)(dH * (i + 1) + ins.getTop()),(int)(dXOffset + ins.getLeft() + dW),(int)(dH * (i + 1) + ins.getTop()));
      }
      if (fd.isStrikethrough()) {
        gc.drawLine((int)(dXOffset + ins.getLeft()),(int)(dH * (i + 0.5) + ins.getTop()),(int)(dXOffset + ins.getLeft() + dW),(int)(dH * (i + 0.5) + ins.getTop()));
      }
    }
  }
 else {
    for (int i=0; i < itm.getLineCount(); i++) {
      String oText=itm.getLine(i);
      dW=gc.textExtent(oText).x;
      if (bRightAligned) {
        dXOffset=-ins.getLeft() + dFW - dW - ins.getRight();
      }
 else       if (bCenterAligned) {
        dXOffset=-ins.getLeft() + (dFW - dW) / 2;
      }
      gc.drawText(oText,(int)(dX + dXOffset + ins.getLeft()),(int)(dY + dH * i + ins.getTop()),true);
      if (fd.isUnderline()) {
        gc.drawLine((int)(dX + dXOffset + ins.getLeft()),(int)(dY + dH * (i + 1) + ins.getTop()),(int)(dX + dXOffset + ins.getLeft()+ dW),(int)(dY + dH * (i + 1) + ins.getTop()));
      }
      if (fd.isStrikethrough()) {
        gc.drawLine((int)(dX + dXOffset + ins.getLeft()),(int)(dY + dH * (i + 0.5) + ins.getTop()),(int)(dX + dXOffset + ins.getLeft()+ dW),(int)(dY + dH * (i + 0.5) + ins.getTop()));
      }
    }
  }
  R31Enhance.setTransform(gc,trOld);
  if (previousClipping != null) {
    gc.setClipping(previousClipping);
    previousClipping.dispose();
  }
  R31Enhance.disposeTransform(trOld);
  R31Enhance.disposeTransform(tr);
  f.dispose();
  clrText.dispose();
  cComp.recycleTextMetrics(itm);
}

Fixed version (ground truth):
/** 
 * Use this optimized routine for rendering horizontal ONLY text
 * @param gc
 * @param la
 * @param lo
 */
private final void renderHorizontalText(IChartComputation cComp,GC gc,Label la,double dX,double dY){
  final FontDefinition fd=la.getCaption().getFont();
  final Color clrText=(Color)_sxs.getColor(la.getCaption().getColor());
  final ITextMetrics itm=cComp.getTextMetrics(_sxs,la,0);
  final double dFW=itm.getFullWidth();
  final double dH=itm.getHeight();
  final double dFH=itm.getFullHeight();
  double dXOffset=0;
  double dW=0;
  final Insets ins=goFactory.scaleInsets(la.getInsets(),_sxs.getDpiResolution() / 72d);
  final HorizontalAlignment ha=la.getCaption().getFont().getAlignment().getHorizontalAlignment();
  final boolean bRightAligned=ha.getValue() == HorizontalAlignment.RIGHT;
  final boolean bCenterAligned=ha.getValue() == HorizontalAlignment.CENTER;
  final Rectangle r;
  Transform tr=null;
  Transform trOld=new Transform(getDevice());
  gc.getTransform(trOld);
  Region previousClipping=null;
  if (R31Enhance.isR31Available()) {
    r=new Rectangle(0,0,(int)dFW,(int)dFH);
    tr=new Transform(getDevice());
    gc.getTransform(tr);
    if (la.getCaption().getFont().getRotation() != 0) {
      float rotate=(float)la.getCaption().getFont().getRotation();
      double dAngleInRadians=((-rotate * Math.PI) / 180.0);
      double dSineTheta=Math.sin(dAngleInRadians);
      float tTx=(float)(dX - dFW / 2);
      float tTy=(float)(dY - dFH / 2);
      if (rotate > 0)       tTy+=dFW * Math.abs(dSineTheta);
 else       tTx+=dFH * Math.abs(dSineTheta);
      tr.translate((float)(dFW / 2),(float)(dFH / 2));
      tr.translate(tTx,tTy);
      tr.rotate(-rotate);
    }
 else {
      R31Enhance.translate(gc,tr,(float)dX,(float)dY);
    }
    previousClipping=new Region();
    gc.getClipping(previousClipping);
    R31Enhance.setTransform(gc,tr);
  }
 else {
    r=new Rectangle((int)dX,(int)dY,(int)dFW,(int)dFH);
  }
  boolean bFullyTransparent=true;
  if (la.getBackground() != null) {
    bFullyTransparent=(((ColorDefinition)la.getBackground()).getTransparency() == 0);
    R31Enhance.setAlpha(gc,255);
  }
  if (!bFullyTransparent) {
    final Color clrBackground=(Color)_sxs.getColor((ColorDefinition)la.getBackground());
    final Color clrPreviousBackground=gc.getBackground();
    if (((ColorDefinition)la.getBackground()).isSetTransparency()) {
      R31Enhance.setAlpha(gc,(ColorDefinition)la.getBackground());
    }
    gc.setBackground(clrBackground);
    gc.fillRectangle(r);
    clrBackground.dispose();
    gc.setBackground(clrPreviousBackground);
  }
  gc.setForeground(clrText);
  R31Enhance.setAlpha(gc,la.getCaption().getColor());
  final Font f=(Font)_sxs.createFont(fd);
  gc.setFont(f);
  TextStyle style=new TextStyle(f,null,null);
  style.underline=fd.isUnderline();
  style.strikeout=fd.isStrikethrough();
  TextLayout layout=new TextLayout(gc.getDevice());
  if (R31Enhance.isR31Available()) {
    for (int i=0; i < itm.getLineCount(); i++) {
      String oText=itm.getLine(i);
      dW=gc.textExtent(oText).x;
      if (bRightAligned) {
        dXOffset=-ins.getLeft() + dFW - dW - ins.getRight();
      }
 else       if (bCenterAligned) {
        dXOffset=-ins.getLeft() + (dFW - dW) / 2;
      }
      int x=(int)(dXOffset + ins.getLeft());
      int y=(int)(dH * i + ins.getTop());
      layout.setText(oText);
      layout.setStyle(style,0,oText.length());
      layout.draw(gc,x,y);
    }
  }
 else {
    for (int i=0; i < itm.getLineCount(); i++) {
      String oText=itm.getLine(i);
      dW=gc.textExtent(oText).x;
      if (bRightAligned) {
        dXOffset=-ins.getLeft() + dFW - dW - ins.getRight();
      }
 else       if (bCenterAligned) {
        dXOffset=-ins.getLeft() + (dFW - dW) / 2;
      }
      int x=(int)(dX + dXOffset + ins.getLeft());
      int y=(int)(dY + dH * i + ins.getTop());
      layout.setText(oText);
      layout.setStyle(style,0,oText.length());
      layout.draw(gc,x,y);
    }
  }
  R31Enhance.setTransform(gc,trOld);
  if (previousClipping != null) {
    gc.setClipping(previousClipping);
    previousClipping.dispose();
  }
  R31Enhance.disposeTransform(trOld);
  R31Enhance.disposeTransform(tr);
  layout.dispose();
  f.dispose();
  clrText.dispose();
  cComp.recycleTextMetrics(itm);
}