展开全部
这是我自己改的,你可以参考,我用的是simsun,你只需要修改最后一行,把路径指向simsun.ttf所在的路径就可以了,注意需要有fonts.scale和fonts.dir。
ysj@yjGentoo resources $ cat /opt/sun-jre-1.4.2.04/lib/font.properties
# @(#)font.properties.zh_CN_UTF8.Sun.linux 1.1 03/07/14
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
#
# Component Font Mappings For Linux zh_CN_UTF8
#
serif.0=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1
serif.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.italic.0=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1
serif.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bold.0=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1
serif.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bolditalic.0=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1
serif.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.italic.0=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bold.0=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bolditalic.0=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.italic.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bold.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.italic.0=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bold.0=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-c-*-iso8859-1
dialog.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bolditalic.0=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-c-*-iso8859-1
dialog.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.italic.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bold.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
# Missing Glyph Character
#
default.char=274f
# Component Font Character Encodings
#
fontcharset.serif.0=sun.io.CharToByteISO8859_1
fontcharset.serif.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.sansserif.0=sun.io.CharToByteISO8859_1
fontcharset.sansserif.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.monospaced.0=sun.io.CharToByteISO8859_1
fontcharset.monospaced.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.dialog.0=sun.io.CharToByteISO8859_1
fontcharset.dialog.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.dialoginput.0=sun.io.CharToByteISO8859_1
fontcharset.dialoginput.1=sun.io.CharToByteUnicodeBigUnmarked
# Exclusion Ranges
#
# XFontSet Information
#
fontset.serif.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.serif.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.serif.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.serif.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.default=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
filename.-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1=/usr/share/fonts/ttf/China/simsun.ttf
appendedfontpath=/usr/share/fonts/ttf/China
ysj@yjGentoo resources $ cat /opt/sun-jre-1.4.2.04/lib/font.properties
# @(#)font.properties.zh_CN_UTF8.Sun.linux 1.1 03/07/14
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
#
# Component Font Mappings For Linux zh_CN_UTF8
#
serif.0=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1
serif.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.italic.0=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1
serif.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bold.0=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1
serif.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
serif.bolditalic.0=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1
serif.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.italic.0=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bold.0=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
sansserif.bolditalic.0=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.italic.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bold.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
monospaced.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
monospaced.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.italic.0=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bold.0=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-c-*-iso8859-1
dialog.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialog.bolditalic.0=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-c-*-iso8859-1
dialog.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.italic.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.italic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bold.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bold.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
dialoginput.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bolditalic.1=-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
# Missing Glyph Character
#
default.char=274f
# Component Font Character Encodings
#
fontcharset.serif.0=sun.io.CharToByteISO8859_1
fontcharset.serif.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.sansserif.0=sun.io.CharToByteISO8859_1
fontcharset.sansserif.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.monospaced.0=sun.io.CharToByteISO8859_1
fontcharset.monospaced.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.dialog.0=sun.io.CharToByteISO8859_1
fontcharset.dialog.1=sun.io.CharToByteUnicodeBigUnmarked
fontcharset.dialoginput.0=sun.io.CharToByteISO8859_1
fontcharset.dialoginput.1=sun.io.CharToByteUnicodeBigUnmarked
# Exclusion Ranges
#
# XFontSet Information
#
fontset.serif.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.serif.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.serif.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.serif.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.sansserif.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.monospaced.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialog.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.italic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.bold=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.bolditalic=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.dialoginput.plain=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
fontset.default=\
-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
filename.-misc-simsun-medium-r-normal--*-%d-*-*-c-*-iso10646-1=/usr/share/fonts/ttf/China/simsun.ttf
appendedfontpath=/usr/share/fonts/ttf/China
展开全部
自己改改看吧
import java.awt.EventQueue;
import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.*;
public class T {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frm = new JFrame();
final DefaultStyledDocument model = new DefaultStyledDocument();
final JTextPane p = new JTextPane(model);
p.addCaretListener(new CaretListener() {
int start = 0;
int length = 0;
@Override
public void caretUpdate(CaretEvent e) {
model.setCharacterAttributes(start, length,
new SimpleAttributeSet() {
{
addAttribute(StyleConstants.Italic,
Boolean.FALSE);
addAttribute(StyleConstants.Bold,
Boolean.FALSE);
}
}, true);
start = p.getSelectionStart();
length = p.getSelectionEnd() - start;
model.setCharacterAttributes(start, length,
new SimpleAttributeSet() {
{
addAttribute(StyleConstants.Italic,
Boolean.TRUE);
addAttribute(StyleConstants.Bold,
Boolean.TRUE);
}
}, true);
}
});
frm.add(p);
frm.setSize(400, 400);
frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frm.setVisible(true);
}
});
}
}
import java.awt.EventQueue;
import javax.swing.*;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.*;
public class T {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frm = new JFrame();
final DefaultStyledDocument model = new DefaultStyledDocument();
final JTextPane p = new JTextPane(model);
p.addCaretListener(new CaretListener() {
int start = 0;
int length = 0;
@Override
public void caretUpdate(CaretEvent e) {
model.setCharacterAttributes(start, length,
new SimpleAttributeSet() {
{
addAttribute(StyleConstants.Italic,
Boolean.FALSE);
addAttribute(StyleConstants.Bold,
Boolean.FALSE);
}
}, true);
start = p.getSelectionStart();
length = p.getSelectionEnd() - start;
model.setCharacterAttributes(start, length,
new SimpleAttributeSet() {
{
addAttribute(StyleConstants.Italic,
Boolean.TRUE);
addAttribute(StyleConstants.Bold,
Boolean.TRUE);
}
}, true);
}
});
frm.add(p);
frm.setSize(400, 400);
frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frm.setVisible(true);
}
});
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
部分内容设置字体,感觉应该使用能显示html内容的控件。等高人进一步解答。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询