Skip to content

Instantly share code, notes, and snippets.

@brendandawes
Last active June 6, 2016 12:44
Show Gist options
  • Save brendandawes/996fbcb709e8986613ae2662565e528c to your computer and use it in GitHub Desktop.
Save brendandawes/996fbcb709e8986613ae2662565e528c to your computer and use it in GitHub Desktop.
Processing:typeToImage
PGraphics typeToImage(String txt,PFont theFont, int fontSize){
PImage img;
ArrayList<PVector> vectors = new ArrayList();
PGraphics pg;
textFont(theFont);
textSize(fontSize);
textAlign(LEFT,TOP);
float w = textWidth(txt);
float h = fontSize;
pg = createGraphics(int(w),int(h),JAVA2D);
pg.beginDraw();
pg.smooth();
pg.noStroke();
pg.textFont(theFont);
pg.background(255);
pg.fill(0);
pg.textSize(fontSize);
pg.textAlign(LEFT,TOP);
pg.text(txt, 0, 0);
pg.endDraw();
return pg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment