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.