We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I'm trying to display text with a changeable font, that is any font installed. I accomplished that quite easily w/ processing's default libraries, here's the code:
void setup() {
 size(900, 500);
     smooth();
      lastWidth = 900;
      if (frame != null) {
        surface.setResizable(true);
        background(255, 255, 255);
      }
  myFont = createFont(activeFont, activeFontSize); 
  fill(0, 0, 0); 
  textFont(myFont);
  textAlign(CENTER, CENTER);
  setGUI();
}
void draw() {
  if (firstDrawRun) { //sets GUI in the very beginning
    setGUI();
    setFunctionMenus();
    firstDrawRun = false;
  }
  if (activeFont != selectedFont) { //dropdown list changes font
    activeFont = selectedFont;
    myFont = createFont(activeFont, activeFontSize); 
    textFont(myFont); 
  }
  if (activeFontSize != fontSize) { //dropdown list changes font size
    activeFontSize = fontSize;
    myFont = createFont(activeFont, activeFontSize); 
    textFont(myFont); 
  }
...activeFont being a string w/ the font name, that is pulled out via:
String[] fontList = PFont.list();
void fonts(int n) { //list of installed fonts
  selectedFont = fontList[n]; 
  //System.out.println(selectedFont); 
}
But now I need to work w/ the text displayed using geomerative and I'm having trouble telling it what font to use. the default call is font = new RFont("name of font", "font size", ...);
But I want to take those fonts directly from what's installed on the system. I tried "C:/Windows/Fonts/"+activeFont+".ttf" but that didn't work either, and after checking C:/Windows/Fonts/ I am totally lost.
Anybody ever dealt w/ such issues? Thanks for any ideas!
Answers
The whole code is at https://github.com/suhaj/CODE