textWidth in processing.js
in
Processing with Other Languages
•
1 year ago
Does anyone have a working example of the textWidth() function. It seems to return 0 for me in all my tests. An example below...
cheers, -DH
- /* @pjs font="Batang.ttf"; */
- void setup()
- {
- size(200,200);
- noLoop();
- textFont(createFont("Batang",32));
- }
- void draw()
- {
- background(255);
- String t = "test";
- float tw = textWidth(t);
- fill(0);
- text(t, 50, 50);
- text("tw="+tw, 50, 90);
- }
1