/**1* @file lv_font.h2*3*/45#ifndef LV_FONT_H6#define LV_FONT_H78#ifdef __cplusplus9extern "C" {10#endif111213/*********************14* INCLUDES15*********************/16#ifdef LV_CONF_INCLUDE_SIMPLE17#include "lv_conf.h"18#else19#include "../../lv_conf.h"20#endif2122#include <stdint.h>23#include <stddef.h>2425#include "lv_symbol_def.h"2627/*********************28* DEFINES29*********************/3031/**********************32* TYPEDEFS33**********************/3435typedef struct36{37uint32_t w_px :8;38uint32_t glyph_index :24;39} lv_font_glyph_dsc_t;4041typedef struct42{43uint32_t unicode :21;44uint32_t glyph_dsc_index :11;45} lv_font_unicode_map_t;4647typedef struct _lv_font_struct48{49uint32_t unicode_first;50uint32_t unicode_last;51const uint8_t * glyph_bitmap;52const lv_font_glyph_dsc_t * glyph_dsc;53const uint32_t * unicode_list;54const uint8_t * (*get_bitmap)(const struct _lv_font_struct *,uint32_t); /*Get a glyph's bitmap from a font*/55int16_t (*get_width)(const struct _lv_font_struct *,uint32_t); /*Get a glyph's with with a given font*/56struct _lv_font_struct * next_page; /*Pointer to a font extension*/57uint32_t h_px :8;58uint32_t bpp :4; /*Bit per pixel: 1, 2 or 4*/59uint32_t monospace :8; /*Fix width (0: normal width)*/60uint16_t glyph_cnt; /*Number of glyphs (letters) in the font*/61} lv_font_t;6263/**********************64* GLOBAL PROTOTYPES65**********************/6667/**68* Initialize the fonts69*/70void lv_font_init(void);7172/**73* Add a font to an other to extend the character set.74* @param child the font to add75* @param parent this font will be extended. Using it later will contain the characters from `child`76*/77void lv_font_add(lv_font_t *child, lv_font_t *parent);7879/**80* Remove a font from a character set.81* @param child the font to remove82* @param parent remove `child` from here83*/84void lv_font_remove(lv_font_t * child, lv_font_t * parent);8586/**87* Tells if font which contains `letter` is monospace or not88* @param font_p point to font89* @param letter an UNICODE character code90* @return true: the letter is monospace; false not monospace91*/92bool lv_font_is_monospace(const lv_font_t * font_p, uint32_t letter);9394/**95* Return with the bitmap of a font.96* @param font_p pointer to a font97* @param letter an UNICODE character code98* @return pointer to the bitmap of the letter99*/100const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter);101102/**103* Get the width of a letter in a font. If `monospace` is set then return with it.104* @param font_p pointer to a font105* @param letter an UNICODE character code106* @return the width of a letter107*/108uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter);109110111/**112* Get the width of the letter without overwriting it with the `monospace` attribute113* @param font_p pointer to a font114* @param letter an UNICODE character code115* @return the width of a letter116*/117uint8_t lv_font_get_real_width(const lv_font_t * font_p, uint32_t letter);118119/**120* Get the height of a font121* @param font_p pointer to a font122* @return the height of a font123*/124static inline uint8_t lv_font_get_height(const lv_font_t * font_p)125{126return font_p->h_px;127}128129/**130* Get the bit-per-pixel of font131* @param font pointer to font132* @param letter a letter from font (font extensions can have different bpp)133* @return bpp of the font (or font extension)134*/135uint8_t lv_font_get_bpp(const lv_font_t * font, uint32_t letter);136137/**138* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in the range139* @param font pointer to font140* @param unicode_letter an unicode letter which bitmap should be get141* @return pointer to the bitmap or NULL if not found142*/143const uint8_t * lv_font_get_bitmap_continuous(const lv_font_t * font, uint32_t unicode_letter);144145/**146* Generic bitmap get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)147* @param font pointer to font148* @param unicode_letter an unicode letter which bitmap should be get149* @return pointer to the bitmap or NULL if not found150*/151const uint8_t * lv_font_get_bitmap_sparse(const lv_font_t * font, uint32_t unicode_letter);152/**153* Generic glyph width get function used in 'font->get_width' when the font contains all characters in the range154* @param font pointer to font155* @param unicode_letter an unicode letter which width should be get156* @return width of the gylph or -1 if not found157*/158int16_t lv_font_get_width_continuous(const lv_font_t * font, uint32_t unicode_letter);159160/**161* Generic glyph width get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)162* @param font pointer to font163* @param unicode_letter an unicode letter which width should be get164* @return width of the glyph or -1 if not found165*/166int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter);167168/**********************169* MACROS170**********************/171172#define LV_FONT_DECLARE(font_name) extern lv_font_t font_name;173174175/**********************176* ADD BUILT IN FONTS177**********************/178#include "../lv_fonts/lv_font_builtin.h"179180/*Declare the custom (user defined) fonts*/181#ifdef LV_FONT_CUSTOM_DECLARE182LV_FONT_CUSTOM_DECLARE183#endif184185#ifdef __cplusplus186} /* extern "C" */187#endif188189#endif /*USE_FONT*/190191192193