mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
add support to > 255 fonts by enabling LV_FONT_FMT_TXT_LARGE
This commit is contained in:
parent
c607e45b48
commit
22973360d0
@ -24,6 +24,7 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lv_symbol_def.h"
|
||||
#include "../lv_misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -46,10 +47,10 @@ extern "C" {
|
||||
typedef struct
|
||||
{
|
||||
uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width. 8 bit integer, 4 bit fractional */
|
||||
uint8_t box_w; /**< Width of the glyph's bounding box*/
|
||||
uint8_t box_h; /**< Height of the glyph's bounding box*/
|
||||
int8_t ofs_x; /**< x offset of the bounding box*/
|
||||
int8_t ofs_y; /**< y offset of the bounding box*/
|
||||
uint16_t box_w; /**< Width of the glyph's bounding box*/
|
||||
uint16_t box_h; /**< Height of the glyph's bounding box*/
|
||||
int16_t ofs_x; /**< x offset of the bounding box*/
|
||||
int16_t ofs_y; /**< y offset of the bounding box*/
|
||||
uint8_t bpp; /**< Bit-per-pixel: 1, 2, 4, 8*/
|
||||
}lv_font_glyph_dsc_t;
|
||||
|
||||
@ -74,8 +75,8 @@ typedef struct _lv_font_struct
|
||||
const uint8_t * (*get_glyph_bitmap)(const struct _lv_font_struct *, uint32_t);
|
||||
|
||||
/*Pointer to the font in a font pack (must have the same line height)*/
|
||||
uint8_t line_height; /**< The real line height where any text fits*/
|
||||
uint8_t base_line; /**< Base line measured from the top of the line_height*/
|
||||
lv_coord_t line_height; /**< The real line height where any text fits*/
|
||||
lv_coord_t base_line; /**< Base line measured from the top of the line_height*/
|
||||
uint8_t subpx :2; /**< An element of `lv_font_subpx_t`*/
|
||||
void * dsc; /**< Store implementation specific data here*/
|
||||
#if LV_USE_USER_DATA
|
||||
@ -121,7 +122,7 @@ uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32
|
||||
* @param font_p pointer to a font
|
||||
* @return the height of a font
|
||||
*/
|
||||
static inline uint8_t lv_font_get_line_height(const lv_font_t * font_p)
|
||||
static inline lv_coord_t lv_font_get_line_height(const lv_font_t * font_p)
|
||||
{
|
||||
return font_p->line_height;
|
||||
}
|
||||
|
@ -127,8 +127,6 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
*/
|
||||
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next)
|
||||
{
|
||||
|
||||
|
||||
bool is_tab = false;
|
||||
if(unicode_letter == '\t') {
|
||||
unicode_letter = ' ';
|
||||
@ -151,8 +149,6 @@ bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t *
|
||||
|
||||
int32_t kv = ((int32_t)((int32_t)kvalue * fdsc->kern_scale) >> 4);
|
||||
|
||||
|
||||
|
||||
uint32_t adv_w = gdsc->adv_w;
|
||||
if(is_tab) adv_w *= 2;
|
||||
|
||||
|
@ -38,14 +38,18 @@ typedef struct
|
||||
#if LV_FONT_FMT_TXT_LARGE == 0
|
||||
uint32_t bitmap_index : 20; /**< Start index of the bitmap. A font can be max 1 MB. */
|
||||
uint32_t adv_w :12; /**< Draw the next glyph after this width. 8.4 format (real_value * 16 is stored). */
|
||||
#else
|
||||
uint32_t bitmap_index; /**< Start index of the bitmap. A font can be max 4 GB. */
|
||||
uint32_t adv_w; /**< Draw the next glyph after this width. 28.4 format (real_value * 16 is stored). */
|
||||
#endif
|
||||
uint8_t box_w; /**< Width of the glyph's bounding box*/
|
||||
uint8_t box_h; /**< Height of the glyph's bounding box*/
|
||||
int8_t ofs_x; /**< x offset of the bounding box*/
|
||||
int8_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/
|
||||
#else
|
||||
uint32_t bitmap_index; /**< Start index of the bitmap. A font can be max 4 GB. */
|
||||
uint32_t adv_w; /**< Draw the next glyph after this width. 28.4 format (real_value * 16 is stored). */
|
||||
uint16_t box_w; /**< Width of the glyph's bounding box*/
|
||||
uint16_t box_h; /**< Height of the glyph's bounding box*/
|
||||
int16_t ofs_x; /**< x offset of the bounding box*/
|
||||
int16_t ofs_y; /**< y offset of the bounding box. Measured from the top of the line*/
|
||||
#endif
|
||||
}lv_font_fmt_txt_glyph_dsc_t;
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t *
|
||||
uint32_t line_start = 0;
|
||||
uint32_t new_line_start = 0;
|
||||
lv_coord_t act_line_length;
|
||||
uint8_t letter_height = lv_font_get_line_height(font);
|
||||
uint16_t letter_height = lv_font_get_line_height(font);
|
||||
|
||||
/*Calc. the height and longest line*/
|
||||
while(text[line_start] != '\0') {
|
||||
|
@ -591,7 +591,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t char_id, lv_point_
|
||||
lv_coord_t max_w = lv_obj_get_width(label);
|
||||
const lv_style_t * style = lv_obj_get_style(label);
|
||||
const lv_font_t * font = style->text.font;
|
||||
uint8_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t y = 0;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
|
||||
@ -694,7 +694,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
lv_coord_t max_w = lv_obj_get_width(label);
|
||||
const lv_style_t * style = lv_obj_get_style(label);
|
||||
const lv_font_t * font = style->text.font;
|
||||
uint8_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t y = 0;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
uint16_t logical_pos;
|
||||
@ -854,7 +854,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
|
||||
lv_coord_t max_w = lv_obj_get_width(label);
|
||||
const lv_style_t * style = lv_obj_get_style(label);
|
||||
const lv_font_t * font = style->text.font;
|
||||
uint8_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t letter_height = lv_font_get_line_height(font);
|
||||
lv_coord_t y = 0;
|
||||
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
|
||||
lv_label_align_t align = lv_label_get_align(label);
|
||||
|
Loading…
x
Reference in New Issue
Block a user