A small program to display the font

Just wrote this, for people who want a quick look at the font included in glcdfont.c. It writes as much as it can fit on the screen, delays for 4 seconds, then draws the rest, delays for 4 more seconds, and repeats.

All you need are arduboy.cpp, arduboy.h, and glcdfont.c in the same directory.


#include <SPI.h>
#include "arduboy.h"

Arduboy display;

void setup()
{
  SPI.begin();
  display.start();
  display.setTextSize(1);
  display.setTextWrap(1);
}

void loop() {
  display.clearDisplay();
  display.setCursor(0, 0);
  for(byte x=0; x<10; x++) {
    display.write(x);
  }
  //skip newline character
  for(byte x=11; x<170; x++) {
    display.write(x);
  }
  
  display.display();
  delay(4000);
  
  display.clearDisplay();
  display.setCursor(0, 0);
  for(byte x=170; x<255; x++) {
    display.write(x);
  }
  
  display.display();
  delay(4000); 
}

2 Likes

Snap, please? :slight_smile:

Is this based on the font from https://github.com/Arduboy/Arduboy/blob/master/glcdfont.c …?

If so, there are a few problems. First, the font is described as 5x7. It’s not.

Second, it appears to be missing a character.

Here is my decode of the Arduboy font. I think this is right, although since I don’t have the tool chain, or a dev kit or an emulator, I had to sort of wing it. But I did NOT have to tweak it - this fell right out. (I also don’t have github account, so no good way to push this back up).

First, on this panel, I have highlighted background cells of 5x8. Notice that some characters fill the cells all the way out, with some very important pieces. The lowercase Y descender goes all the way down.

I suspect this is just a typo in the file, and it should actually be described as a 5x8.

Now, here is the Windows Terminal font, which appears to use the same mapping of codes to glyphs.

If we compare the two sets, all appears good until character 0xB2 in the Arduboy font, which should be a densely filled rectangle. That’s missing, and all subsequent characters are offset by one.

This could be a real stumbling block for someone trying to use those line drawing graphics up in the Bx, Cx, Dx range. Or the Greek. Or the math.

3 Likes

I plan to write a font decoded/encoder when I have time… so you can have the bitmaps commented out in the hex file an edit them and then just “rebuild” the file to update all the encoded values. IE, font editing in your text editor. I’m a big fan of toolchains to aid development (like the image converter I’ve already published).

Off by one is an inherited problem: https://github.com/adafruit/Adafruit-GFX-Library/issues/22
… This is one reason I’d like more transparency over the source code and better compatibility with the original libraries; it makes applying fixes easier!

Would be nice if you could elaborate on what you mean by “compatibility”… I’d hate to think we can’t have a nice API because a few original authors decided not to build a nice API long ago. I want the best API possible to help devs, not necessarily the most compatible. Obviously it’s quite possible for someone to use SSD1306 if they want instead of our own library.

If we want to support people using these other libraries we could make a very small “bootup” library and then let people choose whatever they want - without feeling beholden to doing things exactly the same way they’d always been done.

IE, there is no need to us to be a copy of another library. Either we’re our own thing, or we should just refer people to the other library itself. Now porting from one platform to another is a whole other discussion.

Started a new thread on this topic: What belongs in the core library?

Here is the todo list I started of things I’ve been working on but haven’t finished yet:

- physics
- sprites and masking
- voltage detection
- EEPROM management
- draw ops that don't require color as arg
- button management (frame units)
- button management (time units)
- music with tracks and sequences
- music with instruments and variable duty cycle
- brigtness set/edit/save
- sound on/off set/edit
- get repo added to Arduino official list
- power down USB to save more power
- ability to show/determine library version used to compile sketch (for later debugging)
- boot logo in core lib
- custom board file for Arduboy


UI

- menu
- alerts

And I’d love to discuss the best function names and arguments… here is what I’m doing now for menu in a game, but I think it can be improved:

int8_t menu(const char* const* choices, uint8_t count,
  uint8_t x, uint8_t y, uint8_t width, uint8_t height)

Which was fixed there …

Odd to call it 5x7, though.

I believe it’s called 5x7 because that’s what is considered the normal writable area, even though some letters dip into the gutter. In terms of how closely the letters should be packed together, they’re 6x8. That sixth column of pixels is blank to provide the spacing between characters, and the gutter is not considered to be used often enough that another horizontal line of pixels would be required for spacing.

Similarly, I’ve been looking into another font that’s 3x5, or 4x6 if you want to include the spacing to the right and below the characters.

I’ve have my ideas for a new font. I want a display area of 9 or 10px high, variable width. All the bitmaps would still be 8px high (for storage reasons) but you’d have a shift bit that allowed lower case letters to be drawn nicely and their Xx8 grid simply down shifted 2-3 pixels. I think the default font is simply atrocious and we could do so much better. My goal: Do so much better without using additional space. It’ll be interesting to see if that is possible.

So now it’s fixed Upstream in original GFX lib~

We already fixed it a while back in our own core lib (see github commit history). Our library now only knows the correct method.

Wow, good catch on the lower case y, never really saw that before! Nice detective work!