0 Replies Latest reply on Feb 2, 2011 9:27 PM by 836385

    How to Render Malayalam Font Correctly?

      I am trying to render array of characters defined as char[] chars = {0x0D2C,0x0D3E,0x0D32,0x0D28,0x0D4D,0x200D}. The font is Arial Unicode MS that is installed under Windows XP SP3 system. Here is a code snippet:

      public void paintComponent(Graphics g)
      Graphics2D g2d = (Graphics2D) g;
      int screenRes = Toolkit.getDefaultToolkit().getScreenResolution();

      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

      String text ;
      char[] chars = {0x0D2C,0x0D3E,0x0D32,0x0D28,0x0D4D,0x200D};
      int fontSize = (int) Math.round( 72.0 * screenRes / 72.0);
      Font font = new Font("Arial Unicode MS", Font.PLAIN, fontSize);
      font = new Font("Kartika", Font.PLAIN, fontSize);
      text = new String(chars);

      g2d.drawString(text, 100, 150);


      The result of rendering is:

      But what is expected should be:

      This is because last char 0x200D in the array is a joint in the font. It seams that Java gets confused. If I render the same char arrays by using Internet Explorer, the correct Malayalam font characters are displayed. BTW, I tried using GlyphVector as well. It didn't render correctly either.

      Help me please.

      Edited by: 833382 on Feb 2, 2011 1:26 PM