Skip to content

Include fonts individually #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/SFE_MicroOLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util/fontlargeletter31x48.h"

// Change the total fonts included
#ifdef INCLUDE_LARGE_LETTER_FONT
#define TOTALFONTS 5
#else
#define TOTALFONTS 4
#endif

// Add the font name as declared in the header file. Remove as many as possible to conserve FLASH memory.
// Add the font name as declared in the header file. Remove as many
// as possible to conserve FLASH memory.
const unsigned char *MicroOLED::fontsPointer[] = {
font5x7, font8x16, sevensegment, fontlargenumber
#if INCLUDE_FONT0
font5x7,
#else
0x0,
#endif
#if INCLUDE_FONT1
font8x16,
#else
0x0,
#endif
#if INCLUDE_FONT2
sevensegment,
#else
0x0,
#endif
#if INCLUDE_FONT3
fontlargenumber,
#else
0x0,
#endif
#ifdef INCLUDE_LARGE_LETTER_FONT
,
fontlargeletter31x48
#else
0x0
#endif
};

Expand Down Expand Up @@ -1015,8 +1032,8 @@ uint8_t MicroOLED::getFontType(void)
*/
uint8_t MicroOLED::setFontType(uint8_t type)
{
if ((type >= TOTALFONTS) || (type < 0))
return false;
if ((type >= TOTALFONTS) || !fontsPointer[type])
return false;

fontType = type;
fontWidth = pgm_read_byte(fontsPointer[fontType] + 0);
Expand Down