LFC is an ultra-compact, memory-efficient bitmap font library designed specifically for resource-constrained embedded systems. With font files as small as 3-4KB and support for multiple displays, it provides professional typography capabilities for systems with less than 64KB of memory.
- Tiny font files: ~4KB for code space, ~3KB for 24px ASCII fonts
- Zero heap usage: Completely malloc-free design
- Minimal overhead: < 100 bytes RAM usage per display context
- Optimized for: Systems with 64KB or less total memory
- Complete UTF-8 encoding/decoding
- Direct UTF-32 character rendering
- Multi-language text capabilities
- Efficient Unicode code point lookup
- Multiple display support: Drive different screens simultaneously
- Dynamic screen rotation: 0°, 90°, 180°, 270° orientations
- Display-independent rendering: Same API for all display types
- Flexible pixel callbacks: Custom display driver integration
- Configurable character spacing and padding
- Text inversion (black/white mode)
- Bounding box visualization
- Rectangle drawing (filled or outline)
- Multi-display synchronized operations
The library requires a display-specific driver or a pixel writing function compatible with your embedded system's display hardware.
What you need to implement:
- A hardware-specific function that writes individual pixels to your display
- Display resolution
The library requires C8 format bitmap fonts that must be converted using the LFC Font Converter tool.
First, copy the lfc_font_lib folder and add it to your project. The folder contains two files. Alternatively, you can add only these two files directly to your project if you prefer.
To use the LFC font library, include the lfc_font.h file in your desired source file using the #include directive.
// Include LFC font library
#include "lfc_font_lib/lfc_font.h"Define a variable using the DISPLAY_CONTEXT structure defined in lfc_font.h and store your display's specifications within this structure.
DISPLAY_CONTEXT device_display;
// Set display properties (for ssd1306)
device_display.width = 128; // Display width
device_display.height = 64; // Display height
device_display.rotation = 0; // Screen rotation (0-3), 0: 0, 1:90, 2:180, 3:270 degree
device_display.set_pixel_func = SSD1306_Set_Pixel; // Pixel write function, it defined in your display library
The library uses the PRINT_FORM structure to write text or icons to the display. Define a variable using this structure and configure the C8 font array and other text display properties.
// Create print form
PRINT_FORM print_form;
// Set displayer
print_form.display_context = &main_display;
// Set font (it defined in fonts/C8_fonts.h Create by LFC Font Converter)
print_form.font=Goldman_Regular_16;
// Disable all extra properties
print_form.config=LFC_DEFAULT_CONFIG;
// Extra space between characters
print_form.spacing=0;
// Padding text
print_form.padding=0;
You can display any UTF-8 string or icon on the screen using the LFC_Print_Str function.
// Display coordinates for text placement
// (0,0) is typically bottom-left corner of the display
int16_t pos_x = 10; // X coordinate: 10 pixels from left edge
int16_t pos_y = 10; // Y coordinate: 10 pixels from bottom edge
// Text content to display
uint8_t display_text[] = "Hello World";
// Render text on screen using configured print format
LFC_Print(&print_form, display_text, pos_x, pos_y);