title: String width via fontmetrics calculation is very slow if there are arabic or persian letters in text
body: <p>I have a problem. My application interface works much slower if i use eastern languages there. Especially i felt it in components such as JList, JCombobox, JTable. </p>
  
  <p>How i found the performance of FontMetrics.stringWidth method is very slow (500+ times) if in the text at least one letter is arabic or persian. How i know it is commonly used method in various swing components.</p>
  
  <p>Is there a way to boost this method performance?</p>
  
  <p>Here is the example class which demonstrates the problem:</p>
  
  <pre><code>import java.awt.Font;
  import java.awt.FontMetrics;
  import java.awt.Graphics;
  import java.awt.image.BufferedImage;
  
  public class FontMetricsSpeedTest
  {
  
   public static void main( String args[] ) {
    String persian="صصصصصصصصصصصصصصصصصصصصص";
    String english="abcde()agjklj;lkjelwk";
    FontMetrics fm=createFontMetrics(new Font("dialog",Font.PLAIN,12));
    int size=50000;
    long start=System.currentTimeMillis();
    for(int i=0;i&lt;size;i++)
    {
     fm.stringWidth(persian);
    }
    System.out.println("Calculation time for persian: "+(System.currentTimeMillis()-start)+" ms");
    start=System.currentTimeMillis();
    for(int i=0;i&lt;size;i++)
    {
     fm.stringWidth(english);
    }
    System.out.println("Calculation time for english: "+(System.currentTimeMillis()-start)+" ms");
   }
   private static FontMetrics createFontMetrics(Font font)
   {
    BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics g = bi.getGraphics();
    FontMetrics fm = g.getFontMetrics(font);
    g.dispose();
    bi = null;
    return fm;
   }
  }
  </code></pre>
  
  <p>For me it gives next output:</p>
  
  <p>Calculation time for persian: 5482 ms</p>
  
  <p>Calculation time for english: 11 ms</p>