Using a font

Hello,

I'm discovering the display of caracters on 128x64 OLED. I compiled a program using 24x40 font , now I have to replace py 16x16 font
I put BigFont.c in the right folder -till here this is ok :wink:
displaying a caracter is made calling this function

void drawCar(int sx, int sy, int num, uint8_t *font, int fw, int fh, int color) {
  byte row;
  for(int y=0; y<fh; y++) {
    for(int x=0; x<(fw/8); x++) {
      row = pgm_read_byte_near(font+x+y*(fw/8)+(fw/8)*fh*num);
      //macro that reads a byte of data stored in a specified address(PROGMEM area) 
      
      for(int i=0;i<8;i++) {
        if (bitRead(row, 7-i) == 1) display.drawPixel(sx+(x*8)+i, sy+y, color);
      }
    }
  }
}

but it is not displaying the numbers it used to do with the previous font .. what should I modify . I actually don't understand well how this works at the level of font.c content and calculation font+x+y*(fw/8)+(fw/8)fhnum

arthurie:
Hello,

I'm discovering the display of caracters on 128x64 OLED. I compiled a program using 24x40 font , now I have to replace py 16x16 font
I put BigFont.c in the right folder -till here this is ok :wink:
displaying a caracter is made calling this function

void drawCar(int sx, int sy, int num, uint8_t *font, int fw, int fh, int color) {

byte row;
 for(int y=0; y<fh; y++) {
   for(int x=0; x<(fw/8); x++) {
     row = pgm_read_byte_near(font+x+y*(fw/8)+(fw/8)fhnum);
     //macro that reads a byte of data stored in a specified address(PROGMEM area)
     
     for(int i=0;i<8;i++) {
       if (bitRead(row, 7-i) == 1) display.drawPixel(sx+(x*8)+i, sy+y, color);
     }
   }
 }
}




but it is not displaying the numbers it used to do with the previous font .. what should I modify . I actually don't understand well how this works at the level of font.c content and calculation font+x+y*(fw/8)+(fw/8)*fh*num



![](http://www.henningkarlsen.com/electronics/images/fonts/bigfont.png)

If your display is KS108 compatible, the data is displayed as follows (assuming an 8x8 pixel letter "P"):

Byte 0 1 2 3 4 5 6 7
-------------------------------------
Bit 0 0 0 0 0 0 0 0
** 1 1 1 1 1 1 1 1**
** 2 2 2 2 2 2 2 2**
** 3 3 3 3 3 3 3 3**
** 4 4 4 4 4 4 4 4**
** 5 5 5 5 5 5 5 5**
** 6 6 6 6 6 6 6 6**
** 7 7 7 7 7 7 7 7**
** . # # # # . . .**
** . # . . . # . .**
** . # . . . # . .**
** . # # # # . . .**
** . # . . . . . .**
** . # . . . . . .**
** . # . . . . . .**
** . # . . . . . .**
** 0x00,0xFF,0x09,0x09,0x09,0x06,0x00,0x00**

Knowing how the bits are laid out will help you understand the seemingly odd addressing that goes on to locate fonts. Also, you will see that if you digitize an existing font which runs left to right, it will display rotated by 90 degrees on the display.

Note that all screen fonts SHOULD be multiples of 8 pixels in size. For example, 8x8 or 8x16 or 16x24 or 16x32... this makes crossing "chip" boundaries (the left and right half of the display) easier.

By the way, take a look here: https://github.com/krupski/Noritake_VFD_GUU100

Check out the "fonts" subdirectory. There are a bunch of various sized bitmap fonts for a 128x64 display. Maybe they will be of some use to you. It's free GPL3 software, so help yourself.

Hope this helps.

sure it helps ! I didn't find any good tutorial on font use...
I'm still stuck in understanding how the font.c file is composed , and what exactly the code for reading is doing. Here the font used are bigger than 8x8 (the one used on the code is 24x40 , I'm using 16x16)