0 Replies Latest reply: Feb 2, 2011 3:27 PM by 836385 RSS

    How to Render Malayalam Font Correctly?

    836385
      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)
      {              
      super.paintComponent(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);
      g2d.setFont(font);
      text = new String(chars);

      g2d.drawString(text, 100, 150);

      g2d.dispose();
      }

      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