pkourany / Adafruit_mfGFX_IDE

Multifont GFX library for IDE, adapted from Adafruit_GFX library
Other
11 stars 21 forks source link

Questions re: custom fonts #4

Open 5h44n opened 4 years ago

5h44n commented 4 years ago

Hello, I'm trying to create a small, custom 3x5 font and am having issues getting it to display correctly. I'm using a 16x32 LED matrix and Particle photon.

I only need a small subset of the 0x20 - 0x7F character set. I made custom bitmaps in an spreadsheet below: image

Below is my hard-coded bitmap and descriptor. Since I only need a few characters, I figured I can make the unused characters blank. (note: added comments in the bitmap for clarity, I remove them when compiling)

Can the bitmap have any start and end character or do I have define all the characters between 0x20 and 0x7F?

Thanks in advance and appreciate any insight you might have!

#ifdef TESTFONT
const uint8_t testBitmaps[] =
{
    0x20, 0x5B, // Start Character, End Character
    0x00,       //  ' '
    0x00,       //  '!'
    0x00,       //  '"'
    0x00,       //  '#'
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x3E, 0x22, 0x3E,
    0x3E,
    0x2E, 0x2A, 0x3A,
    0x2A, 0x2A, 0x3E,
    0x38, 0x08, 0x3E,
    0x3A, 0x2A, 0x2E,
    0x3E, 0x2A, 0x2E,
    0x20, 0x20, 0x3E,
    0x3E, 0x2A, 0x3E,
    0x38, 0x28, 0x3E,
    0x14,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x3E, 0x22, 0x1C,
    0x00,
    0x00,
    0x00,
    0x3E, 0x08, 0x3E,
    0x00,
    0x00,
    0x00,
    0x00,
    0x3E, 0x10, 0x3E,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x3A, 0x2A, 0x2E,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x38, 0x0E, 0x38,       //  'Y'
    0x00                //  'Z'
};

const FontDescriptor testDescriptors[] =
{
    {1, 5, 0},
    {1, 5, 1},
    {1, 5, 2},
    {1, 5, 3},
    {1, 5, 4},
    {1, 5, 5},
    {1, 5, 6},
    {1, 5, 7},
    {1, 5, 8},
    {1, 5, 9},
    {1, 5, 10},
    {1, 5, 11},
    {1, 5, 12},
    {1, 5, 13},
    {1, 5, 14},
    {1, 5, 15},
    {3, 5, 16},
    {1, 5, 19},
    {3, 5, 20},
    {3, 5, 23},
    {3, 5, 26},
    {3, 5, 29},
    {3, 5, 32},
    {3, 5, 35},
    {3, 5, 38},
    {3, 5, 41},
    {1, 5, 42},
    {1, 5, 43},
    {1, 5, 44},
    {1, 5, 45},
    {1, 5, 46},
    {1, 5, 47},
    {1, 5, 48},
    {1, 5, 49},
    {1, 5, 50},
    {1, 5, 51},
    {3, 5, 52},
    {1, 5, 55},
    {1, 5, 56},
    {1, 5, 57},
    {3, 5, 58},
    {1, 5, 61},
    {1, 5, 62},
    {1, 5, 63},
    {1, 5, 64},
    {3, 5, 65},
    {1, 5, 68},
    {1, 5, 69},
    {1, 5, 70},
    {1, 5, 71},
    {1, 5, 72},
    {3, 5, 73},
    {1, 5, 76},
    {1, 5, 77},
    {1, 5, 78},
    {1, 5, 79},
    {1, 5, 80},
    {3, 5, 81},
    {1, 5, 82}
};
#endif  //TESTFONT
5h44n commented 4 years ago

Whoops, realized that the bytes should be generated horizontally, not vertically. Apologies! Thanks also for your work on this library, it's been very helpful!

pkourany commented 4 years ago

@shanexavier313, have you resolved your font issues or do you still need help?

5h44n commented 4 years ago

Haven't had a chance to test it out yet but think I'm good, thanks! For anyone curious, custom bitmaps should be generated like so:

image

EDIT: it worked. Thank you!