Improving fonts


#1

I have been working on the code to have bigger fonts, because according to me the fonts work only when they at maximum 8 bits wide.
The hack will be in file MatrixFont.cpp
at function getBitmapFontPixelAtXY, the line:

if (font->Bitmap[(location * font->Height) + y] & (0x80 >> x))

replace with

if (font->Bitmap[(location * font->Height * ((font->Width + 4) / 8)) + (y*((font->Width + 4) / 8)) + (x >> 3)] & (0x80 >> (x&7)))

This will take into account the width of the font, so if you have a font that is more than 8bits wide will work. At this time this work only for the backgroundLayer. I’m still working for the others layers.
I also add a font function to provide a Bitmap font directly on Layer_Background.h

void setBitmapFont(bitmap_font *newFont);

in Layer_Background_Impl.h add:

template <typename RGB, unsigned int optionFlags>
 void SMLayerBackground<RGB, optionFlags>::setBitmapFont(bitmap_font *newFont) {
     font = (bitmap_font *)newFont;
 }

So if you have your own font you could call usign the function like this:

backgroundLayer.setBitmapFont((bitmap_font *)&myOwnFont);

Example of a big font

// Created from bdf2c Version 3, (c) 2009, 2010 by Lutz Sammer
//  License AGPLv3: GNU Affero General Public License version 3

#include "MatrixFontCommon.h"

