oled 1.0
OLED Graphics Control Library
Loading...
Searching...
No Matches
font.h File Reference

Header file for font handling and character bitmap retrieval. More...

#include <ctype.h>
#include <avr/io.h>
#include <avr/eeprom.h>
Include dependency graph for font.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FONT_WIDTH   5
 Defines the width in pixels of each character in the font.
#define FONT_HEIGHT   7
 Defines the height in pixels of each character in the font.
#define FONT_ASCII_START_CHAR   ' '
 Specifies the starting ASCII character for the font.
#define FONT_ASCII_END_CHAR   '~'
 Specifies the ending ASCII character for the font.
#define FONT_IGNORE_LOWER_CASE
 Converts all lowercase letters to uppercase to save memory in PROGMEM or EEPROM.
#define FONT_STORE_IN_EEPROM
 Stores the font data in EEPROM memory.

Functions

unsigned char * font_getchararray (const char character)
 Retrieves the bitmap array for a given ASCII character from the font table.

Detailed Description

Header file for font handling and character bitmap retrieval.

This file defines macros for font dimensions, ASCII character range, and configuration options such as storing fonts in EEPROM or ignoring lower case characters. It provides the prototype for font_getchararray, a function that returns the bitmap data of a given ASCII character. The font data supports rendering text on graphical displays like OLED by converting characters into pixel patterns. Configuration macros allow customization of font size and storage.

Author
g.raf
Date
2025-09-03
Version
1.0 Release
Note
This file is part of a larger project and subject to the license specified in the repository. For updates and the complete revision history, see the GitHub repository.
See also
https://github.com/0x007e/oled "AVR ATmega GitHub Repository"

Macro Definition Documentation

◆ FONT_ASCII_END_CHAR

#define FONT_ASCII_END_CHAR   '~'

Specifies the ending ASCII character for the font.

This macro defines the last ASCII character that the font supports or displays. It is used to set the ending character code when mapping font glyphs.

◆ FONT_ASCII_START_CHAR

#define FONT_ASCII_START_CHAR   ' '

Specifies the starting ASCII character for the font.

This macro defines the first ASCII character that the font supports or displays. It is used to set the beginning character code when mapping font glyphs.

◆ FONT_HEIGHT

#define FONT_HEIGHT   7

Defines the height in pixels of each character in the font.

This macro sets the vertical size of a single character glyph in pixels. It is used to define the font height for rendering text on graphical displays.

◆ FONT_IGNORE_LOWER_CASE

#define FONT_IGNORE_LOWER_CASE

Converts all lowercase letters to uppercase to save memory in PROGMEM or EEPROM.

When this macro is defined, only uppercase letters are displayed by converting any lowercase letters to their uppercase equivalents. This helps reduce memory usage in program memory (PROGMEM) or EEPROM by avoiding the storage of separate lowercase glyphs.

Note
Defining this macro enables the ignoring of lowercase characters entirely.

◆ FONT_STORE_IN_EEPROM

#define FONT_STORE_IN_EEPROM

Stores the font data in EEPROM memory.

When this macro is defined, font data is saved in the EEPROM memory instead of PROGMEM, which helps reduce PROGMEM usage. The amount of EEPROM required depends on the character set:

  • All ASCII characters require approximately 470 bytes of EEPROM.
  • ASCII characters without lowercase letters require approximately 340 bytes of EEPROM.
Note
Using EEPROM for font storage extends PROGRAM availability but be mindful of EEPROM write limits.

◆ FONT_WIDTH

#define FONT_WIDTH   5

Defines the width in pixels of each character in the font.

This macro sets the horizontal size of a single character glyph in pixels. It is used to calculate spacing and positioning when rendering text on graphical displays.

Function Documentation

◆ font_getchararray()

unsigned char * font_getchararray ( char character)

Retrieves the bitmap array for a given ASCII character from the font table.

Parameters
characterThe ASCII character to retrieve the bitmap for.
Returns
Pointer to a static array for storing the bitmap bytes representing the character.

This function maps an input ASCII character to its corresponding bitmap pattern stored in the font table. If the character is outside the supported ASCII range defined by FONT_ASCII_START_CHAR and FONT_ASCII_END_CHAR, it defaults is the '?' character. When the macro FONT_IGNORE_LOWER_CASE is defined, lowercase letters are converted to uppercase to save memory, and adjustments are made to the character code accordingly.

Note
The bitmap data is read from either EEPROM or program memory (PROGMEM) depending on the macro FONT_STORE_IN_EEPROM. The data is copied into a static temporary array and a pointer to this array is returned for use in rendering.
Here is the caller graph for this function: