Skip to content

Commit edcf45b

Browse files
authored
Merge pull request #32 from lutorm/include-fonts-individually
Include fonts individually
2 parents fd4764c + 0a9a233 commit edcf45b

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/SFE_MicroOLED.cpp

+26-9
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
6565
#include "util/fontlargeletter31x48.h"
6666

6767
// Change the total fonts included
68-
#ifdef INCLUDE_LARGE_LETTER_FONT
6968
#define TOTALFONTS 5
70-
#else
71-
#define TOTALFONTS 4
72-
#endif
7369

74-
// Add the font name as declared in the header file. Remove as many as possible to conserve FLASH memory.
70+
// Add the font name as declared in the header file. Remove as many
71+
// as possible to conserve FLASH memory.
7572
const unsigned char *MicroOLED::fontsPointer[] = {
76-
font5x7, font8x16, sevensegment, fontlargenumber
73+
#if INCLUDE_FONT0
74+
font5x7,
75+
#else
76+
0x0,
77+
#endif
78+
#if INCLUDE_FONT1
79+
font8x16,
80+
#else
81+
0x0,
82+
#endif
83+
#if INCLUDE_FONT2
84+
sevensegment,
85+
#else
86+
0x0,
87+
#endif
88+
#if INCLUDE_FONT3
89+
fontlargenumber,
90+
#else
91+
0x0,
92+
#endif
7793
#ifdef INCLUDE_LARGE_LETTER_FONT
78-
,
7994
fontlargeletter31x48
95+
#else
96+
0x0
8097
#endif
8198
};
8299

@@ -1017,8 +1034,8 @@ uint8_t MicroOLED::getFontType(void)
10171034
*/
10181035
uint8_t MicroOLED::setFontType(uint8_t type)
10191036
{
1020-
if ((type >= TOTALFONTS) || (type < 0))
1021-
return false;
1037+
if ((type >= TOTALFONTS) || !fontsPointer[type])
1038+
return false;
10221039

10231040
fontType = type;
10241041
fontWidth = pgm_read_byte(fontsPointer[fontType] + 0);

0 commit comments

Comments
 (0)