static const unsigned char __calibri21x28b_bitmap__[] = {
//  48 $30 '0030'
//  width 22, bbx 2, bby 0, bbw 19, bbh 28
  _______X,XXXXXXX_,________,
  ______XX,XXXXXXXX,X_______,
  _____XXX,XXXXXXXX,XX______,
  ____XXXX,X_____XX,XXX_____,
  ___XXXX_,_______X,XXX_____,
  ___XXXX_,________,XXXX____,
  ___XXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXX___,________,_XXXX___,
  __XXXX__,________,_XXXX___,
  __XXXX__,________,_XXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  ___XXXX_,________,XXXX____,
  ___XXXX_,_______X,XXX_____,
  ___XXXXX,______XX,XXX_____,
  ____XXXX,XXXXXXXX,XX______,
  _____XXX,XXXXXXXX,X_______,
  _______X,XXXXXXX_,________,
//  49 $31 '0031'
//  width 22, bbx 4, bby 0, bbw 16, bbh 28
  ________,__XXXX__,________,
  ________,_XXXXX__,________,
  _______X,XXXXXX__,________,
  ______XX,XXXXXX__,________,
  ____XXXX,X_XXXX__,________,
  ____XXXX,__XXXX__,________,
  ____XX__,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ____XXXX,XXXXXXXX,XXXX____,
  ____XXXX,XXXXXXXX,XXXX____,
  ____XXXX,XXXXXXXX,XXXX____,
//  50 $32 '0032'
//  width 22, bbx 2, bby 0, bbw 18, bbh 28
  _______X,XXXXXX__,________,
  ____XXXX,XXXXXXXX,________,
  ___XXXXX,XXXXXXXX,X_______,
  ___XXXX_,____XXXX,XX______,
  ___XX___,_____XXX,XX______,
  ________,______XX,XX______,
  ________,______XX,XXX_____,
  ________,______XX,XXX_____,
  ________,______XX,XXX_____,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,____XXXX,________,
  ________,___XXXX_,________,
  ________,__XXXXX_,________,
  ________,_XXXXX__,________,
  ________,_XXXX___,________,
  ________,XXXX____,________,
  _______X,XXX_____,________,
  ______XX,XX______,________,
  _____XXX,X_______,________,
  ____XXXX,________,________,
  ___XXXX_,________,________,
  __XXXXXX,XXXXXXXX,XXXX____,
  __XXXXXX,XXXXXXXX,XXXX____,
  ___XXXXX,XXXXXXXX,XXXX____,
//  51 $33 '0033'
//  width 22, bbx 2, bby 0, bbw 18, bbh 28
  ______XX,XXXXXX__,________,
  ____XXXX,XXXXXXXX,________,
  ___XXXXX,XXXXXXXX,X_______,
  ___XXXX_,____XXXX,XX______,
  ___XX___,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,_____XXX,X_______,
  ________,____XXXX,X_______,
  _____XXX,XXXXXXX_,________,
  _____XXX,XXXXX___,________,
  _____XXX,XXXXXXXX,________,
  ________,___XXXXX,XX______,
  ________,_____XXX,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXXX____,
  ________,_______X,XXXX____,
  ________,_______X,XXXX____,
  ________,_______X,XXX_____,
  __X_____,______XX,XXX_____,
  __XXXX__,_____XXX,XX______,
  __XXXXXX,XXXXXXXX,XX______,
  ___XXXXX,XXXXXXXX,X_______,
  _____XXX,XXXXXXX_,________,
//  52 $34 '0034'
//  width 22, bbx 1, bby 0, bbw 20, bbh 28
  ________,____XXXX,X_______,
  ________,___XXXXX,X_______,
  ________,___XXXXX,X_______,
  ________,__XXXXXX,X_______,
  ________,_XXXXXXX,X_______,
  ________,_XXX_XXX,X_______,
  ________,XXXX_XXX,X_______,
  ________,XXX__XXX,X_______,
  _______X,XX___XXX,X_______,
  ______XX,XX___XXX,X_______,
  ______XX,X____XXX,X_______,
  _____XXX,X____XXX,X_______,
  _____XXX,_____XXX,X_______,
  ____XXX_,_____XXX,X_______,
  ___XXXX_,_____XXX,X_______,
  ___XXX__,_____XXX,X_______,
  __XXXX__,_____XXX,X_______,
  __XXX___,_____XXX,X_______,
  _XXX____,_____XXX,X_______,
  _XXXXXXX,XXXXXXXX,XXXXX___,
  _XXXXXXX,XXXXXXXX,XXXXX___,
  __XXXXXX,XXXXXXXX,XXXX____,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,______XX,X_______,
//  53 $35 '0035'
//  width 22, bbx 2, bby 0, bbw 18, bbh 28
  ____XXXX,XXXXXXXX,XX______,
  ____XXXX,XXXXXXXX,XX______,
  ____XXXX,XXXXXXXX,XX______,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXXX,XXXXXX__,________,
  ____XXXX,XXXXXXXX,________,
  ____XXXX,XXXXXXXX,XX______,
  ________,____XXXX,XX______,
  ________,______XX,XXX_____,
  ________,_______X,XXX_____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XXX_____,
  __XXX___,_____XXX,XX______,
  __XXXXXX,XXXXXXXX,X_______,
  __XXXXXX,XXXXXXXX,________,
  ____XXXX,XXXXXX__,________,
//  54 $36 '0036'
//  width 22, bbx 2, bby 0, bbw 19, bbh 28
  ________,__XXXXXX,XX______,
  ________,XXXXXXXX,XXX_____,
  ______XX,XXXXXXXX,XXX_____,
  _____XXX,XX______,__X_____,
  _____XXX,X_______,________,
  ____XXXX,________,________,
  ____XXX_,________,________,
  ___XXXX_,________,________,
  ___XXXX_,________,________,
  ___XXX__,________,________,
  ___XXX__,________,________,
  __XXXX__,_XXXXXXX,________,
  __XXXXXX,XXXXXXXX,XX______,
  __XXXXXX,XXXXXXXX,XXX_____,
  __XXXXXX,_______X,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,_XXXX___,
  ___XXX__,________,_XXXX___,
  ___XXX__,________,_XXX____,
  ___XXXX_,________,_XXX____,
  ___XXXX_,________,XXXX____,
  ___XXXXX,________,XXXX____,
  ____XXXX,_______X,XXX_____,
  _____XXX,XXXXXXXX,XX______,
  _____XXX,XXXXXXXX,X_______,
  _______X,XXXXXXXX,________,
//  55 $37 '0037'
//  width 22, bbx 2, bby 0, bbw 18, bbh 28
  __XXXXXX,XXXXXXXX,XXXX____,
  __XXXXXX,XXXXXXXX,XXXX____,
  __XXXXXX,XXXXXXXX,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,____XXXX,________,
  ________,____XXXX,________,
  ________,___XXXX_,________,
  ________,___XXXX_,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,_XXXX___,________,
  ________,_XXXX___,________,
  ________,XXXX____,________,
  ________,XXXX____,________,
  _______X,XXX_____,________,
  _______X,XXX_____,________,
  ______XX,XXX_____,________,
  ______XX,XX______,________,
  ______XX,XX______,________,
//  56 $38 '0038'
//  width 22, bbx 2, bby 0, bbw 18, bbh 28
  _______X,XXXXXXXX,________,
  _____XXX,XXXXXXXX,X_______,
  ____XXXX,XXXXXXXX,XX______,
  ___XXXXX,______XX,XXX_____,
  ___XXXX_,_______X,XXX_____,
  ___XXXX_,________,XXX_____,
  ___XXX__,________,XXXX____,
  ___XXX__,________,XXX_____,
  ___XXXX_,_______X,XXX_____,
  ___XXXXX,_______X,XXX_____,
  ____XXXX,X_____XX,XX______,
  _____XXX,XX__XXXX,X_______,
  ______XX,XXXXXXXX,________,
  _______X,XXXXXX__,________,
  _______X,XXXXXXXX,________,
  _____XXX,XX_XXXXX,XX______,
  ____XXXX,X____XXX,XXX_____,
  ___XXXX_,_______X,XXX_____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,XXXX____,
  __XXXXX_,_______X,XXXX____,
  ___XXXXX,XXXXXXXX,XXX_____,
  ____XXXX,XXXXXXXX,XX______,
  ______XX,XXXXXXXX,________,
//  57 $39 '0039'
//  width 22, bbx 2, bby 0, bbw 18, bbh 28
  _______X,XXXXXXX_,________,
  _____XXX,XXXXXXXX,X_______,
  ____XXXX,XXXXXXXX,X_______,
  ___XXXXX,______XX,XX______,
  ___XXXX_,_______X,XXX_____,
  __XXXX__,_______X,XXX_____,
  __XXXX__,________,XXX_____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  ___XXXX_,_______X,XXXX____,
  ___XXXXX,XXXXXXXX,XXXX____,
  ____XXXX,XXXXXXXX,XXXX____,
  ______XX,XXXXXX__,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ___X____,____XXXX,X_______,
  ___XXXXX,XXXXXXXX,________,
  ___XXXXX,XXXXXXX_,________,
  ___XXXXX,XXXXX___,________,
};

  /// character width for each encoding
