Digole UART/I2C/SPI Display Library

Have you seen this:

http://www.georgegardner.info/arduino/easy-font-creation-for-led-matrix-from-truetype-system-fonts.html

I was looking at this project for ideas and I noticed he has a good explaination of the font format.

1 Like

@Bko Good find. There are some great tips in that article on Exporting fonts in GLCD format. Hopefully it helps @peekay123 out some

Sweet bko! I will absolutely look at that. Thanks!

@peekay123 I can also try the updated library on Arduinoā€™s I just need to know where to put the code needed to switch over to the newly added fonts.

I assume that you define the font you want to use at the top of the program code but Iā€™m not 100% sure. Once I know how Iā€™m supposed to pick which font I want to use Iā€™ll start testing it out on my side and see if I am getting the same results.

Really exited to see this working since it would allow me to make the screen look any way I could imagine it. I know how to make bitmap images and animations so the only thing left to figure out is how to use any font I have available on my computer. Iā€™m ready to put these Sharp Memory Displays to good use :smiley:

@RWB, using an arduino does not change anything. There are a few things to change to get things going:

  1. You need a demo program (application.cpp) so you can test your font
  2. You need to generate a font in "C" array format using font creator software. Then, you need to copy the resulting array into glcdfont.c. Look at the way the existing font array is setup in the file and use the same convention:
    const unsigned char yourfont[] PROGMEM = { arrary... };
  3. In font.h, you need to add a new font index and declaration

#define GFXFONT_GLCD 0
#define GFXFONT_GLCD_ASCII 1
#define GFXFONT_FONTNAME 2 - ADD AN INDEX FOR EACH NEW FONT

extern const unsigned char glcdFont;
extern const unsigned char glcdFont_ascii;
extern const unsigned char fontname; - ADD DECLARATION FOR EACH NEW FONT

Finally, in Adafruit_GFX.cpp, you need to add a bit of code:

Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
  WIDTH(w), HEIGHT(h)
{
  _width    = WIDTH;
  _height   = HEIGHT;
  rotation  = 0;
  cursor_y  = cursor_x    = 0;
  textsize  = 1;
  textcolor = textbgcolor = 0xFFFF;
  wrap      = true;
  //setFont(GFXFONT_GLCD_ASCII);  // THESE LINES SELECT THE DEFAULT FONT
  //setFont(GFXFONT_GLCD);
  setFont(GFXFONT_YOUFONT);
}

