Running out of storage space

Hello
I'm trying to print some things on an LCD screen using ug8lib and I'm having major problems with the program storage space on the arduino.
Right now, I'm trying to print a few values as strings (which will be later changed to variables) but after writing a little bit of code I'm already at 99% of storage space used.
Can you please help me make it smaller?

#include <Arduino.h>
#include "U8glib.h"

U8GLIB_ST7920_128X64_1X u8g(6, 5, 4, 7);  

void setup() {


}

void loop() {  
    u8g.firstPage();
    do{

    u8g.setFont(u8g_font_fub25);
    u8g.drawStr(0, 27, "50");
    u8g.setFont(u8g_font_7x13B);
    u8g.drawStr(40, 25, "km/h");

    u8g.setFont(u8g_font_fub17);
    u8g.drawStr(0, 45, "1");
    u8g.drawStr(10, 45, ":");
    u8g.drawStr(17, 45, "20");

    u8g.setFont(u8g_font_helvB14);
    u8g.drawStr(0, 62, "1");
    u8g.drawStr(7, 62, ":");
    u8g.drawStr(12, 62, "20");
    u8g.drawStr(32, 62, "BEST");


  }
  
    while ( u8g.nextPage() ); {
    }
  
}

How much memory does each of those fonts take?

The fonts will use a lot of memory. Please consider to switch to u8g2. In U8g2 fonts are available in different sizes (with different number of glyphs included). Additionally fonts are compressed so that lesser space is required.

Oliver

How do I change font sizes in u8g2 without setting a new font?

You have to select a font, but you can choose a font which matches more closely your needs.

Oliver

From your example sketch, I am guessing that you only want numbers in 25 pixel font.
This makes a massive difference to the font size when you use U8g2.

Sketch uses 13182 bytes (40%) of program storage space. Maximum is 32256 bytes.
Global variables use 1477 bytes (72%) of dynamic memory, leaving 571 bytes for local variables. Maximum is 2048 bytes.

You will need to use the appropriate constructor for your hardware.
If you want to save SRAM memory, you can use a paged constructor.

#include <Arduino.h>

#include "U8g2lib.h"

//U8GLIB_ST7920_128X64_1X u8g(6, 5, 4, 7);
U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, A0, A1, A2, /* reset=*/ U8X8_PIN_NONE); //Brown Shield

void setup() {
    u8g2.begin();    //.kbv 

}

void loop() {
    u8g2.firstPage();
    do {

        u8g2.setFont(u8g2_font_fub25_tn); //u8g_font_fub25);
        u8g2.drawStr(0, 27, "50");
        u8g2.setFont(u8g2_font_t0_22b_tr); //u8g_font_7x13B);
        u8g2.drawStr(40, 25, "km/h");

        u8g2.setFont(u8g2_font_fub17_tr); //u8g_font_fub17);
        u8g2.drawStr(0, 45, "1");
        u8g2.drawStr(10, 45, ":");
        u8g2.drawStr(17, 45, "20");

        u8g2.setFont(u8g2_font_helvB14_tr); //u8g_font_helvB14);
        u8g2.drawStr(0, 62, "1");
        u8g2.drawStr(7, 62, ":");
        u8g2.drawStr(12, 62, "20");
        u8g2.drawStr(32, 62, "BEST");


    }

    while ( u8g2.nextPage() ); {
    }

}

David.