Processing中使用字体的通常用法是调用PApplet的createFont方法产生PFont.
PFont pFont = createFont("Courier", 18);
这里就出现了不能指定黑体和斜体属性,那么在Processing中使用黑体和斜体怎么办呢?
参看PFont的源码,可以看到PFont其实是基于java.awt的Font来实现的提供了实用awt的构造函数
public PFont(Font font, boolean smooth) {
this(font, smooth, null);
}
因为可以使用AWT的Font构造出Processing的PFont,我们可以这样来实现黑体和粗体
Font font = new Font("Courier",Font.Bold | Font.ITALIC,42);
myFont = new PFont(font,true);