textAscent()
例子
float base = height * 0.75;
float scalar = 0.8; // Different for each font
textSize(32); // Set initial text size
float a = textAscent() * scalar; // Calc ascent
line(0, base-a, width, base-a);
text(“dp”, 0, base); // Draw text on baseline
textSize(64); // Increase text size
a = textAscent() * scalar; // Recalc ascent
line(40, base-a, width, base-a);
text(“dp”, 40, base); // Draw text on baseline
描述
返回当前字体在当前大小下的上行间距。这条信息对于检测字体在基线之上的高度十分有用。例如,将textAscent() 和 textDescent() 相加会得到这一行的总高度。
语法
textAscent()
返回值类型
float
相关
textDescent()
- 本文固定链接: http://iprocessing.cn/2017/07/15/textascent文本上行间距/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表