1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/lv_misc/lv_font.h

205 lines
4.6 KiB
C
Raw Normal View History

2017-11-23 20:42:14 +01:00
/**
2017-11-23 21:28:36 +01:00
* @file lv_font.h
2017-11-23 20:42:14 +01:00
*
*/
2017-11-23 21:28:36 +01:00
#ifndef LV_FONT_H
#define LV_FONT_H
2017-11-23 20:42:14 +01:00
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
2017-11-26 23:57:39 +01:00
#include "../../lv_conf.h"
2017-11-23 20:42:14 +01:00
#include <stdint.h>
#include <stddef.h>
2017-12-11 23:11:15 +01:00
#include "lv_fonts/lv_symbol_def.h"
2017-11-23 20:42:14 +01:00
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
2018-02-05 11:27:08 +01:00
typedef struct
{
uint32_t w_px :8;
uint32_t glyph_index :24;
}lv_font_glyph_dsc_t;
typedef struct
{
uint32_t unicode :21;
uint32_t glyph_dsc_index :11;
}lv_font_unicode_map_t;
2017-11-23 21:28:36 +01:00
typedef struct _lv_font_struct
2017-11-23 20:42:14 +01:00
{
2018-02-05 11:27:08 +01:00
uint32_t unicode_first;
uint32_t unicode_last;
uint8_t h_px;
const uint8_t * glyph_bitmap;
const lv_font_glyph_dsc_t * glyph_dsc;
2018-02-09 12:40:00 +01:00
const uint32_t * unicode_list;
const uint8_t * (*get_bitmap)(const struct _lv_font_struct * ,uint32_t);
2017-11-23 21:28:36 +01:00
struct _lv_font_struct * next_page; /*Pointer to a font extension*/
2018-02-09 12:40:00 +01:00
uint32_t bpp :4; /*Bit per pixel: 1, 2 or 4*/
2017-11-23 21:28:36 +01:00
}lv_font_t;
2017-11-23 20:42:14 +01:00
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the built-in fonts
*/
2017-11-23 21:28:36 +01:00
void lv_font_init(void);
2017-11-23 20:42:14 +01:00
/**
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
* @param child pointer to a font to join to the 'parent'
* @param parent pointer to a font. 'child' will be joined here
*/
2017-11-23 21:28:36 +01:00
void lv_font_add(lv_font_t *child, lv_font_t *parent);
2017-11-23 20:42:14 +01:00
/**
* Return with the bitmap of a font.
* @param font_p pointer to a font
* @param letter a letter
* @return pointer to the bitmap of the letter
*/
2017-11-23 21:28:36 +01:00
const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter);
2017-11-23 20:42:14 +01:00
/**
* Get the height of a font
* @param font_p pointer to a font
* @return the height of a font
*/
2017-11-23 21:28:36 +01:00
static inline uint8_t lv_font_get_height(const lv_font_t * font_p)
2017-11-23 20:42:14 +01:00
{
2018-02-05 11:27:08 +01:00
return font_p->h_px;
2017-11-23 20:42:14 +01:00
}
/**
* Get the width of a letter in a font
* @param font_p pointer to a font
* @param letter a letter
* @return the width of a letter
*/
2017-11-23 21:28:36 +01:00
uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter);
2017-11-23 20:42:14 +01:00
/**
2018-02-09 12:40:00 +01:00
* Get the bit-per-pixel of font
* @param font pointer to font
* @param letter a letter from font (font extensions can have different bpp)
* @return bpp of the font (or font extension)
2017-11-23 20:42:14 +01:00
*/
2018-02-09 12:40:00 +01:00
uint8_t lv_font_get_bpp(lv_font_t * font, uint32_t letter);
/**
* Generic bitmap get function used in 'font->get_bitmap' when the font contains all characters in the range
* @param font pointer to font
* @param unicode_letter an unicode letter which bitmap should be get
* @return pointer to the bitmap or NULL if not found
*/
const uint8_t * lv_font_get_bitmap_continuous(const lv_font_t * font, uint32_t unicode_letter);
/**
* Generic bitmap get function used in 'font->get_bitmap' when the font NOT contains all characters in the range (sparse)
* @param font pointer to font
* @param unicode_letter an unicode letter which bitmap should be get
* @return pointer to the bitmap or NULL if not found
*/
const uint8_t * lv_font_get_bitmap_sparse(const lv_font_t * font, uint32_t unicode_letter);
2017-11-23 20:42:14 +01:00
/**********************
* MACROS
**********************/
/***********************
2018-02-09 12:40:00 +01:00
* FONT DECLARATION INCLUDES
2017-11-23 20:42:14 +01:00
***********************/
2018-02-09 12:40:00 +01:00
/*10 px */
#if USE_LV_FONT_DEJAVU_10
extern lv_font_t lv_font_dejavu_10;
#endif
#if USE_LV_FONT_DEJAVU_10_LATIN_SUP
extern lv_font_t lv_font_dejavu_10_latin_sup;
#endif
#if USE_LV_FONT_DEJAVU_10_CYRILLIC
extern lv_font_t lv_font_dejavu_10_cyrillic;
#endif
#if USE_LV_FONT_SYMBOL_10
extern lv_font_t lv_font_symbol_10;
#endif
/*20 px */
#if USE_LV_FONT_DEJAVU_20
extern lv_font_t lv_font_dejavu_20;
#endif
#if USE_LV_FONT_DEJAVU_20_LATIN_SUP
extern lv_font_t lv_font_dejavu_20_latin_sup;
#endif
#if USE_LV_FONT_DEJAVU_20_CYRILLIC
extern lv_font_t lv_font_dejavu_20_cyrillic;
#endif
#if USE_LV_FONT_SYMBOL_20
extern lv_font_t lv_font_symbol_20;
#endif
/*30 px */
#if USE_LV_FONT_DEJAVU_30
extern lv_font_t lv_font_dejavu_30;
#endif
#if USE_LV_FONT_DEJAVU_30_LATIN_SUP
extern lv_font_t lv_font_dejavu_30_latin_sup;
#endif
#if USE_LV_FONT_DEJAVU_30_CYRILLIC
extern lv_font_t lv_font_dejavu_30_cyrillic;
#endif
#if USE_LV_FONT_SYMBOL_30
extern lv_font_t lv_font_symbol_30;
#endif
/*40 px */
#if USE_LV_FONT_DEJAVU_40
extern lv_font_t lv_font_dejavu_40;
#endif
#if USE_LV_FONT_DEJAVU_40_LATIN_SUP
extern lv_font_t lv_font_dejavu_40_latin_sup;
#endif
#if USE_LV_FONT_DEJAVU_40_CYRILLIC
extern lv_font_t lv_font_dejavu_40_cyrillic;
#endif
#if USE_LV_FONT_SYMBOL_40
extern lv_font_t lv_font_symbol_40;
#endif
2017-11-23 20:42:14 +01:00
#ifdef __cplusplus
} /* extern "C" */
#endif
2017-11-26 23:57:39 +01:00
#endif /*USE_FONT*/