Pfont ignores font weight

I'm attempting to load a font (Gotham) to use in my sketch and it seems to be ignoring the font weight. The font is an .otf font. Comparing with what I see in illustrator it seems all weights of the font display as "medium."

I've tried creating a .vlw in processing and I have tried using the createFont() method. Both produce the same results.

PFont myFont;

void setup(){
  background(255);
  fill(0);
  size(500, 200);
  String[] fontList = PFont.list();
  println(fontList);
  myFont = createFont("Gotham-ExtraLight", 32);
  textFont(myFont);

  text("The quick brown fox jumped over the lazy dog", 10,50);
}

Using Processing 2.2.1 on OSX Mavericks

Tagged:

Answers

  • Try textSize(32)

  • I think there is no way to specify font styles in Processing, except by using different fonts (different names), eg.:

    DejaVuSans-Bold.ttf
    DejaVuSans-BoldOblique.ttf
    DejaVuSans-ExtraLight.ttf
    DejaVuSans-Oblique.ttf
    DejaVuSans.ttf

  • @XYZZY tried that but nothing changed.

    @PhiLho I know I have to load in each font style individually. The problem is that processing seems to be ignoring the style I specify. For example if I were to load in DejaVuSans-Bold.ttf (or any of the other styles) it would display as DejaVuSans.ttf.

  • PFont font1, font2, font3;
    
    void setup()
    {
      size(900, 200);
      background(255);
      fill(0);
      String[] fontList = PFont.list();
      for (String f : fontList) { if (f.startsWith("Deja")) println(f); }
      font1 = createFont("DejaVu Sans", 32);
      font2 = createFont("DejaVu Sans Bold", 32);
      font3 = createFont("DejaVu Sans Oblique", 32);
    //  textSize(32);
      textFont(font1);
      text("The quick brown fox jumped over the lazy dog", 10, 50);
      textFont(font2);
      text("The quick brown fox jumped over the lazy dog", 10, 100);
      textFont(font3);
      text("The quick brown fox jumped over the lazy dog", 10, 150);
    }
    

    I see three different fonts.

  • edited July 2014

    I see three identical fonts. I note that DejaVu is not in the fontList and @PhiLho's code prints nothing to the console. Processing 2.2.1 on MacOS 10.9.4.

  • edited July 2014

    I saw the three fonts the same as well. I don't have DejaVu either, so I changed to Arial and it works fine. Everyones got Arial...

    PFont font1, font2, font3;
    
    void setup()
    {
      size(900, 200);
      background(255);
      fill(0);
      String[] fontList = PFont.list();
      for (String f : fontList) { if (f.startsWith("Arial")) println(f); }
      font1 = createFont("Arial", 32);
      font2 = createFont("Arial Bold", 32);
      font3 = createFont("Arial Italic", 32);
    //  textSize(32);
      textFont(font1);
      text("The quick brown fox jumped over the lazy dog", 10, 50);
      textFont(font2);
      text("The quick brown fox jumped over the lazy dog", 10, 100);
      textFont(font3);
      text("The quick brown fox jumped over the lazy dog", 10, 150);
    }
    

    I see your problem, @tysonanderson. You are trying to create a font with "Gotham-ExtraLight" (note hyphen). "Arial" is listed in the create font dialoge as "ArialMT" and "Arial Bold" is listed as "Arial-BoldMT". You just got to indicate the correct name/spelling.

  • Thanks for your help.

    I see 3 fonts as well so it seems to be working for DejaVu. It for some reason does not like Gotham. I switched my design to use Gill Sans since that seems to be working as well. I'd like to know why it doesn't work but for now I've come up with a workaround.

  • Added a note to the end of my last post while you were responding. I think that might be the cause. Maybe.

  • @XYZZY I wish that were the case. I've been copying the text directly from the PFont.list(); output so I'm certain the problem isn't a spelling error.

    I think the problem is something much more complex because even when I look at gotham in the create font dialog all the font weights are exactly the same in the preview.

  • Oh, okay. Well, good luck.

  • edited July 2014

    "I see three identical fonts. I note that DejaVu is not in the fontList"
    Well, it just means it uses the default font, then. That's why I have this commented out textSize(), so if I uncomment it and comment out the textFont() calls, I can see if it changes anything. If not, the font name is wrong (or not existing on the current system).

Sign In or Register to comment.