static const unsigned char __calibri21x28b_widths__[] = {
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
  22,
};

  /// character encoding for each index entry
static const unsigned short __calibri21x28b_index__[] = {
  48,
  49,
  50,
  51,
  52,
  53,
  54,
  55,
  56,
  57,
};

  /// bitmap font structure
const struct bitmap_font calibri21x28b = {
  .Width = 21, .Height = 28,
  .Chars = 10,
  .Widths = __calibri21x28b_widths__,
  .Index = __calibri21x28b_index__,
  .Bitmap = __calibri21x28b_bitmap__,
};

To use the font the call will be

backgroundLayer.setBitmapFont((bitmap_font *)&calibri21x28b);

Finally this is the result on 4 pannels, 32x16, total => 64x32:


Well thats all at this time, thanks again for the code.
Best regards from Chile
Álvaro Monares G.


#2

Great work @amonares! I’ll make sure this gets in the next major release of the SmartMatrix Library. If you can do a Pull Request on Github for the changes that would be best, but if not, I’ll just take your changes from here and add them to the library.

I linked to this post from Github Issues: https://github.com/pixelmatix/SmartMatrix/issues/30


#3

Louis, I will do a Pull Request, after I improve the scroll font and do a lot of test :grinning:
But so far I have do bigger fonts in backgroundLayer and in scrollLayer, the idea now is to do test that include different font width, top offset (positive/negative) and left offset (positive/negative).

Best regards
Álvaro Monares G.


#4

Hi there.

I have tried to implement this in my library but I can’t seem to get it to work. Do you have a pull request for this yet?

Thanks!


#5

Hi,

I understand that this is an old topic, but is there any other way to increase the font size? I also cannot seem to get this to work.

Thank you!


#6

I made it work by following the instructions:

1

I’ve replaced the line from

if (font->Bitmap[(location * font->Height) + y] & (0x80 >> x))

to

if (font->Bitmap[(location * font->Height * ((font->Width + 4) / 8)) + (y*((font->Width + 4) / 8)) + (x >> 3)] & (0x80 >> (x&7)))

2

I’ve added void setBitmapFont(bitmap_font *newFont); to Layer_Background.h

3

Added

template <typename RGB, unsigned int optionFlags>
 void SMLayerBackground<RGB, optionFlags>::setBitmapFont(bitmap_font *newFont) {
     font = (bitmap_font *)newFont;
 }

to Layer_Background_Impl.h

4

I’ve made a calibri21x28b.c file inside src/ and copied all of the example font.

5

I’ve added #include <calibri21x28b.c> to my code.

6

I’ve called it using backgroundLayer.setBitmapFont((bitmap_font *)&calibri21x28b);

