How to make different fonts appear in JTextField. Say a Hindi font or chinese font

Ashwin Chathuruthy

In the java code you must put only the following line


        JTextFiledName.setFont(new Font("Shusha", Font.PLAIN, 16));

Make sure you have the following setup done.

To display a font. Say a hindi font like Shusha. You must edit a file called font.properties in the jre/lib(in jdk1.2.2) and in my case Java2 under Visual cafe. Make the following modifications to that file.

Add the line below.


dialog.3=Shusha,SYMBOL_CHARSET,NEED_CONVERTED

Note if you are adding another font make sure it becomes


dialog.4=xxxx,SYMBOL_CHARSET,NEED_CONVERTED

Then repeat for bold, italics etc


...
dialog.bold.3=Shusha,SYMBOL_CHARSET,NEED_CONVERTED

.....
dialog.italic.3=Shusha,SYMBOL_CHARSET,NEED_CONVERTED

....
dialog.bolditalic.3=Shusha,SYMBOL_CHARSET,NEED_CONVERTED

After that add the following line under where its written


# font filenames for reduced initialization time
#

filename.Shusha=SHUSHA.TTF

Here SHUSHA is the font name. It can be thoolica.ttf. I think its better to follow the same case of the one shown under the windows/font directory. Like SHUSHA is in all caps

Then add to the line below


# Static FontCharset info.
#

fontcharset.dialog.3=sun.awt.CharToByteSymbol

Now try running the application and enter a text in the text field and voila you get it in the language you want it.

And dont forget to have the font installed in your windows/font directory. If still not working make a copy in the fonts directory under the jvm/fonts directory

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact