Swing/RegisterFont のバックアップ差分(No.4)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/RegisterFont へ行く。
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:GraphicsEnvironmentにFontを登録して使用する #navi(../) #tags(Font, GraphicsEnvironment, Html, StyleSheet, JLabel, JEditorPane, JTextPane) RIGHT:Posted by &author(aterai); at 2009-10-19 *GraphicsEnvironmentにFontを登録して使用する [#x76fbbb3] ``GraphicsEnvironment``に``Font``を登録して、``Html``タグなどで使用できるようにします。 --- title: GraphicsEnvironmentにFontを登録して使用する tags: [Font, GraphicsEnvironment, Html, StyleSheet, JLabel, JEditorPane, JTextPane] author: aterai pubdate: 2009-10-19T14:42:22+09:00 description: GraphicsEnvironmentにFontを登録して、Htmlタグなどで使用できるようにします。 --- * 概要 [#x76fbbb3] `GraphicsEnvironment`に`Font`を登録して、`Html`タグなどで使用できるようにします。 -&jnlp; -&jar; -&zip; #download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTRkZgST0I/AAAAAAAAAhY/czEyIQL0NfY/s800/RegisterFont.png) //#screenshot #ref(http://lh4.ggpht.com/_9Z4BYR88imo/TQTRkZgST0I/AAAAAAAAAhY/czEyIQL0NfY/s800/RegisterFont.png) **サンプルコード [#r8fa1dfe] * サンプルコード [#r8fa1dfe] #code(link){{ Font font = makeFont(getClass().getResource("Burnstown Dam.ttf")); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font); }} **解説 [#v79aaeaf] -1. ``JLabel#setFont``メソッドでフォントを設定しています。 -2. 登録したフォントを``Html``タグで指定して使用しています。 -- ``lable.setText("<html><font size='+3' face='Burnstown Dam'>2: html,font,size,+3</font></html>");`` -3. ``StyleSheet``で``body``タグのフォントを設定しています。 -- ``styleSheet.addRule("body {font-size: 24pt; font-family: Burnstown Dam;}");`` -4. ``JTextPane#setFont``メソッドでフォントを設定しています。 -- ``body``タグで指定されているフォントを無視して、``JTextPane``のデフォルトのフォントを使用したい場合は、``editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);``としておく必要があります。 * 解説 [#v79aaeaf] - 1. `JLabel#setFont`メソッドでフォントを設定しています。 - 2. 登録したフォントを`Html`タグで指定して使用しています。 -- `label.setText("<html><font size='+3' face='Burnstown Dam'>2: html,font,size,+3</font></html>");` - 3. `StyleSheet`で`body`タグのフォントを設定しています。 -- `styleSheet.addRule("body {font-size: 24pt; font-family: Burnstown Dam;}");` - 4. `JTextPane#setFont`メソッドでフォントを設定しています。 -- `body`タグで指定されているフォントを無視して、`JTextPane`のデフォルトのフォントを使用したい場合は、`editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);`としておく必要があります。 **参考リンク [#p3b209cd] -[http://www.creamundo.com/ creamundo | Fuentes Gratis TrueType TTF] --こちらから``TrueType``フォントを利用しています。 -[[Fontをファイルから取得>Swing/CreateFont]] -[[Htmlを使ったJLabelとJEditorPaneの無効化>Swing/DisabledHtmlLabel]] -[[JEditorPaneのHTMLEditorKitにCSSを適用>Swing/StyleSheet]] * 参考リンク [#p3b209cd] - [http://www.creamundo.com/ creamundo | Fuentes Gratis TrueType TTF] -- こちらから`TrueType`フォントを利用しています。 - [[Fontをファイルから取得>Swing/CreateFont]] - [[Htmlを使ったJLabelとJEditorPaneの無効化>Swing/DisabledHtmlLabel]] - [[JEditorPaneのHTMLEditorKitにCSSを適用>Swing/StyleSheet]] **コメント [#se35441f] * コメント [#se35441f] #comment #comment