UI の日本語フォント指定

Factor の UI のフォントは Vera とかいうので、日本語フォントではい。そのため日本語を表示できない。
それを解決するために、~/.factor-boot-rc で ui.freetype の ttf-name と ttf-path を上書きしてブートイメージを作りなおす。

~/.factor-boot-rc

! -*- mode: factor ; -*-
USING: namespaces ui.freetype ;

85 dpi set-global


! フォントを指定する
USING: arrays io.styles assocs kernel sequences ;
IN: ui.freetype

: ttf-name ( font style -- name )
    2array H{
        { { "monospace" plain        } "VL-Gothic-Regular" }
        { { "monospace" bold         } "VL-Gothic-Regular" }
        { { "monospace" bold-italic  } "VL-Gothic-Regular" }
        { { "monospace" italic       } "VL-Gothic-Regular" }
        { { "sans-serif" plain       } "VL-PGothic-Regular" }
        { { "sans-serif" bold        } "VL-PGothic-Regular" }
        { { "sans-serif" bold-italic } "VL-PGothic-Regular" }
        { { "sans-serif" italic      } "VL-PGothic-Regular" }
        { { "serif" plain            } "VL-PGothic-Regular" }
        { { "serif" bold             } "VL-PGothic-Regular" }
        { { "serif" bold-italic      } "VL-PGothic-Regular" }
        { { "serif" italic           } "VL-PGothic-Regular" }
    } at ;

: ttf-path ( name -- string )
    "/usr/share/fonts/truetype/vlgothic/" swap ".ttf" 3append ;

これで普通に日本語が表示されるようになった。

そういえば Emacs 上での run-factor でも UTF-8 でなら普通に日本語が通るようになってる。

( scratchpad ) "あいう" reverse .
"ういあ"
( scratchpad ) "あいう" length .
3