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 ( ' ' ) ; } 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 ; }
Writes text to the result .