-
-
Notifications
You must be signed in to change notification settings - Fork 56
How to create new font for the library
Aleksei edited this page Aug 29, 2020
·
3 revisions
The library supports different font formats. To get exact information on font formats supported, please refer to API.
- Creating new font using GLCD Font Creator (fixed width fonts)
- Creating new font from BDF format
- Creating new font directly from ttf font file (fixed width and variable size fonts)
- Use online font creator for the library
You can easily add new fonts to your application, using GLCD Font Creator application.
- Download and install GLCD Font Creator
- Download and install Python 2.7
- Download and install pip:
sudo apt-get install python-pip
- Download and install freetype_py:
sudo pip install freetype-py
orpip install freetype-py
- Download and install pip:
- Generate the font, you need, in GLCD Font Creator application.
- Export created font by pressing "Export to GLCD" button to some file glcdfont.c
- Run python script fontgenerator.py from lcdgfx/tools directory
python fontgenerator.py --glcd glcdfont.c -f old > ssd1306font.h
- Copy generated font code to your application or include ssd1306font.h file and use the font:
display.setFixedFont(YOUR_FONT_NAME);
display.printFixed(0, 8, "Hello", STYLE_NORMAL);
// OR
canvas.setFixedFont(YOUR_FONT_NAME);
canvas.printFixed(0, 8, "Hello", STYLE_NORMAL);
Creating new font from BDF format
Please, use this useful tool developed by mayopan: Link to font converter with instructions
You can easily add new fonts to your application, generating font directly from TTF font file.
- Download and install Python 2.7 (if you don't have it)
- Download and install pip:
sudo apt-get install python-pip
- Download and install freetype_py:
sudo pip install freetype-py
orpip install freetype-py
- Download and install pip:
sudo pip install freetype-py
- Generate the font, you need, directly from ttf file by running python script fontgenerator.py from lcdgfx/tools directory
python fontgenerator.py --ttf FreeMono.ttf -f old > ssd1306font.h
- Copy generated font code to your application or include ssd1306font.h file and use the font:
display.setFixedFont(YOUR_FONT_NAME);
display.printFixed(0, 8, "Hello", STYLE_NORMAL);
// OR
canvas.setFixedFont(YOUR_FONT_NAME);
canvas.printFixed(0, 8, "Hello", STYLE_NORMAL);
- Download and install Python 2.7 (if you don't have it)
- Download and install pip
- Download and install freetype_py
sudo pip install freetype-py
- Generate the font, you need, directly from ttf file by running python script fontgenerator.py from lcdgfx/tools directory
python fontgenerator.py --ttf FreeMono.ttf -f new > ssd1306font.h
- Copy generated font code to your application or include ssd1306font.h file and use the font:
display.setFreeFont(YOUR_FONT_NAME);
display.printFixed(0, 8, "Hello", STYLE_NORMAL);
// OR
canvas.setFreeFont(YOUR_FONT_NAME);
canvas.printFixed(0, 8, "Hello", STYLE_NORMAL);
check YOUR_FONT_NAME in generated header file.