Buggy code:
NSAutoreleasePool pool = gc . checkGC ( ( ( ( GC . CLIPPING ) | ( GC . TRANSFORM ) ) | ( GC . FOREGROUND ) ) ) ; try { computeRuns ( ) ; int length = translateOffset ( text . length ( ) ) ; if ( ( length == 0 ) && ( flags == 0 ) ) return ; gc . handle . saveGraphicsState ( ) ; NSPoint pt = new NSPoint ( ) ; pt . x = x ; pt . y = y ; NSRange range = new NSRange ( ) ; int numberOfGlyphs = layoutManager . numberOfGlyphs ( ) ; if ( numberOfGlyphs > 0 ) { range . location = 0 ; range . length = numberOfGlyphs ; layoutManager . drawBackgroundForGlyphRange ( range , pt ) ; } boolean hasSelection = ( ( selectionStart <= selectionEnd ) && ( selectionStart != ( - 1 ) ) ) && ( selectionEnd != ( - 1 ) ) ; if ( hasSelection || ( ( flags & ( SWT . LAST_LINE_SELECTION ) ) != 0 ) ) { if ( selectionBackground == null ) selectionBackground = device . getSystemColor ( COLOR_LIST_SELECTION ) ; NSColor selectionColor = NSColor . colorWithDeviceRed ( selectionBackground . handle [ 0 ] , selectionBackground . handle [ 1 ] , selectionBackground . handle [ 2 ] , selectionBackground . handle [ 3 ] ) ; NSBezierPath path = NSBezierPath . bezierPath ( ) ; NSRect rect = new NSRect ( ) ; if ( hasSelection ) { int pRectCount = OS . malloc ( PTR_SIZEOF ) ; range . location = translateOffset ( selectionStart ) ; range . length = translateOffset ( ( ( selectionEnd - selectionStart ) + 1 ) ) ; int pArray = layoutManager . rectArrayForCharacterRange ( range , range , textContainer , pRectCount ) ; int [ ] rectCount = new int [ 1 ] ; OS . memmove ( rectCount , pRectCount , PTR_SIZEOF ) ; OS . free ( pRectCount ) ; for ( int k = 0 ; k < ( rectCount [ 0 ] ) ; k ++ , pArray += NSRect . sizeof ) { OS . memmove ( rect , pArray , sizeof ) ; fixRect ( rect ) ; rect . x += pt . x ; rect . y += pt . y ; rect . height = Math . max ( rect . height , ( ( ascent ) + ( descent ) ) ) ; path . appendBezierPathWithRect ( rect ) ; } } if ( ( flags & ( SWT . LAST_LINE_SELECTION ) ) != 0 ) { NSRect bounds = lineBounds [ ( ( lineBounds . length ) - 1 ) ] ; rect . x = ( ( pt . x ) + ( bounds . x ) ) + ( bounds . width ) ; rect . y = y + ( bounds . y ) ; rect . width = ( ( flags & ( SWT . FULL_SELECTION ) ) != 0 ) ? 2147483647 : ( bounds . height ) // 3 ; rect . height = Math . max ( bounds . height , ( ( ascent ) + ( descent ) ) ) ; path . appendBezierPathWithRect ( rect ) ; } selectionColor . setFill ( ) ; path . fill ( ) ; } if ( numberOfGlyphs > 0 ) { range . location = 0 ; range . length = numberOfGlyphs ; float [ ] fg = gc . data . foreground ; <START_BUG> boolean defaultFg = ( ( ( ( fg [ 0 ] ) == 0 ) && ( ( fg [ 1 ] ) == 0 ) ) && ( ( fg [ 2 ] ) == 0 ) ) && ( ( fg [ 3 ] ) == 1 ) ; <END_BUG> if ( ! defaultFg ) { for ( int i = 0 ; i < ( ( styles . length ) - 1 ) ; i ++ ) { TextLayout . StyleItem run = styles [ i ] ; if ( ( ( run . style ) != null ) && ( ( run . style . foreground ) != null ) ) continue ; if ( ( ( ( run . style ) != null ) && ( run . style . underline ) ) && ( ( run . style . underlineStyle ) == ( SWT . UNDERLINE_LINK ) ) ) continue ; range . location = ( length != 0 ) ? translateOffset ( run . start ) : 0 ; range . length = ( translateOffset ( styles [ ( i + 1 ) ] . start ) ) - ( range . location ) ; layoutManager . addTemporaryAttribute ( NSForegroundColorAttributeName , gc . data . fg , range ) ; } } range . location = 0 ; range . length = numberOfGlyphs ; layoutManager . drawGlyphsForGlyphRange ( range , pt ) ; if ( ! defaultFg ) { range . location = 0 ; range . length = length ; layoutManager . removeTemporaryAttribute ( NSForegroundColorAttributeName , range ) ; } NSPoint point = new NSPoint ( ) ; for ( int j = 0 ; j < ( styles . length ) ; j ++ ) { TextLayout . StyleItem run = styles [ j ] ; TextStyle style = run . style ; if ( style == null ) continue ; boolean drawUnderline = ( style . underline ) && ( ! ( isUnderlineSupported ( style ) ) ) ; drawUnderline = drawUnderline && ( ( ( j + 1 ) == ( styles . length ) ) || ( ! ( style . isAdherentUnderline ( styles [ ( j + 1 ) ] . style ) ) ) ) ;

Fix:
boolean defaultFg = ( ( ( ( ( fg [ 0 ] ) == 0 ) && ( ( fg [ 1 ] ) == 0 ) ) && ( ( fg [ 2 ] ) == 0 ) ) && ( ( fg [ 3 ] ) == 1 ) ) && ( ( gc . data . alpha ) == 255 ) ;