textFont()
例子
PFont mono;
// The font “andalemo.ttf” must be located in the
// current sketch’s “data” directory to load successfully
mono = loadFont(“andalemo.ttf”, 32);
background(0);
textFont(mono);
text(“word”, 12, 60);
描述
设置text() 函数将要显示的文本的字体。字体在使用之前必须先通过createFont() 函数创建或者通过loadFont() 函数载入。通过textFont() 函数设置的字体将会在text() 函数后面的所有函数中使用。如果字体大小的参数没有确定的话,字体的大小会默认为原始大小(在使用create font工具时设置的字体大小)并且会重载在textFont() 或textSize() 之前的任何函数。
当字体是通过图像纹理渲染的时候(在这种情况下是通过P2D或P3D渲染引擎和loadFont() 函数以及.vlw文件渲染的),你应该创建大小为最常用大小的字体。在不确定尺寸参数的情况下使用textFont() 函数会产生最干净的文本。
语法
textFont(which)
textFont(which, size)
参数
which PFont: 属于PFont类的变量
size 浮点数:以像素为单位的字符大小
返回值
void
相关
createFont()
loadFont()
PFont
text()
textSize()
- 本文固定链接: http://iprocessing.cn/2017/07/15/textfont文本字体/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表