{ AttributedString as = new AttributedString (string); as.addAttribute (TextAttribute.FONT, font); ClasspathToolkit tk = (ClasspathToolkit)(Toolkit.getDefaultToolkit ()); peer = tk.getClasspathTextLayoutPeer(as, frc);
{ this.font = font; this.frc = frc; this.string = string; lm = font.getLineMetrics(string, frc);   getStringProperties();  if( Bidi.requiresBidi( string.toCharArray(), 0, string.length() ) ) { Bidi bidi = new Bidi( string, leftToRight ? Bidi.DIRECTION_LEFT_TO_RIGHT : Bidi.DIRECTION_RIGHT_TO_LEFT ); int rc = bidi.getRunCount(); byte[] table = new byte[ rc ]; for(int i = 0; i < table.length; i++) table[i] = (byte)bidi.getRunLevel(i);  runs = new GlyphVector[ rc ]; runIndices = new int[rc][2]; for(int i = 0; i < runs.length; i++) { runIndices[i][0] = bidi.getRunStart( i ); runIndices[i][1] = bidi.getRunLimit( i ); if( runIndices[i][0] != runIndices[i][1] ) { runs[i] = font.layoutGlyphVector ( frc, string.toCharArray(), runIndices[i][0], runIndices[i][1], ((table[i] & 1) == 0) ? Font.LAYOUT_LEFT_TO_RIGHT : Font.LAYOUT_RIGHT_TO_LEFT ); } } Bidi.reorderVisually( table, 0, runs, 0, runs.length ); } else { runs = new GlyphVector[ 1 ]; runIndices = new int[1][2]; runIndices[0][0] = 0; runIndices[0][1] = string.length(); runs[ 0 ] = font.layoutGlyphVector( frc, string.toCharArray(), 0, string.length(), leftToRight ? Font.LAYOUT_LEFT_TO_RIGHT : Font.LAYOUT_RIGHT_TO_LEFT ); }
  public TextLayout (String string, Font font, FontRenderContext frc)   {    AttributedString as = new AttributedString (string);    as.addAttribute (TextAttribute.FONT, font);    ClasspathToolkit tk = (ClasspathToolkit)(Toolkit.getDefaultToolkit ());    peer = tk.getClasspathTextLayoutPeer(as, frc);  }