【发布时间】:2013-03-11 11:39:56
【问题描述】:
GraphicsEnvironment 的 getAllFonts() 方法为什么返回不同的字体 比 fc-list(在 linux 上?)
fc-list 返回:
Abyssinica SIL:style=Regular
Cantarell:style=Bold
Cantarell:style=Regular
Century Schoolbook L:style=Bold
Century Schoolbook L:style=Bold Italic
Century Schoolbook L:style=Italic
Century Schoolbook L:style=Roman
Courier:style=Regular
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
DejaVu Sans,DejaVu Sans Light:style=ExtraLight
DejaVu Sans Mono:style=Bold
DejaVu Sans Mono:style=Bold Oblique
DejaVu Sans Mono:style=Book
DejaVu Sans Mono:style=Oblique
DejaVu Sans:style=Bold
DejaVu Sans:style=Bold Oblique
DejaVu Sans:style=Book
DejaVu Sans:style=Oblique
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold,Bold
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Bold Italic,Bold Italic
DejaVu Serif,DejaVu Serif Condensed:style=Condensed,Book
DejaVu Serif,DejaVu Serif Condensed:style=Condensed Italic,Italic
DejaVu Serif:style=Bold
DejaVu Serif:style=Bold Italic
DejaVu Serif:style=Book
DejaVu Serif:style=Italic
Dingbats:style=Regular
...
而
GraphicsEnvironment 中的 getAllFonts 返回:
AbyssinicaSIL
CenturySchL-Bold
CenturySchL-BoldItal
CenturySchL-Ital
CenturySchL-Roma
DejaVuSans
DejaVuSans-Bold
DejaVuSans-BoldOblique
DejaVuSansCondensed
DejaVuSansCondensed-Bold
DejaVuSansCondensed-BoldOblique
DejaVuSansCondensed-Oblique
DejaVuSans-ExtraLight
DejaVuSansMono
DejaVuSansMono-Bold
DejaVuSansMono-BoldOblique
DejaVuSansMono-Oblique
DejaVuSans-Oblique
DejaVuSerif
DejaVuSerif-Bold
DejaVuSerif-BoldItalic
DejaVuSerifCondensed
DejaVuSerifCondensed-Bold
DejaVuSerifCondensed-BoldItalic
DejaVuSerifCondensed-Italic
DejaVuSerif-Italic
Dialog.bold
Dialog.bolditalic
Dialog.italic
Dialog.plain
DialogInput.bold
DialogInput.bolditalic
DialogInput.italic
DialogInput.plain
Dingbats
...
比较这两个不同的列表,教学列表中的字体不可用。
谁能解释这是怎么回事?
补充说明:
我首先提出这个问题的原因是,我试图找出一些 UI 问题,即在一个操作系统(例如 Solaris)上定义的字体与在另一个操作系统(例如 Linux)上定义的字体不同。
我认为问题在于,虽然两个操作系统具有相同的逻辑字体(对话框), 它们不一定具有相同的物理字体。
但是如果你制作这样的字体:
Font STANDARD_FONT = new Font("Dialog", 0, 12);
不保证到处都是一样的。
我希望我可以查看两个系统上可用的字体,看看哪些是通过 fc-list 可用的,但是 java (Dialog.plain) 报告的字体不是 fc-list 列出的字体。
所以,如果我通过 new Font("Dialog", 0, 12) 定义一个逻辑字体, 通过 java 可用的 API(例如 font.getName() 等)显示:
后记 - Dialog.plain 家庭 - 对话 名称 - 对话框 fontName - Dialog.plain 尺寸 - 12
我怎样才能准确地知道 java 为 Dialog Family 选择了哪种物理字体?
【问题讨论】: