爲什麼GraphicsEnvironment中的getAllFonts()方法返回不同的字體 比fc-list的爲什麼GraphicsEnvironment的getAllFonts()返回與fc-list不同的字體?
fc-list的回報(在Linux上):
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
...
而
getAllFonts在GraphicsEnvironment中返回:
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列出的字體。
所以,如果我通過定義新的字體( 「對話」,0,12)邏輯字體, 通過Java可用的API(如font.getName()等)顯示:
後記 - 對話。平原 家庭 - 對話 名字 - 對話 的fontName - Dialog.plain 大小 - 12
我怎麼能知道什麼物理字體Java已經選擇使用該對話框家庭?
感謝澄清瓦肯。我在上面添加了一些筆記,以瞭解我看到的和我看不到的東西, – 2013-03-11 03:41:13
要發現每個邏輯字體映射到的內容,您需要閱讀[Java的字體配置文件](http://docs.oracle.com/javase /7/docs/technotes/guides/intl/fontconfig.html)。 – Vulcan 2013-03-11 03:49:32
似乎有點難看,因爲沒有辦法確定它正在選擇哪個屬性文件。我基於java api指南做出了一個很好的猜測,但是如果有一個API會打印它選擇的物理字體的名稱,它會更好。感謝偉大的信息瓦肯,非常明確的建議。 – 2013-03-11 20:40:51