各位大虾:
小弟用GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();函数可以得到系统支持的字体。
可是这些字体中有很多字体仍然无法正常显示,显示的结果是一堆“口口口”的情况。例如symbol
请问问题出在哪里?
小弟用GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();函数可以得到系统支持的字体。
可是这些字体中有很多字体仍然无法正常显示,显示的结果是一堆“口口口”的情况。例如symbol
请问问题出在哪里?
我也不是很懂的说
这是一段代码
你可以看看 不知对你有没帮助
if(e.getActionCommand().equals("font"))
{
final Dialog d = new Dialog ( f , "Font");
d.setLocation( 250 ,250);
d.setLayout( new BorderLayout());//表格布局
Label l_font = new Label ("font");
Panel p_1 = new Panel();
p_1.add(l_font);
p_1.setVisible(true);
List font_list = new List (6 , false);//字体列表
font_list.add("Plain");///普通字体
font_list.add("Bold"); ///粗体
font_list.add("Italic");//斜体
font_list.addItemListener( new MyItemListener_font() ); //字体增加监视器
Panel p_2 = new Panel();
p_2.add(font_list);
p_2.setVisible(true);
Button ok = new Button ("OK");
ok.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent e){
d.dispose();
}
});
ok.setSize( new Dimension (20 , 5) );
Panel p_3 = new Panel();
p_3.add(ok);
p_3.setVisible(true);
//添加三个面板
d.add(p_1 , BorderLayout.NORTH);
d.add(p_2 , BorderLayout.CENTER);
d.add(p_3 , BorderLayout.SOUTH);
d.pack();
d.addWindowListener( new WindowAdapter(){ //关闭对话框窗口
public void windowClosing(WindowEvent ee){
d.dispose();
}
});
d.setVisible(true);
}
凡是设置字体之后显示(西文)+(中文)的,
就代表那个字体不支持中文,
我这里设置symbol就有(西文)的提示.
需要配合中文字体使用喵~~```
但是对您说的“楼主可以先去word里44看,凡是设置字体之后显示(西文)+(中文)的 ”
我不知道在哪能找到这个信息。希望您能再提示小弟一下
必定高分相送!感谢!!!
这是让我最头疼的根本问题~~
再次感谢
String[] strings = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
for(int i = 0; i < strings.length; i++) {
System.out.println(strings[i]);
}
结果:
Algerian
Arial
Arial Black
Arial Narrow
Arial Unicode MS
Basemic Symbol
Basemic Times
BasemicNew
Baskerville Old Face
Batang
BatangChe
Bauhaus 93
Bell MT
Berlin Sans FB
Berlin Sans FB Demi
Bernard MT Condensed
Bodoni MT Poster Compressed
Book Antiqua
Bookman Old Style
Bookshelf Symbol 7
Bradley Hand ITC
Britannic Bold
Broadway
Brush Script MT
Californian FB
Centaur
Century
Century Gothic
Chiller
Colonna MT
Comic Sans MS
Cooper Black
Courier New
Dialog
DialogInput
Dotum
DotumChe
Estrangelo Edessa
Footlight MT Light
Franklin Gothic Medium
Freestyle Script
French Script MT
Garamond
Gautami
Georgia
Gulim
GulimChe
Gungsuh
GungsuhChe
Haettenschweiler
Harlow Solid Italic
Harrington
High Tower Text
Impact
Informal Roman
Jokerman
Juice ITC
Kartika
Kingsoft Phonetic Plain
Kristen ITC
Kunstler Script
Latha
Lucida Bright
Lucida Calligraphy
Lucida Console
Lucida Fax
Lucida Handwriting
Lucida Sans
Lucida Sans Typewriter
Lucida Sans Unicode
Magneto
Mangal
Marlett
Matura MT Script Capitals
Microsoft Sans Serif
MingLiU
Mistral
Modern No. 20
Monospaced
Monotype Corsiva
MS Gothic
MS Mincho
MS Outlook
MS PGothic
MS PMincho
MS Reference Sans Serif
MS Reference Specialty
MS UI Gothic
MV Boli
Niagara Engraved
Niagara Solid
Nina
Old English Text MT
Onyx
Palatino Linotype
Papyrus
Parchment
Playbill
PMingLiU
Poor Richard
Pristina
Raavi
Ravie
SansSerif
Segoe Condensed
Segoe UI
Serif
Showcard Gothic
Shruti
Snap ITC
Stencil
Sylfaen
Symbol
Tahoma
Tempus Sans ITC
Times New Roman
Trebuchet MS
Tunga
Verdana
Viner Hand ITC
Vivaldi
Vladimir Script
Vrinda
Webdings
Wide Latin
Wingdings
Wingdings 2
Wingdings 3
仿宋_GB2312
华文中宋
华文仿宋
华文宋体
华文彩云
华文新魏
华文楷体
华文琥珀
华文细黑
华文行楷
华文隶书
宋体
宋体-方正超大字符集
幼圆
微软雅黑
新宋体
方正姚体
方正舒体
楷体_GB2312
隶书
黑体
我用GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()得到系统支持的字体也有symbol
但是为什么显示ABC的时候会出现“口口口”的情况呢?
首先确认选择的font是否支持你输出string的编码。
Symbol支持的文字很有限,
你看看这里:http://www.iancgbell.clara.net/maths/symbols.htm
并不是所有的字体都可以显示所有编码下的文字。
选择支持UTF-8的字体就好了,不要弄那些不常用的。
您的回复给我很大的启发,但是我当前默认配置就是utf8
以下就是我文字输出的地方,而问题仍没有根本解决。输出仍是口口口口
不过无论如何还是很谢谢您,你的回复让我明白了一些细节。
Font fonts1 = new Font("Symbol", 0, 12);
g.setFont(fonts1);
String text="Font Demo";
g.drawString(text, x, y + 6);