NEW Adafruit_mfGFX multifont library


I think for most people, the most useful thing would be storing fonts on an SD card and selectively loading whatever is needed. I say most useful because that is the most common large storage device that people pair with these sort of displays, for 24-bit images and so forth.

In the end I think the fonts aren’t too crazy in size that I can’t deal with them. I know that my total sketch size at the moment is 83kb out of 262kb or so that are available, and I imagine my non-font sketch size is no more than 15-30kb. But i wouldn’t have the space to not selectively ignore characters I don’t need in my fonts. For that reason it would be convenient if the mfGFX library had a way to include fonts where I didn’t have to have a continuous series of characters. Meaning, rather than having to include 0-9, if I only needed 0, 3, 4, and 9, only including those characters. As I understand it right now I have to include a full set [or else make 3 fonts, one for 0, one for 3-4, and one for 9]


@Tomek I’ll post your image here for others to see.

Also I’m pretty dam sure you can choose which fonts you want to include in the custom font library as you create the fonts using the DotFactory software. I haven’t created a custom font lately so I don’t remember the process exactly but I also think you can just delete the text or numbers that you know you will not be using in the FONT library that Dot Factory creates for you also. So I’m pretty sure there are 2 ways to do it.


@Tomek, in order to make a font without “filler” character you need to:

  1. Using DotFactory, set the configuration as in the original instructions but also, under “Comments”, tick the “Variable Name” and “Char Descriptor” options. This will allow you to better identify each character in the generated data.

  2. Remove all the characters you don’t want from both the font bitmap and font descriptor tables leaving you with only the characters you want for that font.

  3. Copy the font bitmap and font descriptor tables to your font.cpp file. Modify the START and STOP character at the start of the font bitmap table to be 00 and whatever the number of character you have (eg. in your example, you would have 0,3,4,9 making 4 chars so the start and stop are 0 and 3).

  4. Now the trick is that the fonts are no longer ASCII indexed (eg. zero is no longer char position 48). So in your code you will need to map the ascii value to the correct font index. In your example ascii zero is now font index zero, ascii 3 is now font index 2, etc. You could do this with a lookup table or some logic, your choice.

Hope that helps! :smile:


Hallo RWB

i test your Code with a Arduino Mini Pro with SRAM 23K256 and a Sharp Mem Display 400x240. I must edit your Libs to run (Spark core -> Arduino IDE). but something is wrong.
Error not enough Memory ? Can anyone Help.

Der Sketch verwendet 24.218 Bytes (78%) des Programmspeicherplatzes. Das Maximum sind 30.720 Bytes.
Globale Variablen verwenden 12.088 Bytes (590%) des dynamischen Speichers, -10.040 Bytes für lokale Variablen verbleiben. Das Maximum sind 2.048 Bytes.

modified arduino


@LarryXXL, is the SRAM connected via SPI? The SPI wiring and timing is critical and may need tweaking for the Arduino. You need to run the version of the library designed to use the SRAM and not the internal RAM. This is what is causing your error. Which library have you been using?


Im use the FRAM Lib with modifications. The SRAM is identical. You can see all files in the Rar.


@peekay123 I’m excited to see the new Photon board design with its much improved memory capacity. I ordered up a few of them. This will certainly make working with Sharp Memory LCD’s much easier.


@LarryXXL, I don’t see in the code where you link in the SpiRAM library?


@peekay123 Hallo . I must modified all Librarys from the SharpMemFRAM to run the Compiler without error.
than i use the modified Fram.h .cpp with the 23K256 SPI Chip.
Hardware is

  • Arduino Pro mini 3.3v/8Mhz
  • Sharp Mem Display 2.7 400x240
  • 23K256 Microship SPI SRam
    Arduino IDE 1.5.8

the compiler Message is now “not enough Memory 12088Bytes”.
why i become this Messages ?


@LarryXXL, all the font tables in font.cpp need to be cast as PROGMEM like this for example:

const uint8_t timesNewRoman_8ptBitmaps[] PROGMEM =

This is why you get the error. Also, it is quite possible that the revBits() function code may not work on the Arduino. The function is meant to reverse the bit order of the byte passed to it.


I’m having an issue using the custom font to print out correctly. Strangely if all the letter are capital they print out fine, but the lowercase letter all print off by one character so an “o” will print a “p” and a 'l" will print a “m”. I’m using an the adafruit ssd1306 library too. Every thing works fine if i use the default ARIAL_8. I also get the same results when I copy the ARIAL_8 from the fonts.cpp file to the test font section.

Do you have any ideas what could be going on?



Never mind, just found the issue. I have to delete all the // a, //b in the descriptors


Hey is there a spark library for the RA8875? I’ve been looking around and can’t seem to find anything.


Sorry! I can’t remember. Perhaps you should try my code up higher above, as it is tested working on a Teensy 3.1, which insofar as a being a 32-bit processor has some coding convention similarities.

Somehow I have some expectation that someone somewhere has used the RA8875 on the spark core. It’s a very popular chip since adafruit has some nice boards for it.

I still haven’t used the spark core in any project, I just found your community when looking for multiple font GFX support. Also, I feel guilty but haven’t been able to explore the use of this library with other processors besides the teensy. Behind on many of my projects, classic problem.


@screamingcities, the Adafruit RA8875 library looks very easy to port. The only problem with this device is:

Please note! The RA8875 does not tri-state the MISO pin, it should not share that pin with any other SPI device (including an SD card reader) without the use of a 74HC125 or similar.

The RA8875 is not compatible with the mfGFX library since it has its own built-in fonts and supports external font ROMs. It also supports 255 8x16 downloadable user-defined fonts/symbols in CGRAM. This allows symbols and/or characters to be downloaded to the display and then used as a font on the screen. The Adafruit library would have to be modified to support this. Also, the CGRAM is not persistent so the fonts/symbols need to be loaded every time the display is powered. That means a 4080 byte flash requirement on the Core to store all 255 8x16 cells.

The GFX and mfGFX libraries are designed for “dumb” controllers where the processor draws the fonts and graphics. In theory, an extra set of functions could be written to support mfGFX fonts on the RA8875, bypassing the display’s “intelligent” controller and simply drawing them as pixels. :smile:



Many thanks to all for your contribution. I doscovered the mfGFX library, and I think it is a great work. I´m tryinf to create my own font, without luck. I used The Dot Factory program, but when generating, the descriptor seems to be wrong. I attach a screen capture. Almost all letters have (0,0,0), which seems to be wrong, because in the screen I can only see the ones witout “0”.

The parameters I used with The Dot Factory, were the ones in the Readme.pdf of the library.

Could someone help me to solve it? Or recommend another software to make the fonts usable with mfGFX?



@pmsanz, in the section “Enter text to generate here”, it should have the font characters listed there. You need to hit the “+” next to the “Inset text All” selection above that! Try and and get back to me :smile:


Solved! That was my problem: I thought that selecting “All” automagically catches everything. Now I know I have to press “+”.

Many, many thanks again.


Does anyone know how to define the space between characters when they print? Right now it seems to be set at 1 pixel? Can this be changed to 2 pixels? With some custom fonts the characters seem to run together with only 1 pixel spacing.



@wesner0019, in the setFont() code, you fill find a variable called fontkern. It is set to 1 by default. You can change it on a per-font basis. Play with that and let me know how that goes. :smile: