code: public void displayText(String text, Matrix endingTextMatrix){
          boolean hardReturn = false;
          if (lastTextLineMatrix != null && lastTextLineMatrix.get(Matrix.I32) != getCurrentTextLineMatrix().get(Matrix.I32)){
              hardReturn = true;
          }
  
          float currentX = getCurrentTextMatrix().get(Matrix.I31);
          if (hardReturn){
              result.append('\n');
          } else if (lastEndingTextMatrix != null){
              float lastEndX = lastEndingTextMatrix.get(Matrix.I31);
              
              float spaceGlyphWidth = gs().font.getWidth(' ')/1000f;
              float spaceWidth = (spaceGlyphWidth * gs().fontSize + gs().characterSpacing + gs().wordSpacing) * gs().horizontalScaling; // this is unscaled!!
              Matrix scaled = new Matrix(spaceWidth, 0).multiply(getCurrentTextMatrix());
              float scaledSpaceWidth = scaled.get(Matrix.I31) - getCurrentTextMatrix().get(Matrix.I31);
              
              if (currentX - lastEndX > scaledSpaceWidth/2f ){
                  result.append(' ');
              }
          }
          
          if (text != null && result != null) {
          	result.append(text);
          }
  
          lastTextLineMatrix = getCurrentTextLineMatrix();
          lastEndingTextMatrix = endingTextMatrix;
          
      }
docs: Writes text to the result.
  @param text	The text that needs to be displayed
  @param endingTextMatrix	a text matrix
  @see com.lowagie.text.pdf.parser.PdfContentStreamProcessor#displayText(java.lang.String, com.lowagie.text.pdf.parser.Matrix)