font conundrum

edited March 2018 in Questions about Code

My sketch is built for both OSX and Windows, all my GUI fonts are "Consolas-Bold" in a few sizes (the very same font used for the Processing IDE). The TTF font is on both OSX and Windows machines I'm testing on (and I've added it to the sketch data folders to be sure) on OSX it all works fine but on Windows it will not use the Consolas-Bold font for my sketch... does anyone have any idea why the sketch will not use this font but the IDE does ?

I have tried the alternative method of creating .vlw fonts using the "Create Font.." option in Tools, this creates a set of fonts that works on both machines/OS ...But for some reason it shifts all my GUI text up by about 2-3 pixels, I presume the images this function creates has some kind of added offset/border ? This is not going to be much fun to correct throughout the whole GUI... :(

Tagged:

Answers

  • We should need to see your code or an mcve of it

    on OSX it all works fine but on Windows it will not use the Consolas-Bold font

    Which Win are you on, Win 10?

    Do you use createFont or loadFont?

  • Hi Chris,

    I'm using createFont() and it is on windows10.

    Example of the code:

    PFont btnFontStd;
    final int btn_textSize = 32; 
    
        void setup() {
          size(400, 400);
          //
          btnFontStd = createFont("Consolas-Bold", btn_textSize);
          //
          textFont(btnFontStd);
          textAlign(CENTER, CENTER);
          text("Font Test", width/2, height/2);
        }
    

    Cheers, mala

  • edited March 2018 Answer ✓

    Thanks.

    .... this creates a set of fonts that works on both machines/OS ...But for some reason it shifts all my GUI text up by about 2-3 pixels

    Question:

    just guessing here

    Would it help to use textAlign(CENTER, BASELINE); ?

    BASELINE is the default

    Chrisir

    PFont btnFontStd;
    final int btn_textSize = 32; 
    
    void setup() {
      size(400, 400);
      //
      btnFontStd = createFont("Consolas-Bold", btn_textSize);
      //
      textFont(btnFontStd);
      textAlign(CENTER, CENTER);
      text("Font Test", width/2, height/2);
    
      textAlign(CENTER, BASELINE);
      text("Font Test", width/2, height/2);
    }
    
  • Hi Chris.... sorry for rather slow reply, that will help tahnk you. mala

Sign In or Register to comment.