Fontの一覧を取得する
Total: 11157
, Today: 3
, Yesterday: 2
Posted by aterai at
Last-modified:
Summary
Font
一覧を取得して、Font
のファミリ名、論理名などを表示します。
Screenshot

Advertisement
Source Code Examples
Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
View in GitHub: Java, KotlinExplanation
上記のサンプルでは、GraphicsEnvironment#getAllFonts()
メソッドを使って、この環境で利用可能なフォントの一覧を取得しています。
このメソッドは、ユーザーに特定のフォントを選択させる場合によく使用されます。
family
getFamily()
でFont
のファミリ名Font#getFontName()
で取得できるのはフォントフェース名family
+style
になっている場合が多い?- ベンダーによって結構バラバラ?
name
getName()
でFont
の論理名
postscript name
Font
のポストスクリプト名
GraphicsEnvironment#getAvailableFontFamilyNames()
メソッドでフォントファミリ名の配列を取得可能
Reference
- GraphicsEnvironment#getAllFonts() (Java Platform SE 8)
- Java 2D API: 4.2 フォントのコンセプト
- Physical and Logical Fonts (The Java™ Tutorials > 2D Graphics > Working with Text APIs)