esp-idf-ssd1306/FreeTypeDemo
2024-09-10 17:58:36 +09:00
..
fonts added FreeTypeDemo 2024-09-08 12:15:46 +09:00
main changed from ssd1306_bitmaps to _ssd1306_bitmaps 2024-09-10 17:31:04 +09:00
CMakeLists.txt added FreeTypeDemo 2024-09-08 12:15:46 +09:00
partitions.csv added FreeTypeDemo 2024-09-08 12:15:46 +09:00
README.md Update README.md 2024-09-10 17:58:36 +09:00
sdkconfig.defaults added FreeTypeDemo 2024-09-08 12:15:46 +09:00

FreeTypeDemo for SSD1306

FreeType components are available from the ESP Component Registry.
https://components.espressif.com/components/espressif/freetype/

The github page is here.
This component can convert a True Type Font to a bitmap image.

Please note that if you use a proportional font, some fonts may not convert correctly.
Monospaced fonts can be converted correctly.
You can find Monospaced fonts here.

FreeTypeDemo

How to use True Type font.

  • Download Monospaced fonts from internet.

  • Copy font file to fonts directory.

  • Select font.
    load_font("/fonts/consola.ttf");

  • Specify the display position and threshold.
    The converted bitmap is monochrome data with gradations from 0 to 255.
    The lower the value, the lighter the black, and the higher the value, the darker the black.
    Unfortunately, SSD1306 cannot express gradations.
    The lower the threshold, the small value will display. As a result, the text becomes thicker.
    The higher the threshold, the small value will not display. As a result, the text becomes thinner.
    render_text(&dev, 0, 16, 128, "FreeType");

Bitmap gradation representation

________
________
________
___####_
__##.+##
_+#___.#
_##____#
_#######
_##.....
_+#_____
__##+.+#
___####+
________
________
________
________

# indicates a value greater than 128.
+ indicates that the value is greater than 64 and less than 128.
. indicates that the value is greater than 32 and less than 64.
_ indicates a value less than 32.

Setting the threshold to 128 will only show # pixels.
The first and second fonts in the photo use the same font file (consola.ttf), but are displayed with different thresholds.

________
________
________
___####_
__##__##
_ #____#
_##____#
_#######
_##_____
_ #_____
__##___#
___####_
________
________
________
________