Re: build a browser in java
Since the fonts I use don't include chinese characters (but dingbat
symbols) I get a small rectangle followed by the scissors.
..
yeah! good i18n Fonts you may find at (Got infor after some googling
from http://www.alanwood.net/unicode/fonts.html):
..
// __
Arial Unicode MS - 38,917 characters (50,377 glyphs) in version 1.01
OpenType layout tables: Arabic, Devanagari, Gujarati, Gurmukhi, Han
Ideographic, Kana [Hiragana & Katakana], Kannada, Tamil
Family: Sans-serif
Styles: Regular
Availability: Supplied with Microsoft Office 2002 (XP) and Microsoft
Office 2003.
..
// __
Bitstream CyberBit - 29,934 glyphs in version beta v2.0
OpenType layout tables: Arabic
Family: Serif
Styles: Regular
Availability: Free download from
ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/
..
Bitstream CyberCJK - 28,686 glyphs in version beta v2.0
Family: Serif
Styles: Regular
Availability: Free download from
ftp://ftp.netscape.com/pub/communicator/extras/fonts/windows/
// __
Code2000 - 51,239 characters (61,864 glyphs) in version 1.16
Includes many characters that are difficult to find elsewhere, making
it a useful font to assign to the user-defined encoding or character
set in your Web browser, and well worth the $5 registration. Produced
by James Kass.
Family: Serif
Styles: Regular
Availability: shareware $5 payable via paypal to
jameskass@code2000.net
http://www.code2000.net/code2000_page.htm
..
// __
and with this piece of code (again reworking/repurposing yours ;-))
you can load TTFs from a local file (without tinkering with
font.properties) and see both the chinese chars and the scissors
..
// __
import java.awt.*;
import javax.swing.*;
import java.io.*;
// __
public class UnicodeFrm06{
private static Font dynFnt32Pt = null;
// __
public static void main( String args[] ){
// __ with Cyberbit TTF fonts you see then the Chinese chars but not
the scissors
String aTTF_Fl = "/lib/fonts/Cyberbit.ttf";
// __ with CODE2000 TTF fonts you see both
aTTF_Fl = "/lib/fonts/CODE2000.TTF";
// __
String aJvHmProp = System.getProperty("java.home");
File Fl = new File(aJvHmProp, aTTF_Fl);
String aFlPath = Fl.getAbsolutePath();
// __
float fSz = 32f;
dynFnt32Pt = setCtxtFonts(aFlPath, fSz);
if(dynFnt32Pt != null){
JFrame frame = new JFrame("UnicodeFrm06");
frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
JLabel Ji18nLbl = new JLabel("\u4e10 \u2704");
Ji18nLbl.setBackground(Color.white);
Ji18nLbl.setFont(dynFnt32Pt);
Ji18nLbl.setToolTipText(" TTFs from: " + aFlPath);
frame.getContentPane().add(Ji18nLbl);
frame.getContentPane().setBackground(Color.white);
frame.pack();
frame.setVisible(true);
}
else{ System.err.println("// __ Fonts could not be set from file: |"
+ aFlPath + "|"); }
}
// __ loading fonts from a data feed programatically
private static Font setCtxtFonts(String aFlPath, float fSz){
Font Fnt = null;
try{
FileInputStream FIS = new FileInputStream((new File(aFlPath)));
Font dynFnt = Font.createFont(Font.TRUETYPE_FONT, FIS);
Fnt = dynFnt.deriveFont(fSz);
FIS.close();
}catch(FileNotFoundException FlNF){ FlNF.printStackTrace(); }
catch(FontFormatException FFX){ FFX.printStackTrace(); }
catch(IOException IOX){ IOX.printStackTrace(); }
// __
return(Fnt);
}
}