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

Source file containing the ASCII font table data and character lookup function for text rendering. More...

#include "font.h"
Include dependency graph for font.c:

Functions

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

Variables

const unsigned char font_ascii_table[][5] EEMEM

Detailed Description

Source file containing the ASCII font table data and character lookup function for text rendering.

This file defines the font data table for ASCII characters, supporting both uppercase and lowercase (unless excluded by macros). The font table can be located either in EEPROM or program memory (PROGMEM), depending on compile-time options. The character table entries represent the bitmap patterns for individual characters, which are selected by the lookup function font_getchararray(). This function handles bounds checking and optional conversion of lowercase to uppercase letters when enabled, to optimize memory usage. The table and accessor function are designed for use in embedded systems with constrained storage, such as microcontrollers, where font data is read for graphical text displays.

The configuration macros allow customization:

  • FONT_STORE_IN_EEPROM: Store font table in EEPROM instead of PROGMEM.
  • FONT_IGNORE_LOWER_CASE: Do not store or display lowercase letters, saving memory.
  • FONT_ASCII_START_CHAR / FONT_ASCII_END_CHAR: Configure supported character range.
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"

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:

Variable Documentation

◆ EEMEM

const unsigned char font_ascii_table [][ 5 ] EEMEM