java - How to calculate text location x with processing.org? -


i having hard time understanding how calculate size of word in processing when there different font sizes.

all trying put suffix right after word "metric". enter image description here

does know how accomplish this?

//code

pfont f; pfont f2; void setup(){   size(600, 300);    f = createfont("segoeui-semibold-200", 100);   f2 = createfont("segoeui-semibold-200", 20);  }  string metric = "metric";  void draw(){   float sw = textwidth(metric); //how can use sw? fill(240); textfont(f); text(metric, 0, height-20);  fill(0); textfont(f2); text("sufix",300, height-20); //how can calculate x @ of word metric  } 

textwidth() consider last call font() or fontsize() calc width, better use after proper call fontsize, or font(font, size) or font(). in case considering last font declared, little one... also, called background() in draw, words not wrote on itself, prevent bad.

pfont f; pfont f2; void setup(){   size(600, 300);    f = createfont("segoeui-semibold-200", 100);   f2 = createfont("segoeui-semibold-200", 20);  }  string metric = "anystuff";  void draw(){    background(110);   fill(240); textfont(f); text(metric, 0, height-20); float sw = textwidth(metric); //after font set...  fill(0); textfont(f2); text("sufix",sw, height-20); //just use :)  } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -