FreeType support
FreeType support
Interface to FreeType to generate font bitmaps run time.
Install FreeType
- Download Freetype from here
make
sudo make install
Add FreeType to your project
- Add include path:
/usr/include/freetype2
(for GCC:-I/usr/include/freetype2 -L/usr/local/lib
) - Add library:
freetype
(for GCC:-L/usr/local/lib -lfreetype
)
Usage
Enable LV_USE_FREETYPE
in lv_conf.h
.
To cache the glyphs from the opened fonts set LV_FREETYPE_CACHE_SIZE >= 0
and then use the following macros for detailed configuration:
LV_FREETYPE_CACHE_SIZE
:maximum memory(bytes) used to cache font bitmap, outline, character maps, etc. 0 means use the system default value, less than 0 means disable cache.Note: that this value does not account for managed FT_Face and FT_Size objects.LV_FREETYPE_CACHE_FT_FACES
:maximum number of opened FT_Face objects managed by this cache instance.0 means use the system default value.Only useful when LV_FREETYPE_CACHE_SIZE >= 0.LV_FREETYPE_CACHE_FT_SIZES
:maximum number of opened FT_Size objects managed by this cache instance. 0 means use the system default value.Only useful when LV_FREETYPE_CACHE_SIZE >= 0.
When you are sure that all the used fonts size will not be greater than 256, you can enable LV_FREETYPE_SBIT_CACHE
, which is much more memory efficient for small bitmaps.
You can use lv_ft_font_init()
to create FreeType fonts. It returns true
to indicate success, at the same time, the font
member of lv_ft_info_t
will be filled with a pointer to an lvgl font, and you can use it like any lvgl font.
Font style supports bold and italic, you can use the following macro to set:
FT_FONT_STYLE_NORMAL
:default style.FT_FONT_STYLE_ITALIC
:Italic styleFT_FONT_STYLE_BOLD
:bold style
They can be combined.eg:FT_FONT_STYLE_BOLD | FT_FONT_STYLE_ITALIC
.
Note that, the FreeType extension doesn’t use LVGL’s file system. You can simply pass the path to the font as usual on your operating system or platform.
Example
Learn more
- FreeType tutorial
- LVGL’s font interface
API
警告
doxygenfile: Unable to find project ‘lvgl’ in breathe_projects dictionary
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!