And it works just fine for now. I will test it more.


#8

Hi Thanks @GeorgeFlorian for this write up on changing fonts. It worked for me also. But i need to display string.

@amonares is there a c file of calibri with characters also included ?


#9

@karakbot

These settings will enable you a Background Layer and a Scrolling layer.

SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);

Both have the possibility to print.

For BackgroundLayer you will want to use:

drawString(int16_t x, int16_t y, const RGB& charColor, const char text[])

If you have a scrollingLayer you may use:

start(const char inputtext[], int numScrolls)

Examples:

String IP = WiFi.localIP().toString();
backgroundLayer.drawString(0,1,CYAN,(char*)IP.c_str());

scrollingLayer.start("Error 1 - Restarting in 5 sec!",1);`

I ended up using @marcmerlin 's SmartMatrix_GFX. It gives you the possibility to use Adafruit_GFX’s methods and fonts.

And here is a piece of advice: look out for the color format if you decide to switch to SmartMatrix_GFX.


#10

@GeorgeFlorian Thanks for the walk through…Theoretically the calibri file doesnt have characters mapped right ? Or am i missing a file with characters mapped as well ?

I will definitely look into gfx library in a while, just need a quick fix for now for a demo.

Thanks in advance…


#11

@karakbot
You are right, the calibri21x28b.c file was made from @amonares original post.

Here is a smaller font: Font_calibri20x26.c file that I modified and used:

// Created from bdf2c Version 3, (c) 2009, 2010 by Lutz Sammer
//  License AGPLv3: GNU Affero General Public License version 3

#include "MatrixFontCommon.h"

static const unsigned char __calibri20x26_bitmap__[] = {
//  48 $30 '0030'
//  width 20, bbx 2, bby 0, bbw 18, bbh 26
  ________,XXXXXX__,________,
  _______X,XXXXXXX_,________,
  ______XX,XXXXXXXX,________,
  _____XXX,______XX,X_______,
  ____XXX_,_______X,XX______,
  ___XXX__,________,XXX_____,
  ___XXX__,________,XXX_____,
  __XXXX__,________,XXXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXX___,________,_XXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  ___XXX__,________,XXX_____,
  ____XXX_,_______X,XX______,
  _____XXX,______XX,X_______,
  ______XX,XXXXXXXX,________,
  _______X,XXXXXXX_,________,
  ________,XXXXXX__,________,
//  49 $31 '0031'
//  width 20, bbx 4, bby 0, bbw 16, bbh 26
  ________,__XXXX__,________,
  ________,_XXXXX__,________,
  _______X,XXXXXX__,________,
  ______XX,XXXXXX__,________,
  ____XXXX,X_XXXX__,________,
  ____XXXX,__XXXX__,________,
  ____XX__,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ____XXXX,XXXXXXXX,XXXX____,
  ____XXXX,XXXXXXXX,XXXX____,
  ____XXXX,XXXXXXXX,XXXX____,
//  50 $32 '0032'
//  width 20, bbx 3, bby 0, bbw 17, bbh 26
  ________,XXXXXXX_,________,
  _____XXX,XXXXXXXX,X_______,
  ____XXXX,XXXXXXXX,XX______,
  ____XXXX,_____XXX,XXX_____,
  ____XX__,______XX,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XX______,
  ________,_____XXX,X_______,
  ________,____XXXX,________,
  ________,___XXXX_,________,
  ________,__XXXX__,________,
  ________,_XXXX___,________,
  ________,XXXX____,________,
  _______X,XXX_____,________,
  ______XX,XX______,________,
  _____XXX,X_______,________,
  ____XXXX,________,________,
  ___XXXX_,________,________,
  ___XXXX_,________,________,
  ___XXXXX,XXXXXXXX,XXXX____,
  ___XXXXX,XXXXXXXX,XXXX____,
  ___XXXXX,XXXXXXXX,XXXX____,
//  51 $33 '0033'
//  width 20, bbx 2, bby 0, bbw 18, bbh 26
  ______XX,XXXXXX__,________,
  ____XXXX,XXXXXXXX,________,
  ___XXXXX,XXXXXXXX,X_______,
  ___XXXX_,____XXXX,XX______,
  ___XX___,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,_____XXX,X_______,
  ________,____XXXX,X_______,
  _______X,XXXXXXX_,________,
  _______X,XXXXX___,________,
  _______X,XXXXXXXX,________,
  ________,___XXXXX,XX______,
  ________,_____XXX,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  __X_____,______XX,XXX_____,
  __XXXX__,_____XXX,XXX_____,
  __XXXXXX,XXXXXXXX,XX______,
  ___XXXXX,XXXXXXXX,X_______,
  _____XXX,XXXXXXX_,________,
//  52 $34 '0034'
//  width 20, bbx 1, bby 0, bbw 20, bbh 26
  ________,____XXXX,X_______,
  ________,___XXXXX,X_______,
  ________,__XXXXXX,X_______,
  ________,_XXXXXXX,X_______,
  ________,_XXX_XXX,X_______,
  ________,XXXX_XXX,X_______,
  ________,XXX__XXX,X_______,
  _______X,XX___XXX,X_______,
  ______XX,XX___XXX,X_______,
  ______XX,X____XXX,X_______,
  _____XXX,X____XXX,X_______,
  _____XXX,_____XXX,X_______,
  ____XXX_,_____XXX,X_______,
  ___XXXX_,_____XXX,X_______,
  ___XXX__,_____XXX,X_______,
  __XXXX__,_____XXX,X_______,
  __XXX___,_____XXX,X_______,
  _XXX____,_____XXX,X_______,
  _XXXXXXX,XXXXXXXX,XXXX____,
  _XXXXXXX,XXXXXXXX,XXXX____,
  __XXXXXX,XXXXXXXX,XXXX____,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
  ________,_____XXX,X_______,
//  53 $35 '0035'
//  width 20, bbx 2, bby 0, bbw 18, bbh 26
  ____XXXX,XXXXXXXX,XX______,
  ____XXXX,XXXXXXXX,XX______,
  ____XXXX,XXXXXXXX,XX______,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXX_,________,________,
  ____XXXX,XXXXXX__,________,
  ____XXXX,XXXXXXXX,________,
  ____XXXX,XXXXXXXX,XX______,
  ________,____XXXX,XX______,
  ________,______XX,XXX_____,
  ________,_______X,XXX_____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XXX_____,
  __XXX___,_____XXX,XX______,
  __XXXXXX,XXXXXXXX,X_______,
  __XXXXXX,XXXXXXXX,________,
  ____XXXX,XXXXXX__,________,
//  54 $36 '0036'
//  width 20, bbx 2, bby 0, bbw 19, bbh 26
  ________,__XXXXXX,XX______,
  ________,XXXXXXXX,XXX_____,
  ______XX,XXXXXXXX,XXX_____,
  _____XXX,XX______,__X_____,
  _____XXX,X_______,________,
  ____XXXX,________,________,
  ____XXX_,________,________,
  ___XXXX_,________,________,
  __XXXXX_,________,________,
  __XXXX__,________,________,
  __XXXX__,________,________,
  __XXXX__,_XXXXXXX,________,
  __XXXXXX,XXXXXXXX,XX______,
  __XXXXXX,XXXXXXXX,XXX_____,
  __XXXXXX,_______X,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,_XXX____,
  __XXXXX_,________,_XXX____,
  __XXXXX_,________,XXXX____,
  ___XXXXX,________,XXXX____,
  ____XXXX,_______X,XXX_____,
  _____XXX,XXXXXXXX,XX______,
  ______XX,XXXXXXXX,X_______,
  _______X,XXXXXXXX,________,
//  55 $37 '0037'
//  width 20, bbx 2, bby 0, bbw 18, bbh 26
  __XXXXXX,XXXXXXXX,XXXX____,
  __XXXXXX,XXXXXXXX,XXXX____,
  __XXXXXX,XXXXXXXX,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,_______X,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ________,_____XXX,X_______,
  ________,____XXXX,________,
  ________,____XXXX,________,
  ________,___XXXX_,________,
  ________,___XXXX_,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,__XXXX__,________,
  ________,_XXXX___,________,
  ________,_XXXX___,________,
  ________,XXXX____,________,
  ________,XXXX____,________,
  _______X,XXX_____,________,
  _______X,XXX_____,________,
  ______XX,XXX_____,________,
  ______XX,XX______,________,
  ______XX,XX______,________,
//  56 $38 '0038'
//  width 20, bbx 2, bby 0, bbw 18, bbh 26
  _______X,XXXXXXXX,________,
  _____XXX,XXXXXXXX,X_______,
  ____XXXX,XXXXXXXX,XX______,
  ___XXXXX,______XX,XXX_____,
  ___XXXX_,_______X,XXX_____,
  ___XXXX_,________,XXX_____,
  ___XXX__,________,XXX_____,
  ___XXXX_,_______X,XXX_____,
  ___XXXXX,_______X,XXX_____,
  ____XXXX,X_____XX,XX______,
  _____XXX,XX__XXXX,X_______,
  ______XX,XXXXXXXX,________,
  _______X,XXXXXX__,________,
  _______X,XXXXXXXX,________,
  _____XXX,XX_XXXXX,XX______,
  ____XXXX,X____XXX,XXX_____,
  ___XXXX_,_______X,XXX_____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,_XXX____,
  __XXXX__,________,XXXX____,
  __XXXXX_,_______X,XXXX____,
  ___XXXXX,XXXXXXXX,XXX_____,
  ____XXXX,XXXXXXXX,XX______,
  ______XX,XXXXXXXX,________,
//  57 $39 '0039'
//  width 20, bbx 2, bby 0, bbw 18, bbh 26
  _______X,XXXXXXX_,________,
  _____XXX,XXXXXXXX,X_______,
  ____XXXX,XXXXXXXX,X_______,
  ___XXXXX,______XX,XX______,
  ___XXXX_,_______X,XXX_____,
  __XXXX__,_______X,XXX_____,
  __XXXX__,________,XXX_____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  __XXXX__,________,XXXX____,
  ___XXXX_,_______X,XXXX____,
  ___XXXXX,XXXXXXXX,XXXX____,
  ____XXXX,XXXXXXXX,XXXX____,
  ______XX,XXXXXX__,XXXX____,
  ________,________,XXXX____,
  ________,________,XXXX____,
  ________,________,XXX_____,
  ________,_______X,XXX_____,
  ________,______XX,XX______,
  ________,______XX,XX______,
  ___X____,____XXXX,X_______,
  ___XXXXX,XXXXXXXX,________,
  ___XXXXX,XXXXXXX_,________,
  ___XXXXX,XXXXX___,________,
};

  /// character width for each encoding
static const unsigned char __calibri20x26_widths__[] = {
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
  19,
};

  /// character encoding for each index entry
static const unsigned short __ccalibri20x26_index__[] = {
  48,
  49,
  50,
  51,
  52,
  53,
  54,
  55,
  56,
  57,
};

  /// bitmap font structure
const struct bitmap_font calibri20x26 = {
  .Width = 20, .Height = 26,
  .Chars = 10,
  .Widths = __calibri20x26_widths__,
  .Index = __ccalibri20x26_index__,
  .Bitmap = __calibri20x26_bitmap__,
};

I think you can go 1 pixel smaller, but I am not sure. I believe that after you’ve made the font smaller past a certain value it won’t work anymore.

I’ve used it by calling this method:

backgroundLayer.setBitmapFont((bitmap_font *)&calibri20x26);

#12

Thanks @GeorgeFlorian. I had tried this and it worked to certain extent.

My setup is with teensy 3.6 and smartmatrix shield v4, 64x192 panel. Is there a guide for teensy with @marcmerlin’s smartmatrix_gfx ?? Most of them i saw with esp32.

Thanks a lot in advance.


#13

I doubt you’ll be able to run that big without running out of RAM

It works the same on both CPUs, it doesn’t care :slight_smile:


#14

I am going to port gfx to rPi which can run bigger panel strings but for now, the resolution you want might work or not depending on the panel type you use


#15

@marcmerlin Tried the demo code, its working for 128x64…is there any quick work around to run 192 x 64 ? I only need to display big fonts in the display. nothing else for now.

Thanks for the replies.


#16

I’m assuming you meant to say 128x64 worked and 192x64 crashed (due to lack of RAM).
First thing you need to do is post your code on github or gist.github.com so that we can see how you init your basic example (I hope you tried a very simple hello world that uses as little RAM as possible)

I got 128x128 working on teensy once by using ABCDE panels that seem to need less RAM than ABCD panels, but otherwise I don’t know the SmartMatrix backend code well enough.
@Louis may be able to help on maybe removing rendering layers to save more RAM.

One thing I’ve done is if 128x96 crashes, I try 128x70 128x80 and 128x90 to see where it crashes. It will look wrong in those odd sizes, but it gives me an idea of how close I am to the limit and how hopeless it is, or not :slight_smile:


#17

@marcmerlin Thanks. I did tried with a basic code and the one in your matrix gfx demo code. But i will retry with reduced sizes and see, if it can be done by optimizing ram issues. I am using ABCDE type panels with 64x64 px.