システムフォントを表示する

Filed in processing , メディアプログラミング演習II 0 comments

Processingはパソコンに入っているフォントは全て表示できますが、Processing用にフォーマットを変換しないといけないのが非常に面倒なところです。
単に変数の値を表示してみたいなど、簡単に文字を使いたい場合は、以下のような形で書くとシステムフォントを使ってくれます。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
PFont font;
// システムでフォントのリストを作成する
String[] fontList = PFont.list();
int a = 20;
 
size(100, 100);
background(255);
smooth();
 
//リストを出力する
println(fontList);
 
//フォントリストの中から選ぶ。MacでもWindowsでも入っているフォントが無難。
font = createFont("Arial", 24);
textFont(font);
 
fill(0);
text("word", 0, height/3);
text("a = " + a, 0, height/3*2);
Posted by noguchi   @   26 6月 2011 0 comments

0 Comments

Sorry, comments are closed.

Previous Post
«
Next Post
»
Stroom designed by Credit Cards In conjunction with Web Hosting Reseller , Dream Interpretation Guide , Best Website Hosting.