void Adafruit_GFX::setFont(uint8_t f) {
  font = f;
  switch(font) {
    case GFXFONT_GLCD:
      fontData = glcdFont;
      fontKern = 1;
      break;
    case GFXFONT_GLCD_ASCII:
      fontData = glcdFont_ascii;
      fontKern = 1;
      break;
    case GFXFONT_YOURFONT:    // ADD A CASE STATEMENT FOR EACH NEW FONT
      fontData = yourfont;
      fontKern = 1;
      break;
    default:
      font = GFXFONT_GLCD;
      fontData = glcdFont;
      fontKern = 1;
      break;
  }

And that should do it! If I can get a darn font working, I'll post everything on my github.

1 Like

@peekay123 Thank you very much! Iā€™ll give it a shot and report back.

@peekay123

I spent alittle bit today trying to get it up and working but I donā€™t have a good understanding of how I should rig up the code to get it all work together. Iā€™m short on time also with other work I have to going on but I really want to get this working.

I was trying to generate a GLCD font library by using http://www.mikroe.com/glcd-font-creator/

I was specifically trying to create a library out of the Agency FB Font in 11 Size. Iā€™m just getting confused on where to put the font width and height numbers so the new code knows how to correctly display the new larger font.

If you can get it working Iā€™ll give ya $200 and you pick out what you want and Iā€™ll have it mailed to you. I which I had more time to try to figure it out but I donā€™t right now.

I also emailed the guy who wrote that Font Article that @BKO posted to see if he might be able to help out.

@BDub @BDub1 You still around? Can you make any sense of this?

RWB, if I get this working you can donate the $200 to a charity. :wink:

1 Like

@RWB, so I got things working after realizing the code has major flaws! I even loaded your font but there are problems. Because the code assume fixed font sizes, the spacing on the fonts looks way to large. Normally, you would have per-character spacing data to do spacing properly but no such luck.

I found another (older) library for the Sharp Memory display that DOES uses font metrics. I may be able to adapt the code to the Adafruit_GFX library though it may take some time. Or I could simply port that library and use it instead. Your thoughts?

So very busy! Sorry buddy :smile: 12:30am time to sleep before I feel like crap again tomorrow for staying up til 1am last night.

@peekay123 Yea man you get this problem solved for me and I'll send the $200 where ever you want it to go :smiley:

So it works except for the font spacing? Or it has more issues than that?

Yea I'm all for what ever works. Would we be able to use multiple fonts with this other option? I have plenty of memory to work with so thats not a problem.

Yup, you could use TheDotFactory to port any TrueType font :smile:

@RWB, I think I figured out a way to easily adapt the Adafruit library with an extra table per font to do it. I will try and work on it today and get back to you. I will test with your desired font. :slight_smile:

@peekay123 Excellent!

@RWB, GOT IT WORKING!!! The original code was a mess and had to rewrite it. Before I post the code, can you tell me the following:

  • What is the resolution (pixels) of the display you are using
  • What fonts did you want to use. TTF fonts donā€™t always convert well to bitmaps. Larger point sizes seem better

I am testing on a 320x240 color LCD. I loaded Agency_FB 11point and it loses details at the 11pt size. :smile:

1 Like

@peekay123 Thatā€™s Awesome! Iā€™m excited!

The screen Iā€™m using is 400 x 240 pixels. The smaller Memory LCD Iā€™ll be using is 128 x128 Pixels if it matters.

Iā€™m not 100% sure which fonts I will want to us just yet, I planned on just testing the ones I like until I find something that looks good with that Iā€™m doing. The Agency FB is a good font though.

Do you think it will be easy to just download and convert different fonts at different sizes to test out or is it more complicated than that?

I have no idea what the 11pt font size would look like on this screen so I have no idea what size fonts Iā€™ll be wanting to use until I can test them out.

Keep up the good work over there! :rocket:

@RWB, the way the library works is you select the font to use. Then you can specify the size which essentially enlarges the font vertically and horizontally by the size. This is ok up to a point where it gets quite pixelated. The other problem is though AgencyFB looks good on a monitor, it doesnā€™t look so good when converted, especially on a lower resolution screen. On low res screen, smaller fonts look best, even when scaled a bit.

When I post the code, I will have a few fonts defined. Adding fonts is not too difficult but there are some tricks. I will post a how to soon as well.

@peekay123

So if I use the GLCD software to create a font that is sized 9x15 pixels will it display on the screen with the exact same pixel layout as seen in the GLCD font creator software screenshot below:

Or is it using a smaller sized font and then trying to expand up to the larger sizes? Kinda like how the stock Adafruit library increases font size by 1, 2, 3, ectā€¦ ?

I plan on just storing a small and a large font array so no up or down sizing needs to happen and the fonts look like they should.

Finding the font that looks just right will probably be a full days work but well worth it to get something that looks cool.

So this is based on the Adafruit GFX library? So many other people will be able to also follow along? If so Iā€™m sure many people will put this to use considering there are no other alternatives.

@RWB the GLCD software does not produce the correct files bot TheDotFactory does. However, it doesnā€™t allow you to edit the pixel. It only converts existing ttf fonts.

@peekay123

I checked out TheDotFactory and many people seem to like it. It hasnā€™t been updated in a few years but as long as it works who cares.

I like how it creates super slim font arrays and uses per character spacing.

Go Peekay Go!!!