Buggy code:
public final class TextLayout extends Resource { NSTextStorage textStorage ; NSLayoutManager layoutManager ; NSTextContainer textContainer ; Font font ; String text ; TextLayout . StyleItem [ ] styles ; int spacing ; int ascent ; int descent ; int indent ; boolean justify ; int alignment ; int [ ] tabs ; int [ ] segments ; int wrapWidth ; int orientation ; int [ ] lineOffsets ; NSRect [ ] lineBounds ; static final int UNDERLINE_THICK = 1 << 16 ; static class StyleItem { TextStyle style ; int start ; public String toString ( ) { } } public TextLayout ( Device device ) { } void checkLayout ( ) { } float [ ] computePolyline ( int left , int top , int right , int bottom ) { } void computeRuns ( ) { } void destroy ( ) { } public void draw ( GC gc , int x , int y ) { } public void draw ( GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground ) { } public void draw ( GC gc , int x , int y , int selectionStart , int selectionEnd , Color selectionForeground , Color selectionBackground , int flags ) { } void freeRuns ( ) { } public int getAlignment ( ) { } public int getAscent ( ) { } public Rectangle getBounds ( ) { } public Rectangle getBounds ( int start , int end ) { checkLayout ( ) ; NSAutoreleasePool pool = null ; if ( ! ( NSThread . isMainThread ( ) ) ) pool = ( ( NSAutoreleasePool ) ( new NSAutoreleasePool ( ) . alloc ( ) . init ( ) ) ) ; try { computeRuns ( ) ; int length = text . length ( ) ; if ( length == 0 ) return new Rectangle ( 0 , 0 , 0 , 0 ) ; if ( start > end ) return new Rectangle ( 0 , 0 , 0 , 0 ) ; start = Math . min ( Math . max ( 0 , start ) , ( length - 1 ) ) ; end = Math . min ( Math . max ( 0 , end ) , ( length - 1 ) ) ; start = translateOffset ( start ) ; end = translateOffset ( end ) ; NSRange range = new NSRange ( ) ; range . location = layoutManager . glyphIndexForCharacterAtIndex ( start ) ; range . length = ( layoutManager . glyphIndexForCharacterAtIndex ( ( end + 1 ) ) ) - ( range . location ) ; NSRect rect = layoutManager . boundingRectForGlyphRange ( range , textContainer ) ; <START_BUG> return new Rectangle ( ( ( int ) ( rect . x ) ) , ( ( int ) ( rect . y ) ) , ( ( int ) ( Math . ceil ( rect . width ) ) ) , ( ( int ) ( Math . ceil ( rect . height ) ) ) ) ; <END_BUG> } finally { if ( pool != null ) pool . release ( ) ; } } public int getDescent ( ) { } public Font getFont ( ) { } public int getIndent ( ) { } public boolean getJustify ( ) { } public int getLevel ( int offset ) { } public int [ ] getLineOffsets ( ) { } public int getLineIndex ( int offset ) { } public Rectangle getLineBounds ( int lineIndex ) { } public int getLineCount ( ) { } public FontMetrics getLineMetrics ( int lineIndex ) { } public Point getLocation ( int offset , boolean trailing ) { } public int getNextOffset ( int offset , int movement ) { } int _getOffset ( int offset , int movement , boolean forward ) { } public int getOffset ( Point point , int [ ] trailing ) { } public int getOffset ( int x , int y , int [ ] trailing ) { } public int getOrientation ( ) { } public int getPreviousOffset ( int index , int movement ) { } public int [ ] getRanges ( ) { } public int [ ] getSegments ( ) { } public int getSpacing ( ) { } public TextStyle getStyle ( int offset ) { } public TextStyle [ ] getStyles ( ) { } public int [ ] getTabs ( ) { } public String getText ( ) { } public int getWidth ( ) { } public boolean isDisposed ( ) { } public void setAlignment ( int alignment ) { } public void setAscent ( int ascent ) { } public void setDescent ( int descent ) { } public void setFont ( Font font ) { } public void setIndent ( int indent ) { } public void setJustify ( boolean justify ) { } public void setOrientation ( int orientation ) { } public void setSegments ( int [ ] segments ) { } public void setSpacing ( int spacing ) { } public void setStyle ( TextStyle style , int start , int end ) { } public void setTabs ( int [ ] tabs ) { } public void setText ( String text ) { } public void setWidth ( int width ) { } public String toString ( ) { } int translateOffset ( int offset ) { } int untranslateOffset ( int offset ) { } }

Fix:
return new Rectangle ( ( ( int ) ( rect . x ) ) , ( ( int ) ( rect . y ) ) , ( ( int ) ( 0.5F + ( rect . width ) ) ) , ( ( int ) ( 0.5F + ( rect . height ) ) ) ) ;