2017-11-23 20:42:14 +01:00
|
|
|
/**
|
2017-11-23 21:28:36 +01:00
|
|
|
* @file lv_font.c
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2017-11-23 20:42:14 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2019-03-06 11:14:06 +01:00
|
|
|
|
2017-11-23 20:42:14 +01:00
|
|
|
#include "lv_font.h"
|
2019-06-06 05:55:17 +02:00
|
|
|
#include "../lv_misc/lv_utils.h"
|
|
|
|
#include "../lv_misc/lv_log.h"
|
2017-11-23 20:42:14 +01:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return with the bitmap of a font.
|
|
|
|
* @param font_p pointer to a font
|
2018-06-22 23:32:21 +02:00
|
|
|
* @param letter an UNICODE character code
|
2017-11-23 20:42:14 +01:00
|
|
|
* @return pointer to the bitmap of the letter
|
|
|
|
*/
|
2019-04-22 05:21:35 +02:00
|
|
|
const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter)
|
2017-11-23 20:42:14 +01:00
|
|
|
{
|
2019-05-29 06:40:19 +02:00
|
|
|
return font_p->get_glyph_bitmap(font_p, letter);
|
2017-11-23 20:42:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-05-01 16:43:32 +02:00
|
|
|
* Get the descriptor of a glyph
|
|
|
|
* @param font_p pointer to font
|
|
|
|
* @param dsc_out store the result descriptor here
|
|
|
|
* @param letter an UNICODE letter code
|
|
|
|
* @return true: descriptor is successfully loaded into `dsc_out`.
|
|
|
|
* false: the letter was not found, no data is loaded to `dsc_out`
|
2017-11-23 20:42:14 +01:00
|
|
|
*/
|
2019-05-29 06:40:19 +02:00
|
|
|
bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next)
|
2018-06-22 23:32:21 +02:00
|
|
|
{
|
2019-05-29 06:40:19 +02:00
|
|
|
return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next);
|
|
|
|
}
|
2018-06-22 23:32:21 +02:00
|
|
|
|
2019-05-29 06:40:19 +02:00
|
|
|
/**
|
|
|
|
* Get the width of a glyph with kerning
|
|
|
|
* @param font pointer to a font
|
|
|
|
* @param letter an UNICODE letter
|
|
|
|
* @param letter_next the next letter after `letter`. Used for kerning
|
|
|
|
* @return the width of the glyph
|
|
|
|
*/
|
|
|
|
uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next)
|
|
|
|
{
|
|
|
|
lv_font_glyph_dsc_t g;
|
|
|
|
bool ret;
|
|
|
|
ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next);
|
|
|
|
if(ret) return g.adv_w;
|
|
|
|
else return 0;
|
2019-04-24 17:28:38 +02:00
|
|
|
}
|
|
|
|
|
2017-11-23 20:42:14 +01:00
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|