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 final RGB LINK_FOREGROUND = new RGB ( 0 , 51 , 153 ) ; int [ ] invalidOffsets ; static final char LTR_MARK = '‎' ; static final char RTL_MARK = '‏' ; static final char ZWS = '​' ; 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 ( ) { checkLayout ( ) ; NSAutoreleasePool pool = null ; if ( ! ( NSThread . isMainThread ( ) ) ) pool = ( ( NSAutoreleasePool ) ( new NSAutoreleasePool ( ) . alloc ( ) . init ( ) ) ) ; try { computeRuns ( ) ; NSRect rect = layoutManager . usedRectForTextContainer ( textContainer ) ; if ( ( wrapWidth ) != ( - 1 ) ) rect . width = wrapWidth ; if ( ( text . length ( ) ) == 0 ) { Font font = ( ( this . font ) != null ) ? this . font : device . systemFont ; NSFont nsFont = font . handle ; <START_BUG> rect . height = Math . max ( rect . height , layoutManager . defaultLineHeightForFont ( nsFont ) ) ; <END_BUG> } rect . height = ( Math . max ( rect . height , ( ( ascent ) + ( descent ) ) ) ) + ( spacing ) ; return new Rectangle ( 0 , 0 , ( ( int ) ( rect . width ) ) , ( ( int ) ( rect . height ) ) ) ; } finally { if ( pool != null ) pool . release ( ) ; } } public Rectangle getBounds ( int start , int end ) { } 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 ( ) { } String getSegmentsText ( ) { } public int getSpacing ( ) { } public TextStyle getStyle ( int offset ) { } public TextStyle [ ] getStyles ( ) { } public int [ ] getTabs ( ) { } public String getText ( ) { } public int getWidth ( ) { } public boolean isDisposed ( ) { } boolean isUnderlineSupported ( TextStyle style ) { } 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:
rect . height = layoutManager . defaultLineHeightForFont ( nsFont ) ;