1
2# FreeType support
3Interface to [FreeType](https://www.freetype.org/) to generate font bitmaps run time.
4
5## Install FreeType
6- Download Freetype from [here](https://sourceforge.net/projects/freetype/files/)
7- `make`
8- `sudo make install`
9
10## Add FreeType to your project
11- Add include path: `/usr/include/freetype2` (for GCC: `-I/usr/include/freetype2 -L/usr/local/lib`)
12- Add library: `freetype` (for GCC: `-L/usr/local/lib -lfreetype`)
13
14## Usage
15Enable `LV_USE_FREETYPE` in `lv_conf.h`.
16
17To cache the glyphs from the opened fonts, set  `LV_FREETYPE_CACHE_SIZE >= 0` and then use the following macros for detailed configuration:
181. `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.
191. `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.
201. `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.
21
22When you are sure that all the used font sizes will not be greater than 256, you can enable `LV_FREETYPE_SBIT_CACHE`, which is much more memory efficient for small bitmaps.
23
24You 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.
25
26Font style supports bold and italic, you can use the following macros to set:
271. `FT_FONT_STYLE_NORMAL`:default style.
281. `FT_FONT_STYLE_ITALIC`:Italic style
291. `FT_FONT_STYLE_BOLD`:bold style
30
31They can be combined.eg:`FT_FONT_STYLE_BOLD | FT_FONT_STYLE_ITALIC`.
32
33Note that, the FreeType extension doesn't use LVGL's file system.
34You can simply pass the path to the font as usual on your operating system or platform.
35
36## Example
37```eval_rst
38.. include:: ../../examples/libs/freetype/index.rst
39```
40
41
42## Learn more
43- FreeType [tutorial](https://www.freetype.org/freetype2/docs/tutorial/step1.html)
44- LVGL's [font interface](https://docs.lvgl.io/v7/en/html/overview/font.html#add-a-new-font-engine)
45
46
47## API
48```eval_rst
49.. doxygenfile:: lv_freetype.h
50  :project: lvgl
51```