Fonts for Adafruit SSD1306

Hi all

I'm working on a project with an Adafruit 128x64 display. My problem is that the default font is a little too small. Since size 2 is way too big, I have to change the font. Is there a slightly bigger font available, which I can also set the background colour (display.setTextColor(WHITE,BLACK);)? Unfortunately my search for the font hasn't been succsessful yet.

I'm using the Adafruit_GFX and the Adafruit_SSD1306 libraries.

Which is your main controller? Arduino or ESP? For ESP8266, you can use this library:

display.setFont(ArialMT_Plain_10);
display.setFont(ArialMT_Plain_16);
display.setFont(ArialMT_Plain_24);

My main controller is an Arduino Uno

U8g2_for_Adafruit_GFX has many fonts.

The background color option only works with a few of the Adafruit fonts. Not sure if anyone has taken the trouble to figure out how to encode other fonts to work with that, and it would not work on proportionally spaced fonts anyway.

So I tried to change to the U8g2 library. But unfortunately I'm having problems with the constructor. I can't get it to work.
One problem that I'm facing now (which could also have been solved with U8g2) is values that are not get printed correctly. In my code I read "Ramp" and "Speed". I think it has to do with overwriting numbers.

  //Ramp = (analogRead(RampVal));
  const int SMOOTH_FACTOR1 = 5;
  Ramp = (Ramp - (Ramp >> SMOOTH_FACTOR1)) +((analogRead(RampVal) * 2) >> SMOOTH_FACTOR1);

  if (Ramp != LastR) {
    myStepper.setRampLen(Ramp);
    display.setTextColor(WHITE, BLACK);
    display.setCursor(70, 50);
    display.print(Ramp);
    display.display();
    LastR = Ramp;
  }
  
  
  const int SMOOTH_FACTOR2 = 6;
  Speed = (Speed - (Speed >> SMOOTH_FACTOR2)) +((analogRead(SpeedVal) * 2) >> SMOOTH_FACTOR2);

  if (Speed != Last) {
    
    myStepper.setSpeed(Speed);
    display.setTextColor(WHITE, BLACK);
    display.setCursor(0, 50);
    display.println(Speed);
    display.display();
    Last = Speed;
  }

Hi, with this tool https://rop.nl/truetype2gfx/, you can make a custom font, from any ttf font and use it with Adafruit_GFX library.
When you make your custom font, you have to save font header file in the Adafruit_GFX library - Fonts folder and include it in the code.

#include <Fonts/FreeMono20pt7b.h>

And set what font to use :

display.setFont(&Fonts/FreeMono20pt7b.h);

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.