Buggy code:
OS . ATSUSetRunStyle ( layout , indentStyle , offset , 1 ) ; } OS . ATSUGetLayoutControl ( layout , kATSULineWidthTag , 4 , buffer , null ) ; int wrapWidth = buffer [ 0 ] ; for ( int i = 0 , start = 0 ; i < ( hardBreaks . length ) ; i ++ ) { int hardBreak = hardBreaks [ i ] ; buffer [ 0 ] = 0 ; if ( wrapWidth != 0 ) OS . ATSUBatchBreakLines ( layout , start , ( hardBreak - start ) , wrapWidth , buffer ) ; OS . ATSUSetSoftLineBreak ( layout , hardBreak ) ; start = hardBreak ; } OS . ATSUGetSoftLineBreaks ( layout , 0 , kATSUToTextEnd , 0 , null , buffer ) ; int count = buffer [ 0 ] ; breaks = new int [ count ] ; OS . ATSUGetSoftLineBreaks ( layout , 0 , kATSUToTextEnd , count , breaks , null ) ; int lineCount = breaks . length ; lineX = new int [ lineCount ] ; lineWidth = new int [ lineCount ] ; lineHeight = new int [ lineCount ] ; lineAscent = new int [ lineCount ] ; ATSTrapezoid trapezoid = new ATSTrapezoid ( ) ; for ( int i = 0 , start = 0 ; i < lineCount ; i ++ ) { if ( ( ascent ) != ( - 1 ) ) { ptr = OS . NewPtr ( 4 ) ; buffer [ 0 ] = OS . kATSUseLineHeight ; OS . memcpy ( ptr , buffer , 4 ) ; tags = new int [ ] { OS . kATSULineAscentTag } ; sizes = new int [ ] { 4 } ; values = new int [ ] { ptr } ; OS . ATSUSetLineControls ( layout , start , tags . length , tags , sizes , values ) ; OS . ATSUGetLineControl ( layout , start , kATSULineAscentTag , 4 , buffer , null ) ; buffer [ 0 ] = OS . Long2Fix ( Math . max ( ascent , OS . Fix2Long ( buffer [ 0 ] ) ) ) ; OS . memcpy ( ptr , buffer , 4 ) ; OS . ATSUSetLineControls ( layout , start , tags . length , tags , sizes , values ) ; OS . DisposePtr ( ptr ) ; } if ( ( descent ) != ( - 1 ) ) { ptr = OS . NewPtr ( 4 ) ; buffer [ 0 ] = OS . kATSUseLineHeight ; OS . memcpy ( ptr , buffer , 4 ) ; tags = new int [ ] { OS . kATSULineDescentTag } ; sizes = new int [ ] { 4 } ; values = new int [ ] { ptr } ; OS . ATSUSetLineControls ( layout , start , tags . length , tags , sizes , values ) ; OS . ATSUGetLineControl ( layout , start , kATSULineDescentTag , 4 , buffer , null ) ; buffer [ 0 ] = OS . Long2Fix ( Math . max ( descent , OS . Fix2Long ( buffer [ 0 ] ) ) ) ; OS . memcpy ( ptr , buffer , 4 ) ; OS . ATSUSetLineControls ( layout , start , tags . length , tags , sizes , values ) ; OS . DisposePtr ( ptr ) ; } int lineBreak = breaks [ i ] ; int lineLength = lineBreak - start ; OS . ATSUGetGlyphBounds ( layout , 0 , 0 , start , lineLength , ( ( short ) ( kATSUseDeviceOrigins ) ) , 1 , trapezoid , null ) ; lineX [ i ] = OS . Fix2Long ( trapezoid . lowerLeft_x ) ; lineAscent [ i ] = - ( OS . Fix2Long ( trapezoid . upperRight_y ) ) ; if ( lineLength != 0 ) { <START_BUG> lineWidth [ i ] = ( OS . Fix2Long ( trapezoid . upperRight_x ) ) - ( OS . Fix2Long ( trapezoid . upperLeft_x ) ) ; <END_BUG> } lineHeight [ i ] = ( ( OS . Fix2Long ( trapezoid . lowerRight_y ) ) + ( lineAscent [ i ] ) ) + ( spacing ) ; start = lineBreak ; } } public void dispose ( ) { } 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 ) { } void freeRuns ( ) { } public int getAlignment ( ) { } public int getAscent ( ) { } public Rectangle getBounds ( ) { } 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 ( ) { }

Fix:
lineWidth [ i ] = ( OS . Fix2Long ( trapezoid . lowerRight_x ) ) - ( OS . Fix2Long ( trapezoid . lowerLeft_x ) ) ;