1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

Merge branch 'font' of https://github.com/littlevgl/lvgl into dev-6.0

This commit is contained in:
Gabor Kiss-Vamosi 2019-06-05 15:19:12 +02:00
commit b29c84cc88
49 changed files with 12261 additions and 148013 deletions

View File

@ -224,40 +224,29 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
* FONT USAGE
*===================*/
/* More info about fonts: https://docs.littlevgl.com/#Fonts
* To enable a built-in font use 1,2,4 or 8 values
* which will determine the bit-per-pixel. Higher value means smoother fonts */
#define LV_USE_FONT_DEJAVU_10 4
#define LV_USE_FONT_DEJAVU_10_LATIN_SUP 4
#define LV_USE_FONT_DEJAVU_10_CYRILLIC 4
#define LV_USE_FONT_SYMBOL_10 4
#define LV_USE_FONT_DEJAVU_20 4
#define LV_USE_FONT_DEJAVU_20_LATIN_SUP 4
#define LV_USE_FONT_DEJAVU_20_CYRILLIC 4
#define LV_USE_FONT_SYMBOL_20 4
#define LV_USE_FONT_DEJAVU_30 4
#define LV_USE_FONT_DEJAVU_30_LATIN_SUP 4
#define LV_USE_FONT_DEJAVU_30_CYRILLIC 4
#define LV_USE_FONT_SYMBOL_30 4
#define LV_USE_FONT_DEJAVU_40 4
#define LV_USE_FONT_DEJAVU_40_LATIN_SUP 4
#define LV_USE_FONT_DEJAVU_40_CYRILLIC 4
#define LV_USE_FONT_SYMBOL_40 4
#define LV_USE_FONT_MONOSPACE_8 1
/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel.
* The symbols are available via `LV_SYMBOL_...` defines
* More info about fonts: https://docs.littlevgl.com/#Fonts
* To create a new font go to: https://littlevgl.com/ttf-font-to-c-array
*/
#define LV_FONT_ROBOTO_12 0
#define LV_FONT_ROBOTO_16 1
#define LV_FONT_ROBOTO_22 0
#define LV_FONT_ROBOTO_28 0
/* Optionally declare your custom fonts here.
* You can use these fonts as default font too
* and they will be available globally. E.g.
* #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \
* LV_FONT_DECLARE(my_font_2) \
* LV_FONT_DECLARE(my_font_2)
*/
#define LV_FONT_CUSTOM_DECLARE
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
/*Always set a default font from the built-in fonts*/
#define LV_FONT_DEFAULT &lv_font_roboto_16
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
typedef void * lv_font_user_data_t;
/*=================
* Text settings

3
lvgl.h
View File

@ -30,6 +30,9 @@ extern "C" {
#include "src/lv_themes/lv_theme.h"
#include "src/lv_misc/lv_font.h"
#include "src/lv_misc/lv_font_fmt/lv_font_fmt_txt.h"
#include "src/lv_objx/lv_btn.h"
#include "src/lv_objx/lv_imgbtn.h"
#include "src/lv_objx/lv_img.h"

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,45 @@
import argparse
import os
import sys
parser = argparse.ArgumentParser(description='Create fonts for LittelvGL including the built-in symbols. lv_font_conv needs to be installed. See https://github.com/littlevgl/lv_font_conv')
parser.add_argument('-s', '--size',
type=int,
metavar = 'px',
nargs='?',
help='Size of the font in px')
parser.add_argument('--bpp',
type=int,
metavar = '1,2,4',
nargs='?',
help='Bit per pixel')
parser.add_argument('-r', '--range',
nargs='+',
metavar = 'start-end',
default='0x20-0x7F',
help='Ranges and/or characters to include. Default is 0x20-7F (ASCII). E.g. -r 0x20-0x7F, 0x200, 324')
parser.add_argument('--font',
metavar = 'file',
nargs='?',
default='Roboto-Regular.woff',
help='A TTF or WOFF file')
parser.add_argument('-o', '--output',
nargs='?',
metavar='file',
help='Output file name. E.g. my_font_20.c')
parser.add_argument('--compressed', action='store_true',
help='Compress the bitmaps')
args = parser.parse_args()
if args.compressed == False:
compr = "--no-compress --no-prefilter"
else:
compr = ""
#Built in symbols
syms = "61441,61448,61451,61452,61453,61457,61459,61460,61461,61465,61468,61473,61478,61479,61480,61502,61504,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62099"
#Run the command
cmd = "lv_font_conv {} --bpp {} --size {} --font ./Roboto-Regular.woff -r {} --font FontAwesome.ttf -r {} --format lvgl -o {}".format(compr, args.bpp, args.size, args.range, syms, args.output)
os.system(cmd)

View File

@ -322,79 +322,41 @@
* FONT USAGE
*===================*/
/* More info about fonts: https://docs.littlevgl.com/#Fonts
* To enable a built-in font use 1,2,4 or 8 values
* which will determine the bit-per-pixel. Higher value means smoother fonts */
#ifndef LV_USE_FONT_DEJAVU_10
#define LV_USE_FONT_DEJAVU_10 4
/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel.
* The symbols are available via `LV_SYMBOL_...` defines
* More info about fonts: https://docs.littlevgl.com/#Fonts
* To create a new font go to: https://littlevgl.com/ttf-font-to-c-array
*/
#ifndef LV_FONT_ROBOTO_12
#define LV_FONT_ROBOTO_12 0
#endif
#ifndef LV_USE_FONT_DEJAVU_10_LATIN_SUP
#define LV_USE_FONT_DEJAVU_10_LATIN_SUP 4
#ifndef LV_FONT_ROBOTO_16
#define LV_FONT_ROBOTO_16 1
#endif
#ifndef LV_USE_FONT_DEJAVU_10_CYRILLIC
#define LV_USE_FONT_DEJAVU_10_CYRILLIC 4
#ifndef LV_FONT_ROBOTO_22
#define LV_FONT_ROBOTO_22 0
#endif
#ifndef LV_USE_FONT_SYMBOL_10
#define LV_USE_FONT_SYMBOL_10 4
#endif
#ifndef LV_USE_FONT_DEJAVU_20
#define LV_USE_FONT_DEJAVU_20 4
#endif
#ifndef LV_USE_FONT_DEJAVU_20_LATIN_SUP
#define LV_USE_FONT_DEJAVU_20_LATIN_SUP 4
#endif
#ifndef LV_USE_FONT_DEJAVU_20_CYRILLIC
#define LV_USE_FONT_DEJAVU_20_CYRILLIC 4
#endif
#ifndef LV_USE_FONT_SYMBOL_20
#define LV_USE_FONT_SYMBOL_20 4
#endif
#ifndef LV_USE_FONT_DEJAVU_30
#define LV_USE_FONT_DEJAVU_30 4
#endif
#ifndef LV_USE_FONT_DEJAVU_30_LATIN_SUP
#define LV_USE_FONT_DEJAVU_30_LATIN_SUP 4
#endif
#ifndef LV_USE_FONT_DEJAVU_30_CYRILLIC
#define LV_USE_FONT_DEJAVU_30_CYRILLIC 4
#endif
#ifndef LV_USE_FONT_SYMBOL_30
#define LV_USE_FONT_SYMBOL_30 4
#endif
#ifndef LV_USE_FONT_DEJAVU_40
#define LV_USE_FONT_DEJAVU_40 4
#endif
#ifndef LV_USE_FONT_DEJAVU_40_LATIN_SUP
#define LV_USE_FONT_DEJAVU_40_LATIN_SUP 4
#endif
#ifndef LV_USE_FONT_DEJAVU_40_CYRILLIC
#define LV_USE_FONT_DEJAVU_40_CYRILLIC 4
#endif
#ifndef LV_USE_FONT_SYMBOL_40
#define LV_USE_FONT_SYMBOL_40 4
#endif
#ifndef LV_USE_FONT_MONOSPACE_8
#define LV_USE_FONT_MONOSPACE_8 1
#ifndef LV_FONT_ROBOTO_28
#define LV_FONT_ROBOTO_28 0
#endif
/* Optionally declare your custom fonts here.
* You can use these fonts as default font too
* and they will be available globally. E.g.
* #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \
* LV_FONT_DECLARE(my_font_2) \
* LV_FONT_DECLARE(my_font_2)
*/
#ifndef LV_FONT_CUSTOM_DECLARE
#define LV_FONT_CUSTOM_DECLARE
#endif
/*Always set a default font from the built-in fonts*/
#ifndef LV_FONT_DEFAULT
#define LV_FONT_DEFAULT &lv_font_dejavu_20 /*Always set a default font from the built-in fonts*/
#define LV_FONT_DEFAULT &lv_font_roboto_16
#endif
/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/
/*=================
* Text settings
*=================*/

View File

@ -88,7 +88,6 @@ void lv_init(void)
lv_fs_init();
#endif
lv_font_init();
#if LV_USE_ANIMATION
lv_anim_core_init();
#endif

View File

@ -184,8 +184,7 @@ void lv_disp_refr_task(lv_task_t * task)
/* With true double buffering the flushing should be only the address change of the
* current frame buffer. Wait until the address change is ready and copy the changed
* content to the other frame buffer (new active VDB) to keep the buffers synchronized*/
while(vdb->flushing)
;
while(vdb->flushing);
uint8_t * buf_act = (uint8_t *)vdb->buf_act;
uint8_t * buf_ina = (uint8_t *)vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1;

View File

@ -94,7 +94,7 @@ void lv_style_init(void)
lv_style_scr.text.color = lv_color_make(0x30, 0x30, 0x30);
lv_style_scr.text.sel_color = lv_color_make(0x55, 0x96, 0xd8);
lv_style_scr.text.font = LV_FONT_DEFAULT;
lv_style_scr.text.letter_space = 2;
lv_style_scr.text.letter_space = 0;
lv_style_scr.text.line_space = 2;
lv_style_scr.image.opa = LV_OPA_COVER;

View File

@ -229,11 +229,15 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_
void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p,
uint32_t letter, lv_color_t color, lv_opa_t opa)
{
const uint8_t bpp1_opa_table[2] = {
0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
/*clang-format off*/
const uint8_t bpp1_opa_table[2] = { 0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/
const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/
const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/
68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255};
68, 85, 102, 119,
136, 153, 170, 187,
204, 221, 238, 255};
/*clang-format on*/
if(opa < LV_OPA_MIN) return;
if(opa > LV_OPA_MAX) opa = LV_OPA_COVER;
@ -242,45 +246,43 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
return;
}
lv_coord_t pos_x = pos_p->x;
lv_coord_t pos_y = pos_p->y;
uint8_t letter_w = lv_font_get_real_width(font_p, letter);
uint8_t letter_h = lv_font_get_height(font_p);
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
lv_font_glyph_dsc_t g;
bool g_ret = lv_font_get_glyph_dsc(font_p, &g, letter, '\0');
if(g_ret == false) return;
lv_coord_t pos_x = pos_p->x + g.ofs_x;
lv_coord_t pos_y = pos_p->y + (font_p->line_height - font_p->base_line) - g.box_h - g.ofs_y;
const uint8_t * bpp_opa_table;
uint8_t mask_init;
uint8_t mask;
uint8_t bitmask_init;
uint8_t bitmask;
if(lv_font_is_monospace(font_p, letter)) {
pos_x += (lv_font_get_width(font_p, letter) - letter_w) / 2;
}
switch(bpp) {
switch(g.bpp) {
case 1:
bpp_opa_table = bpp1_opa_table;
mask_init = 0x80;
bitmask_init = 0x80;
break;
case 2:
bpp_opa_table = bpp2_opa_table;
mask_init = 0xC0;
bitmask_init = 0xC0;
break;
case 4:
bpp_opa_table = bpp4_opa_table;
mask_init = 0xF0;
bitmask_init = 0xF0;
break;
case 8:
bpp_opa_table = NULL;
mask_init = 0xFF;
bitmask_init = 0xFF;
break; /*No opa table, pixel value will be used directly*/
default: return; /*Invalid bpp. Can't render the letter*/
}
const uint8_t * map_p = lv_font_get_bitmap(font_p, letter);
const uint8_t * map_p = lv_font_get_glyph_bitmap(font_p, letter);
if(map_p == NULL) return;
/*If the letter is completely out of mask don't draw it */
if(pos_x + letter_w < mask_p->x1 || pos_x > mask_p->x2 || pos_y + letter_h < mask_p->y1 ||
if(pos_x + g.box_w < mask_p->x1 || pos_x > mask_p->x2 || pos_y + g.box_h < mask_p->y1 ||
pos_y > mask_p->y2)
return;
@ -290,22 +292,16 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
lv_coord_t vdb_width = lv_area_get_width(&vdb->area);
lv_color_t * vdb_buf_tmp = vdb->buf_act;
lv_coord_t col, row;
uint8_t col_bit;
uint8_t col_byte_cnt;
/*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
uint8_t width_byte_scr = letter_w >> 3;
if(letter_w & 0x7) width_byte_scr++;
/*Letter width in byte. Real width in the font*/
uint8_t width_byte_bpp = (letter_w * bpp) >> 3;
if((letter_w * bpp) & 0x7) width_byte_bpp++;
uint8_t width_byte_scr = g.box_w >> 3; /*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
if(g.box_w & 0x7) width_byte_scr++;
uint8_t width_bit = g.box_w * g.bpp; /*Letter width in bits*/
/* Calculate the col/row start/end on the map*/
lv_coord_t col_start = pos_x >= mask_p->x1 ? 0 : mask_p->x1 - pos_x;
lv_coord_t col_end = pos_x + letter_w <= mask_p->x2 ? letter_w : mask_p->x2 - pos_x + 1;
lv_coord_t col_end = pos_x + g.box_w <= mask_p->x2 ? g.box_w : mask_p->x2 - pos_x + 1;
lv_coord_t row_start = pos_y >= mask_p->y1 ? 0 : mask_p->y1 - pos_y;
lv_coord_t row_end = pos_y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_y + 1;
lv_coord_t row_end = pos_y + g.box_h <= mask_p->y2 ? g.box_h : mask_p->y2 - pos_y + 1;
/*Set a pointer on VDB to the first pixel of the letter*/
vdb_buf_tmp += ((pos_y - vdb->area.y1) * vdb_width) + pos_x - vdb->area.x1;
@ -314,21 +310,23 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
vdb_buf_tmp += (row_start * vdb_width) + col_start;
/*Move on the map too*/
map_p += (row_start * width_byte_bpp) + ((col_start * bpp) >> 3);
uint32_t bit_ofs = (row_start * width_bit) + (col_start * g.bpp);
map_p += bit_ofs>> 3;
uint8_t letter_px;
lv_opa_t px_opa;
uint16_t col_bit;
col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */
for(row = row_start; row < row_end; row++) {
col_byte_cnt = 0;
col_bit = (col_start * bpp) % 8;
mask = mask_init >> col_bit;
bitmask = bitmask_init >> col_bit;
for(col = col_start; col < col_end; col++) {
letter_px = (*map_p & mask) >> (8 - col_bit - bpp);
letter_px = (*map_p & bitmask) >> (8 - col_bit - g.bpp);
if(letter_px != 0) {
if(opa == LV_OPA_COVER) {
px_opa = bpp == 8 ? letter_px : bpp_opa_table[letter_px];
px_opa = g.bpp == 8 ? letter_px : bpp_opa_table[letter_px];
} else {
px_opa = bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8
px_opa = g.bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8
: (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8;
}
@ -351,18 +349,19 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
vdb_buf_tmp++;
if(col_bit < 8 - bpp) {
col_bit += bpp;
mask = mask >> bpp;
if(col_bit < 8 - g.bpp) {
col_bit += g.bpp;
bitmask = bitmask >> g.bpp;
} else {
col_bit = 0;
col_byte_cnt++;
mask = mask_init;
bitmask = bitmask_init;
map_p++;
}
}
col_bit += ((g.box_w - col_end) + col_start) * g.bpp;
map_p += (width_byte_bpp)-col_byte_cnt;
map_p += (col_bit >> 3);
col_bit = col_bit & 0x7;
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
}
}

View File

@ -70,7 +70,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
w = p.x;
}
lv_coord_t line_height = lv_font_get_height(font) + style->text.line_space;
lv_coord_t line_height = lv_font_get_line_height(font) + style->text.line_space;
/*Init variables for the first line*/
lv_coord_t line_width = 0;
@ -136,8 +136,10 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
cmd_state = CMD_STATE_WAIT;
i = line_start;
uint32_t letter;
uint32_t letter_next;
while(i < line_end) {
letter = lv_txt_encoded_next(txt, &i);
letter_next = lv_txt_encoded_next(&txt[i], NULL);
/*Handle the re-color command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
@ -181,7 +183,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
if(cmd_state == CMD_STATE_IN) color = recolor;
letter_w = lv_font_get_width(font, letter);
letter_w = lv_font_get_glyph_width(font, letter, letter_next);
if(sel_start != 0xFFFF && sel_end != 0xFFFF) {
int char_ind = lv_encoded_get_char_id(txt, i);

View File

@ -1,165 +0,0 @@
/**
* @file lv_font_built_in.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_font_builtin.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the built-in fonts
*/
void lv_font_builtin_init(void)
{
/*DEJAVU 10*/
#if LV_USE_FONT_DEJAVU_10 != 0
lv_font_add(&lv_font_dejavu_10, NULL);
#endif
#if LV_USE_FONT_DEJAVU_10_LATIN_SUP != 0
#if LV_USE_FONT_DEJAVU_10 != 0
lv_font_add(&lv_font_dejavu_10_latin_sup, &lv_font_dejavu_10);
#else
lv_font_add(&lv_font_dejavu_10_latin_sup, NULL);
#endif
#endif
#if LV_USE_FONT_DEJAVU_10_CYRILLIC != 0
#if LV_USE_FONT_DEJAVU_10 != 0
lv_font_add(&lv_font_dejavu_10_cyrillic, &lv_font_dejavu_10);
#else
lv_font_add(&lv_font_dejavu_10_cyrillic, NULL);
#endif
#endif
/*SYMBOL 10*/
#if LV_USE_FONT_SYMBOL_10 != 0
#if LV_USE_FONT_DEJAVU_10 != 0
lv_font_add(&lv_font_symbol_10, &lv_font_dejavu_10);
#else
lv_font_add(&lv_font_symbol_10, NULL);
#endif
#endif
/*DEJAVU 20*/
#if LV_USE_FONT_DEJAVU_20 != 0
lv_font_add(&lv_font_dejavu_20, NULL);
#endif
#if LV_USE_FONT_DEJAVU_20_LATIN_SUP != 0
#if LV_USE_FONT_DEJAVU_20 != 0
lv_font_add(&lv_font_dejavu_20_latin_sup, &lv_font_dejavu_20);
#else
lv_font_add(&lv_font_symbol_20_latin_sup, NULL);
#endif
#endif
#if LV_USE_FONT_DEJAVU_20_CYRILLIC != 0
#if LV_USE_FONT_DEJAVU_20 != 0
lv_font_add(&lv_font_dejavu_20_cyrillic, &lv_font_dejavu_20);
#else
lv_font_add(&lv_font_dejavu_20_cyrillic, NULL);
#endif
#endif
/*SYMBOL 20*/
#if LV_USE_FONT_SYMBOL_20 != 0
#if LV_USE_FONT_DEJAVU_20 != 0
lv_font_add(&lv_font_symbol_20, &lv_font_dejavu_20);
#else
lv_font_add(&lv_font_symbol_20, NULL);
#endif
#endif
/*DEJAVU 30*/
#if LV_USE_FONT_DEJAVU_30 != 0
lv_font_add(&lv_font_dejavu_30, NULL);
#endif
#if LV_USE_FONT_DEJAVU_30_LATIN_SUP != 0
#if LV_USE_FONT_DEJAVU_30 != 0
lv_font_add(&lv_font_dejavu_30_latin_sup, &lv_font_dejavu_30);
#else
lv_font_add(&lv_font_dejavu_30_latin_sup, NULL);
#endif
#endif
#if LV_USE_FONT_DEJAVU_30_CYRILLIC != 0
#if LV_USE_FONT_DEJAVU_30 != 0
lv_font_add(&lv_font_dejavu_30_cyrillic, &lv_font_dejavu_30);
#else
lv_font_add(&lv_font_dejavu_30_cyrillic, NULL);
#endif
#endif
/*SYMBOL 30*/
#if LV_USE_FONT_SYMBOL_30 != 0
#if LV_USE_FONT_DEJAVU_30 != 0
lv_font_add(&lv_font_symbol_30, &lv_font_dejavu_30);
#else
lv_font_add(&lv_font_symbol_30, NULL);
#endif
#endif
/*DEJAVU 40*/
#if LV_USE_FONT_DEJAVU_40 != 0
lv_font_add(&lv_font_dejavu_40, NULL);
#endif
#if LV_USE_FONT_DEJAVU_40_LATIN_SUP != 0
#if LV_USE_FONT_DEJAVU_40 != 0
lv_font_add(&lv_font_dejavu_40_latin_sup, &lv_font_dejavu_40);
#else
lv_font_add(&lv_font_dejavu_40_latin_sup, NULL);
#endif
#endif
#if LV_USE_FONT_DEJAVU_40_CYRILLIC != 0
#if LV_USE_FONT_DEJAVU_40 != 0
lv_font_add(&lv_font_dejavu_40_cyrillic, &lv_font_dejavu_40);
#else
lv_font_add(&lv_font_dejavu_40_cyrillic, NULL);
#endif
#endif
/*SYMBOL 40*/
#if LV_USE_FONT_SYMBOL_40 != 0
#if LV_USE_FONT_DEJAVU_40 != 0
lv_font_add(&lv_font_symbol_40, &lv_font_dejavu_40);
#else
lv_font_add(&lv_font_symbol_40, NULL);
#endif
#endif
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -1,125 +0,0 @@
/**
* @file lv_font_builtin.h
*
*/
#ifndef LV_FONT_BUILTIN_H
#define LV_FONT_BUILTIN_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../../lv_conf.h"
#endif
#include "../lv_misc/lv_font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the built-in fonts
*/
void lv_font_builtin_init(void);
/**********************
* MACROS
**********************/
/**********************
* FONT DECLARATIONS
**********************/
/*10 px */
#if LV_USE_FONT_DEJAVU_10
LV_FONT_DECLARE(lv_font_dejavu_10)
#endif
#if LV_USE_FONT_DEJAVU_10_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_10_latin_sup)
#endif
#if LV_USE_FONT_DEJAVU_10_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_10_cyrillic)
#endif
#if LV_USE_FONT_SYMBOL_10
LV_FONT_DECLARE(lv_font_symbol_10)
#endif
/*20 px */
#if LV_USE_FONT_DEJAVU_20
LV_FONT_DECLARE(lv_font_dejavu_20)
#endif
#if LV_USE_FONT_DEJAVU_20_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_20_latin_sup)
#endif
#if LV_USE_FONT_DEJAVU_20_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_20_cyrillic)
#endif
#if LV_USE_FONT_SYMBOL_20
LV_FONT_DECLARE(lv_font_symbol_20)
#endif
/*30 px */
#if LV_USE_FONT_DEJAVU_30
LV_FONT_DECLARE(lv_font_dejavu_30)
#endif
#if LV_USE_FONT_DEJAVU_30_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_30_latin_sup)
#endif
#if LV_USE_FONT_DEJAVU_30_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_30_cyrillic)
#endif
#if LV_USE_FONT_SYMBOL_30
LV_FONT_DECLARE(lv_font_symbol_30)
#endif
/*40 px */
#if LV_USE_FONT_DEJAVU_40
LV_FONT_DECLARE(lv_font_dejavu_40)
#endif
#if LV_USE_FONT_DEJAVU_40_LATIN_SUP
LV_FONT_DECLARE(lv_font_dejavu_40_latin_sup)
#endif
#if LV_USE_FONT_DEJAVU_40_CYRILLIC
LV_FONT_DECLARE(lv_font_dejavu_40_cyrillic)
#endif
#if LV_USE_FONT_SYMBOL_40
LV_FONT_DECLARE(lv_font_symbol_40)
#endif
#if LV_USE_FONT_MONOSPACE_8
LV_FONT_DECLARE(lv_font_monospace_8)
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_FONT_BUILTIN_H*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,8 +23,6 @@
* STATIC PROTOTYPES
**********************/
static int32_t lv_font_codeCompare(const void * pRef, const void * pElement);
/**********************
* STATIC VARIABLES
**********************/
@ -41,256 +39,46 @@ static int32_t lv_font_codeCompare(const void * pRef, const void * pElement);
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the fonts
*/
void lv_font_init(void)
{
lv_font_builtin_init();
}
/**
* Add a font to an other to extend the character set.
* @param child the font to add
* @param parent this font will be extended. Using it later will contain the characters from `child`
*/
void lv_font_add(lv_font_t * child, lv_font_t * parent)
{
if(parent == NULL) return;
while(parent->next_page != NULL) {
parent = parent->next_page; /*Got to the last page and add the new font there*/
}
parent->next_page = child;
}
/**
* Remove a font from a character set.
* @param child the font to remove
* @param parent remove `child` from here
*/
void lv_font_remove(lv_font_t * child, lv_font_t * parent)
{
if(parent == NULL) return;
if(child == NULL) return;
while(parent->next_page != child) {
parent = parent->next_page; /*Got to the last page and add the new font there*/
}
parent->next_page = child->next_page;
}
/**
* Tells if font which contains `letter` is monospace or not
* @param font_p point to font
* @param letter an UNICODE character code
* @return true: the letter is monospace; false not monospace
*/
bool lv_font_is_monospace(const lv_font_t * font_p, uint32_t letter)
{
const lv_font_t * font_i = font_p;
int16_t w;
while(font_i != NULL) {
w = font_i->get_width(font_i, letter);
if(w >= 0) {
/*Glyph found*/
if(font_i->monospace) return true;
return false;
}
font_i = font_i->next_page;
}
return 0;
}
/**
* Return with the bitmap of a font.
* @param font_p pointer to a font
* @param letter an UNICODE character code
* @return pointer to the bitmap of the letter
*/
const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter)
const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter)
{
const lv_font_t * font_i = font_p;
while(font_i != NULL) {
const uint8_t * bitmap = font_i->get_bitmap(font_i, letter);
if(bitmap) return bitmap;
font_i = font_i->next_page;
}
return NULL;
return font_p->get_glyph_bitmap(font_p, letter);
}
/**
* Get the width of a letter in a font. If `monospace` is set then return with it.
* @param font_p pointer to a font
* @param letter an UNICODE character code
* @return the width of a letter
* 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`
*/
uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter)
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)
{
const lv_font_t * font_i = font_p;
int16_t w;
while(font_i != NULL) {
w = font_i->get_width(font_i, letter);
if(w >= 0) {
/*Glyph found*/
uint8_t m = font_i->monospace;
if(m) w = m;
return w;
}
font_i = font_i->next_page;
}
return 0;
return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next);
}
/**
* Get the width of the letter without overwriting it with the `monospace` attribute
* @param font_p pointer to a font
* @param letter an UNICODE character code
* @return the width of a letter
* 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
*/
uint8_t lv_font_get_real_width(const lv_font_t * font_p, uint32_t letter)
uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next)
{
const lv_font_t * font_i = font_p;
int16_t w;
while(font_i != NULL) {
w = font_i->get_width(font_i, letter);
if(w >= 0) return w;
font_i = font_i->next_page;
}
return 0;
}
/**
* 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)
*/
uint8_t lv_font_get_bpp(const lv_font_t * font, uint32_t letter)
{
const lv_font_t * font_i = font;
while(font_i != NULL) {
if(letter >= font_i->unicode_first && letter <= font_i->unicode_last) {
return font_i->bpp;
}
font_i = font_i->next_page;
}
return 0;
}
/**
* 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)
{
/*Check the range*/
if(unicode_letter < font->unicode_first || unicode_letter > font->unicode_last) return NULL;
uint32_t index = (unicode_letter - font->unicode_first);
return &font->glyph_bitmap[font->glyph_dsc[index].glyph_index];
}
/**
* 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)
{
/*Check the range*/
if(unicode_letter < font->unicode_first || unicode_letter > font->unicode_last) return NULL;
uint32_t * pUnicode;
pUnicode = lv_utils_bsearch(&unicode_letter, (uint32_t *)font->unicode_list, font->glyph_cnt,
sizeof(uint32_t), lv_font_codeCompare);
if(pUnicode != NULL) {
uint32_t idx = (uint32_t)(pUnicode - font->unicode_list);
return &font->glyph_bitmap[font->glyph_dsc[idx].glyph_index];
}
return NULL;
}
/**
* Generic glyph width get function used in 'font->get_width' when the font contains all characters
* in the range
* @param font pointer to font
* @param unicode_letter an unicode letter which width should be get
* @return width of the gylph or -1 if not found
*/
int16_t lv_font_get_width_continuous(const lv_font_t * font, uint32_t unicode_letter)
{
/*Check the range*/
if(unicode_letter < font->unicode_first || unicode_letter > font->unicode_last) {
return -1;
}
uint32_t index = (unicode_letter - font->unicode_first);
return font->glyph_dsc[index].w_px;
}
/**
* Generic glyph width 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 width should be get
* @return width of the glyph or -1 if not found
*/
int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter)
{
/*Check the range*/
if(unicode_letter < font->unicode_first || unicode_letter > font->unicode_last) return -1;
uint32_t * pUnicode;
pUnicode = lv_utils_bsearch(&unicode_letter, (uint32_t *)font->unicode_list, font->glyph_cnt,
sizeof(uint32_t), lv_font_codeCompare);
if(pUnicode != NULL) {
uint32_t idx = (uint32_t)(pUnicode - font->unicode_list);
return font->glyph_dsc[idx].w_px;
}
return -1;
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;
}
/**********************
* STATIC FUNCTIONS
**********************/
/** Code Comparator.
*
* Compares the value of both input arguments.
*
* @param[in] pRef Pointer to the reference.
* @param[in] pElement Pointer to the element to compare.
*
* @return Result of comparison.
* @retval < 0 Reference is greater than element.
* @retval = 0 Reference is equal to element.
* @retval > 0 Reference is less than element.
*
*/
static int32_t lv_font_codeCompare(const void * pRef, const void * pElement)
{
return (*(uint32_t *)pRef) - (*(uint32_t *)pElement);
}

View File

@ -28,159 +28,100 @@ extern "C" {
/*********************
* DEFINES
*********************/
/*Number of fractional digits in the advanced width (`adv_w`) field of `lv_font_glyph_dsc_t`*/
#define LV_FONT_WIDTH_FRACT_DIGIT 4
#define LV_FONT_KERN_POSITIVE 0
#define LV_FONT_KERN_NEGATIVE 1
/**********************
* TYPEDEFS
**********************/
/*------------------
* General types
*-----------------*/
/*Describe the properties of a glyph*/
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;
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*/
uint8_t bpp; /*Bit-per-pixel: 1, 2, 4, 8*/
}lv_font_glyph_dsc_t;
/*Describe the properties of a font*/
typedef struct _lv_font_struct
{
uint32_t unicode_first;
uint32_t unicode_last;
const uint8_t * glyph_bitmap;
const lv_font_glyph_dsc_t * glyph_dsc;
const uint32_t * unicode_list;
const uint8_t * (*get_bitmap)(const struct _lv_font_struct *,
uint32_t); /*Get a glyph's bitmap from a font*/
int16_t (*get_width)(const struct _lv_font_struct *,
uint32_t); /*Get a glyph's with with a given font*/
struct _lv_font_struct * next_page; /*Pointer to a font extension*/
uint32_t h_px : 8;
uint32_t bpp : 4; /*Bit per pixel: 1, 2 or 4*/
uint32_t monospace : 8; /*Fix width (0: normal width)*/
uint16_t glyph_cnt; /*Number of glyphs (letters) in the font*/
/*Get a glyph's descriptor from a font*/
bool (*get_glyph_dsc)(const struct _lv_font_struct *, lv_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next);
/*Get a glyph's bitmap from a font*/
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*/
void * dsc; /*Store implementation specific data here*/
#if LV_USE_USER_DATA
lv_font_user_data_t user_data;
#endif
} lv_font_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the fonts
*/
void lv_font_init(void);
/**
* Add a font to an other to extend the character set.
* @param child the font to add
* @param parent this font will be extended. Using it later will contain the characters from `child`
*/
void lv_font_add(lv_font_t * child, lv_font_t * parent);
/**
* Remove a font from a character set.
* @param child the font to remove
* @param parent remove `child` from here
*/
void lv_font_remove(lv_font_t * child, lv_font_t * parent);
/**
* Tells if font which contains `letter` is monospace or not
* @param font_p point to font
* @param letter an UNICODE character code
* @return true: the letter is monospace; false not monospace
*/
bool lv_font_is_monospace(const lv_font_t * font_p, uint32_t letter);
/**
* Return with the bitmap of a font.
* @param font_p pointer to a font
* @param letter an UNICODE character code
* @return pointer to the bitmap of the letter
*/
const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter);
const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter);
/**
* Get the width of a letter in a font. If `monospace` is set then return with it.
* @param font_p pointer to a font
* @param letter an UNICODE character code
* @return the width of a letter
* 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`
*/
uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter);
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);
/**
* Get the width of the letter without overwriting it with the `monospace` attribute
* @param font_p pointer to a font
* @param letter an UNICODE character code
* @return the width of a letter
* 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
*/
uint8_t lv_font_get_real_width(const lv_font_t * font_p, uint32_t letter);
uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next);
/**
* Get the height of a font
* Get the line height of a font. All characters fit into this height
* @param font_p pointer to a font
* @return the height of a font
*/
static inline uint8_t lv_font_get_height(const lv_font_t * font_p)
static inline uint8_t lv_font_get_line_height(const lv_font_t * font_p)
{
return font_p->h_px;
return font_p->line_height;
}
/**
* 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)
*/
uint8_t lv_font_get_bpp(const 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);
/**
* Generic glyph width get function used in 'font->get_width' when the font contains all characters
* in the range
* @param font pointer to font
* @param unicode_letter an unicode letter which width should be get
* @return width of the gylph or -1 if not found
*/
int16_t lv_font_get_width_continuous(const lv_font_t * font, uint32_t unicode_letter);
/**
* Generic glyph width 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 width should be get
* @return width of the glyph or -1 if not found
*/
int16_t lv_font_get_width_sparse(const lv_font_t * font, uint32_t unicode_letter);
/**********************
* MACROS
**********************/
#define LV_FONT_DECLARE(font_name) extern lv_font_t font_name;
/**********************
* ADD BUILT IN FONTS
**********************/
#include "../lv_fonts/lv_font_builtin.h"
LV_FONT_DECLARE(lv_font_roboto_12)
LV_FONT_DECLARE(lv_font_roboto_16)
LV_FONT_DECLARE(lv_font_roboto_22)
LV_FONT_DECLARE(lv_font_roboto_28)
/*Declare the custom (user defined) fonts*/
#ifdef LV_FONT_CUSTOM_DECLARE

View File

@ -0,0 +1,219 @@
/**
* @file lv_font.c
*
*/
/*********************
* INCLUDES
*********************/
#include "../lv_font.h"
#include "../lv_log.h"
#include "../lv_utils.h"
#include "lv_font_fmt_txt.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter);
static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t gid_right);
static int32_t lv_font_codeCompare(const void * pRef, const void * pElement);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Used as `get_glyph_bitmap` callback in LittelvGL's native font format if the font is uncompressed.
* @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_fmt_txt(const lv_font_t * font, uint32_t unicode_letter)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
uint32_t gid = get_glyph_dsc_id(font, unicode_letter);
if(!gid) return false;
const lv_font_fmt_txt_glyph_dsc_t * gdsc = &fdsc->glyph_dsc[gid];
if(gdsc) return &fdsc->glyph_bitmap[gdsc->bitmap_index];
/*If not returned earlier then the letter is not found in this font*/
return NULL;
}
/**
* Used as `get_glyph_dsc` callback in LittelvGL's native font format if the font is uncompressed.
* @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`
*/
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)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
uint32_t gid = get_glyph_dsc_id(font, unicode_letter);
if(!gid) return false;
int8_t kvalue = 0;
const lv_font_fmt_txt_glyph_dsc_t * gdsc_next = NULL;
if(fdsc->kern_dsc) {
uint32_t gid_next = get_glyph_dsc_id(font, unicode_letter_next);
if(gid_next) {
gdsc_next = &fdsc->glyph_dsc[gid_next];
kvalue = get_kern_value(font, gid, gid_next);
}
}
/*Put together a glyph dsc*/
const lv_font_fmt_txt_glyph_dsc_t * gdsc = &fdsc->glyph_dsc[gid];
uint32_t adv_w = gdsc->adv_w + ((int32_t)((int32_t)kvalue * fdsc->kern_scale) >> 4);
adv_w = (adv_w + (1 << 3)) >> 4;
dsc_out->adv_w = adv_w;
dsc_out->box_h = gdsc->box_h;
dsc_out->box_w = gdsc->box_w;
dsc_out->ofs_x = gdsc->ofs_x;
dsc_out->ofs_y = gdsc->ofs_y;
dsc_out->bpp = fdsc->bpp;
return true;
}
/**********************
* STATIC FUNCTIONS
**********************/
static uint32_t get_glyph_dsc_id(const lv_font_t * font, uint32_t letter)
{
if(letter == '\0') return 0;
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
uint16_t i;
for(i = 0; i < fdsc->cmap_num; i++) {
/*Relative code point*/
uint32_t rcp = letter - fdsc->cmaps[i].range_start;
if(rcp > fdsc->cmaps[i].range_length) continue;
uint32_t glyph_id = 0;
if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY) {
glyph_id = fdsc->cmaps[i].glyph_id_start + rcp;
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL) {
const uint8_t * gid_ofs_8 = fdsc->cmaps[i].glyph_id_ofs_list;
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_8[rcp];
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) {
uint32_t u;
for(u = 0; u < fdsc->cmaps[i].list_length; u++) {
if(fdsc->cmaps[i].unicode_list[u] == rcp) {
glyph_id = fdsc->cmaps[i].glyph_id_start + u;
}
}
}
else if(fdsc->cmaps[i].type == LV_FONT_FMT_TXT_CMAP_SPARSE_TINY) {
const uint8_t * gid_ofs_16 = fdsc->cmaps[i].glyph_id_ofs_list;
uint32_t u;
for(u = 0; u < 50 /*fdsc->cmaps[i].list_length*/; u++) {
if(fdsc->cmaps[i].unicode_list[u] == rcp) {
glyph_id = fdsc->cmaps[i].glyph_id_start + u;
}
glyph_id = fdsc->cmaps[i].glyph_id_start + gid_ofs_16[u];
}
}
return glyph_id;
}
return 0;
}
static int8_t get_kern_value(const lv_font_t * font, uint32_t gid_left, uint32_t gid_right)
{
lv_font_fmt_txt_dsc_t * fdsc = (lv_font_fmt_txt_dsc_t *) font->dsc;
int8_t value = 0;
uint32_t k;
if(fdsc->kern_classes == 0) {
/*Kern pairs*/
const lv_font_fmt_txt_kern_pair_t * kdsc = fdsc->kern_dsc;
if(kdsc->glyph_ids_size == 0) {
const uint8_t * g_ids = kdsc->glyph_ids;
for(k = 0; k < (uint32_t)kdsc->pair_cnt * 2; k += 2) {
if(g_ids[k] == gid_left &&
g_ids[k+1] == gid_right) {
value = kdsc->values[k >> 1];
break;
}
}
} else if(kdsc->glyph_ids_size == 1) {
const uint16_t * g_ids = kdsc->glyph_ids;
for(k = 0; k < (uint32_t)kdsc->pair_cnt * 2; k += 2) {
if(g_ids[k] == gid_left &&
g_ids[k+1] == gid_right) {
value = kdsc->values[k >> 1];
break;
}
}
} else {
/*Invalid value*/
}
} else {
/*Kern classes*/
const lv_font_fmt_txt_kern_classes_t * kdsc = fdsc->kern_dsc;
uint8_t left_class = kdsc->left_class_mapping[gid_left];
uint8_t right_class = kdsc->left_class_mapping[gid_right];
/* If class = 0, kerning not exist for that glyph
* else got the value form `class_pair_values` 2D array*/
if(left_class > 0 && right_class > 0) {
value = kdsc->class_pair_values[(left_class-1)* kdsc->right_class_cnt + (right_class-1)];
}
}
return value;
}
/** Code Comparator.
*
* Compares the value of both input arguments.
*
* @param[in] pRef Pointer to the reference.
* @param[in] pElement Pointer to the element to compare.
*
* @return Result of comparison.
* @retval < 0 Reference is greater than element.
* @retval = 0 Reference is equal to element.
* @retval > 0 Reference is less than element.
*
*/
static int32_t lv_font_codeCompare(const void * pRef, const void * pElement)
{
return (*(uint16_t *)pRef) - (*(uint16_t *)pElement);
}

View File

@ -0,0 +1,224 @@
/**
* @file lv_font.h
*
*/
#ifndef LV_FONT_FMT_TXT_H
#define LV_FONT_FMT_TXT_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#ifdef LV_CONF_INCLUDE_SIMPLE
#include "lv_conf.h"
#else
#include "../../../../lv_conf.h"
#endif
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "../lv_font.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Describe a glyph*/
typedef struct
{
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. 12.4 format (real_value * 16 is stored). */
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*/
uint8_t ofs_y; /*y offset of the bounding box. Measured from the top of the line*/
}lv_font_fmt_txt_glyph_dsc_t;
typedef enum {
LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY,
LV_FONT_FMT_TXT_CMAP_FORMAT0_FULL,
LV_FONT_FMT_TXT_CMAP_SPARSE_TINY,
LV_FONT_FMT_TXT_CMAP_SPARSE_FULL,
}lv_font_fmt_txt_cmap_type_t;
/* Map codepoints to a `glyph_dsc`s
* Several formats are supported to optimize memory usage
* See https://github.com/littlevgl/lv_font_conv/blob/master/doc/font_spec.md
*/
typedef struct {
/* First Unicode character for this range */
uint32_t range_start;
/* Number of Unicode characters related to this range.
* Last Unicode character = range_start + range_length - 1*/
uint16_t range_length;
/* First glyph ID (array index of `glyph_dsc`) for this range */
uint16_t glyph_id_start;
/*
According the specification there are 4 formats:
https://github.com/littlevgl/lv_font_conv/blob/master/doc/font_spec.md
For simplicity introduce "relative code point":
rcp = codepoint - range_start
and a search function:
search a "value" in an "array" and returns the index of "value".
Format 0 tiny
unicode_list == NULL && glyph_id_ofs_list == NULL
glyph_id = glyph_id_start + rcp
Format 0 full
unicode_list == NULL && glyph_id_ofs_list != NULL
glyph_id = glyph_id_start + glyph_id_ofs_list[rcp]
Sparse tiny
unicode_list != NULL && glyph_id_ofs_list == NULL
glyph_id = glyph_id_start + search(unicode_list, rcp)
Sparse full
unicode_list != NULL && glyph_id_ofs_list != NULL
glyph_id = glyph_id_start + glyph_id_ofs_list[search(unicode_list, rcp)]
*/
uint16_t * unicode_list;
/* if(type == LV_FONT_FMT_TXT_CMAP_FORMAT0_...) it's `uint8_t *`
* if(type == LV_FONT_FMT_TXT_CMAP_SPARSE_...) it's `uint16_t *`
*/
const void * glyph_id_ofs_list;
/*Length of `unicode_list` and/or `glyph_id_ofs_list`*/
uint16_t list_length;
/*Type of this character map*/
lv_font_fmt_txt_cmap_type_t type :2;
}lv_font_fmt_txt_cmap_t;
/*A simple mapping of kern values from pairs*/
typedef struct {
/*To get a kern value of two code points:
1. Get the `glyph_id_left` and `glyph_id_right` from `lv_font_fmt_txt_cmap_t
2 for(i = 0; i < pair_cnt * 2; i+2)
if(gylph_ids[i] == glyph_id_left &&
gylph_ids[i+1] == glyph_id_right)
return values[i / 2];
*/
const void * glyph_ids;
const int8_t * values;
uint32_t pair_cnt :24;
uint32_t glyph_ids_size :2; /*0: `glyph_ids` is stored as `uint8_t`; 1: as `uint16_t`*/
}lv_font_fmt_txt_kern_pair_t;
/*More complex but more optimal class based kern value storage*/
typedef struct {
/*To get a kern value of two code points:
1. Get the `glyph_id_left` and `glyph_id_right` from `lv_font_fmt_txt_cmap_t
2 Get the class of the left and right glyphs as `left_class` and `right_class`
left_class = left_class_mapping[glyph_id_left];
right_class = right_class_mapping[glyph_id_right];
3. value = class_pair_values[(left_class-1)*right_class_cnt + (righ_class-1)]
*/
const uint8_t * class_pair_values; /*left_class_num * right_class_num value*/
const uint8_t * left_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/
const uint8_t * right_class_mapping; /*Map the glyph_ids to classes: index -> glyph_id -> class_id*/
uint8_t left_class_cnt;
uint8_t right_class_cnt;
}lv_font_fmt_txt_kern_classes_t;
/*Bitmap formats*/
typedef enum {
LV_FONT_FMT_TXT_PLAIN = 0,
LV_FONT_FMT_TXT_COMPRESSED = 1,
}lv_font_fmt_txt_bitmap_format_t;
/*Describe store additional data for fonts */
typedef struct {
/*The bitmaps os all glyphs*/
const uint8_t * glyph_bitmap;
/*Describe the glyphs*/
const lv_font_fmt_txt_glyph_dsc_t * glyph_dsc;
/* Map the glyphs to Unicode characters.
* Array of `lv_font_cmap_fmt_txt_t` variables*/
const lv_font_fmt_txt_cmap_t * cmaps;
/* Store kerning values.
* Can be `lv_font_fmt_txt_kern_pair_t * or `lv_font_kern_classes_fmt_txt_t *`
* depending on `kern_classes`
*/
const void * kern_dsc;
/*Scale kern values in 12.4 format*/
uint16_t kern_scale;
/*Number of cmap tables*/
uint16_t cmap_num :10;
/*Bit per pixel: 1, 2, 4 or 8*/
uint16_t bpp :3;
/*Type of `kern_dsc`*/
uint16_t kern_classes :1;
/*
* storage format of the bitmap
* from `lv_font_fmt_txt_bitmap_format_t`
*/
uint16_t bitmap_format :2;
}lv_font_fmt_txt_dsc_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Used as `get_glyph_bitmap` callback in LittelvGL's native font format if the font is uncompressed.
* @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_fmt_txt(const lv_font_t * font, uint32_t letter);
/**
* Used as `get_glyph_dsc` callback in LittelvGL's native font format if the font is uncompressed.
* @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`
*/
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);
/**********************
* MACROS
**********************/
/**********************
* ADD BUILT IN FONTS
**********************/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_FONT_FMT_TXT_H*/

View File

@ -12,60 +12,61 @@ extern "C" {
#endif
#define LV_SYMBOL_GLYPH_FIRST 0xF800
#define LV_SYMBOL_AUDIO "\xEF\xA0\x80"
#define LV_SYMBOL_VIDEO "\xEF\xA0\x81"
#define LV_SYMBOL_LIST "\xEF\xA0\x82"
#define LV_SYMBOL_OK "\xEF\xA0\x83"
#define LV_SYMBOL_CLOSE "\xEF\xA0\x84"
#define LV_SYMBOL_POWER "\xEF\xA0\x85"
#define LV_SYMBOL_SETTINGS "\xEF\xA0\x86"
#define LV_SYMBOL_TRASH "\xEF\xA0\x87"
#define LV_SYMBOL_HOME "\xEF\xA0\x88"
#define LV_SYMBOL_DOWNLOAD "\xEF\xA0\x89"
#define LV_SYMBOL_DRIVE "\xEF\xA0\x8A"
#define LV_SYMBOL_REFRESH "\xEF\xA0\x8B"
#define LV_SYMBOL_MUTE "\xEF\xA0\x8C"
#define LV_SYMBOL_VOLUME_MID "\xEF\xA0\x8D"
#define LV_SYMBOL_VOLUME_MAX "\xEF\xA0\x8E"
#define LV_SYMBOL_IMAGE "\xEF\xA0\x8F"
#define LV_SYMBOL_EDIT "\xEF\xA0\x90"
#define LV_SYMBOL_PREV "\xEF\xA0\x91"
#define LV_SYMBOL_PLAY "\xEF\xA0\x92"
#define LV_SYMBOL_PAUSE "\xEF\xA0\x93"
#define LV_SYMBOL_STOP "\xEF\xA0\x94"
#define LV_SYMBOL_NEXT "\xEF\xA0\x95"
#define LV_SYMBOL_EJECT "\xEF\xA0\x96"
#define LV_SYMBOL_LEFT "\xEF\xA0\x97"
#define LV_SYMBOL_RIGHT "\xEF\xA0\x98"
#define LV_SYMBOL_PLUS "\xEF\xA0\x99"
#define LV_SYMBOL_MINUS "\xEF\xA0\x9A"
#define LV_SYMBOL_WARNING "\xEF\xA0\x9B"
#define LV_SYMBOL_SHUFFLE "\xEF\xA0\x9C"
#define LV_SYMBOL_UP "\xEF\xA0\x9D"
#define LV_SYMBOL_DOWN "\xEF\xA0\x9E"
#define LV_SYMBOL_LOOP "\xEF\xA0\x9F"
#define LV_SYMBOL_DIRECTORY "\xEF\xA0\xA0"
#define LV_SYMBOL_UPLOAD "\xEF\xA0\xA1"
#define LV_SYMBOL_CALL "\xEF\xA0\xA2"
#define LV_SYMBOL_CUT "\xEF\xA0\xA3"
#define LV_SYMBOL_COPY "\xEF\xA0\xA4"
#define LV_SYMBOL_SAVE "\xEF\xA0\xA5"
#define LV_SYMBOL_CHARGE "\xEF\xA0\xA6"
#define LV_SYMBOL_BELL "\xEF\xA0\xA7"
#define LV_SYMBOL_KEYBOARD "\xEF\xA0\xA8"
#define LV_SYMBOL_GPS "\xEF\xA0\xA9"
#define LV_SYMBOL_FILE "\xEF\xA0\xAA"
#define LV_SYMBOL_WIFI "\xEF\xA0\xAB"
#define LV_SYMBOL_BATTERY_FULL "\xEF\xA0\xAC"
#define LV_SYMBOL_BATTERY_3 "\xEF\xA0\xAD"
#define LV_SYMBOL_BATTERY_2 "\xEF\xA0\xAE"
#define LV_SYMBOL_BATTERY_1 "\xEF\xA0\xAF"
#define LV_SYMBOL_BATTERY_EMPTY "\xEF\xA0\xB0"
#define LV_SYMBOL_BLUETOOTH "\xEF\xA0\xB1"
#define LV_SYMBOL_GLYPH_LAST 0xF831
#define LV_SYMBOL_AUDIO "\xef\x80\x81"
#define LV_SYMBOL_VIDEO "\xef\x80\x88"
#define LV_SYMBOL_LIST "\xef\x80\x8b"
#define LV_SYMBOL_OK "\xef\x80\x8c"
#define LV_SYMBOL_CLOSE "\xef\x80\x8d"
#define LV_SYMBOL_POWER "\xef\x80\x91"
#define LV_SYMBOL_SETTINGS "\xef\x80\x93"
#define LV_SYMBOL_TRASH "\xef\x80\x94"
#define LV_SYMBOL_HOME "\xef\x80\x95"
#define LV_SYMBOL_DOWNLOAD "\xef\x80\x99"
#define LV_SYMBOL_DRIVE "\xef\x80\x9c"
#define LV_SYMBOL_REFRESH "\xef\x80\xa1"
#define LV_SYMBOL_MUTE "\xef\x80\xa6"
/*Invalid symbol at (U+F831). If written before a string then `lv_img` will show it as a label*/
#define LV_SYMBOL_VOLUME_MID "\xef\x80\xa7"
#define LV_SYMBOL_VOLUME_MAX "\xef\x80\xa8"
#define LV_SYMBOL_IMAGE "\xef\x80\xbe"
#define LV_SYMBOL_EDIT "\xef\x81\x80"
#define LV_SYMBOL_PREV "\xef\x81\x88"
#define LV_SYMBOL_PLAY "\xef\x81\x8b"
#define LV_SYMBOL_PAUSE "\xef\x81\x8c"
#define LV_SYMBOL_STOP "\xef\x81\x8d"
#define LV_SYMBOL_NEXT "\xef\x81\x91"
#define LV_SYMBOL_EJECT "\xef\x81\x92"
#define LV_SYMBOL_LEFT "\xef\x81\x93"
#define LV_SYMBOL_RIGHT "\xef\x81\x94"
#define LV_SYMBOL_PLUS "\xef\x81\xa7"
#define LV_SYMBOL_MINUS "\xef\x81\xa8"
#define LV_SYMBOL_WARNING "\xef\x81\xb1"
#define LV_SYMBOL_SHUFFLE "\xef\x81\xb4"
#define LV_SYMBOL_UP "\xef\x81\xb7"
#define LV_SYMBOL_DOWN "\xef\x81\xb8"
#define LV_SYMBOL_LOOP "\xef\x81\xb9"
#define LV_SYMBOL_DIRECTORY "\xef\x81\xbb"
#define LV_SYMBOL_UPLOAD "\xef\x82\x93"
#define LV_SYMBOL_CALL "\xef\x82\x95"
#define LV_SYMBOL_CUT "\xef\x83\x84"
#define LV_SYMBOL_COPY "\xef\x83\x85"
#define LV_SYMBOL_SAVE "\xef\x83\x87"
#define LV_SYMBOL_CHARGE "\xef\x83\xa7"
#define LV_SYMBOL_BELL "\xef\x83\xb3"
#define LV_SYMBOL_KEYBOARD "\xef\x84\x9c"
#define LV_SYMBOL_GPS "\xef\x84\xa4"
#define LV_SYMBOL_FILE "\xef\x85\x9b"
#define LV_SYMBOL_WIFI "\xef\x87\xab"
#define LV_SYMBOL_BATTERY_FULL "\xef\x89\x80"
#define LV_SYMBOL_BATTERY_3 "\xef\x89\x81"
#define LV_SYMBOL_BATTERY_2 "\xef\x89\x82"
#define LV_SYMBOL_BATTERY_1 "\xef\x89\x83"
#define LV_SYMBOL_BATTERY_EMPTY "\xef\x89\x84"
#define LV_SYMBOL_BLUETOOTH "\xef\x8a\x93"
/*Invalid symbol at (U+F8FF). If written before a string then `lv_img` will show it as a label*/
#define LV_SYMBOL_DUMMY "\xEF\xA3\xBF"
/*

View File

@ -119,7 +119,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_height(font);
uint8_t letter_height = lv_font_get_line_height(font);
/*Calc. the height and longest line*/
while(text[line_start] != '\0') {
@ -173,11 +173,13 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord
uint32_t n_char_since_last_break = 0; /* Used count word length of long words */
uint32_t last_break = NO_BREAK_FOUND;
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
uint32_t letter = 0;
uint32_t letter;
uint32_t letter_next;
while(txt[i] != '\0') {
lv_coord_t letter_width;
letter = lv_txt_encoded_next(txt, &i);
letter_next = lv_txt_encoded_next(&txt[i], NULL);
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
@ -196,7 +198,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord
} else { /*Check the actual length*/
n_char_since_last_break++;
letter_width = lv_font_get_width(font, letter);
letter_width = lv_font_get_glyph_width(font, letter, letter_next);
cur_w += letter_width;
/* Get the length of the current work and determine best place
@ -210,12 +212,12 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord
i = last_break;
} else {
uint32_t i_tmp = i;
cur_w -=
w_at_last_break +
letter_space; /*ignore the first letter_space after the break char */
/*ignore the first letter_space after the break char */
cur_w -= w_at_last_break + letter_space;
bool other = true;
while(txt[i_tmp] != '\0') {
letter = lv_txt_encoded_next(txt, &i_tmp);
letter_next = lv_txt_encoded_next(&txt[i_tmp], NULL);
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
@ -242,7 +244,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord
break;
}
n_char_since_last_break++;
lv_coord_t letter_width2 = lv_font_get_width(font, letter);
lv_coord_t letter_width2 = lv_font_get_glyph_width(font, letter, letter_next);
cur_w += letter_width2;
if(cur_w > max_width) {
/* Current letter already exceeds, return previous */
@ -323,17 +325,19 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t *
lv_coord_t width = 0;
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
uint32_t letter;
uint32_t letter_next;
if(length != 0) {
while(i < length) {
letter = lv_txt_encoded_next(txt, &i);
letter_next = lv_txt_encoded_next(&txt[i], NULL);
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, letter) != false) {
continue;
}
}
lv_coord_t char_width = lv_font_get_width(font, letter);
lv_coord_t char_width = lv_font_get_glyph_width(font, letter, letter_next);
if(char_width > 0) {
width += char_width;
width += letter_space;

View File

@ -626,7 +626,7 @@ static lv_coord_t get_header_height(lv_obj_t * calendar)
{
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
return lv_font_get_height(ext->style_header->text.font) + ext->style_header->body.padding.top +
return lv_font_get_line_height(ext->style_header->text.font) + ext->style_header->body.padding.top +
ext->style_header->body.padding.bottom;
}
@ -639,7 +639,7 @@ static lv_coord_t get_day_names_height(lv_obj_t * calendar)
{
lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar);
return lv_font_get_height(ext->style_day_names->text.font) +
return lv_font_get_line_height(ext->style_day_names->text.font) +
ext->style_day_names->body.padding.top + ext->style_day_names->body.padding.bottom;
}
@ -704,7 +704,7 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask)
lv_area_t label_area;
label_area.y1 =
calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top;
label_area.y2 = label_area.y1 + lv_font_get_height(ext->style_day_names->text.font);
label_area.y2 = label_area.y1 + lv_font_get_line_height(ext->style_day_names->text.font);
uint32_t i;
for(i = 0; i < 7; i++) {
label_area.x1 = calendar->coords.x1 + (w * i) / 7 + l_pad;
@ -727,15 +727,15 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar);
label_area.y1 = calendar->coords.y1 + get_header_height(calendar) +
ext->style_day_names->body.padding.top +
lv_font_get_height(ext->style_day_names->text.font) +
lv_font_get_line_height(ext->style_day_names->text.font) +
ext->style_day_names->body.padding.bottom;
label_area.y2 = label_area.y1 + lv_font_get_height(style_bg->text.font);
label_area.y2 = label_area.y1 + lv_font_get_line_height(style_bg->text.font);
lv_coord_t w =
lv_obj_get_width(calendar) - style_bg->body.padding.left - style_bg->body.padding.right;
lv_coord_t h = calendar->coords.y2 - label_area.y1 - style_bg->body.padding.bottom;
lv_coord_t box_w = w / 7;
lv_coord_t vert_space = (h - (6 * lv_font_get_height(style_bg->text.font))) / 5;
lv_coord_t vert_space = (h - (6 * lv_font_get_line_height(style_bg->text.font))) / 5;
uint32_t week;
uint8_t day_cnt;
@ -856,8 +856,8 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask)
}
/*Got to the next weeks row*/
label_area.y1 += vert_space + lv_font_get_height(style_bg->text.font);
label_area.y2 += vert_space + lv_font_get_height(style_bg->text.font);
label_area.y1 += vert_space + lv_font_get_line_height(style_bg->text.font);
label_area.y2 += vert_space + lv_font_get_line_height(style_bg->text.font);
}
}

View File

@ -314,8 +314,8 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_STYLE_CHG) {
const lv_style_t * label_style = lv_label_get_style(ext->label);
lv_obj_set_size(ext->bullet, lv_font_get_height(label_style->text.font),
lv_font_get_height(label_style->text.font));
lv_obj_set_size(ext->bullet, lv_font_get_line_height(label_style->text.font),
lv_font_get_line_height(label_style->text.font));
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
} else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED ||
sign == LV_SIGNAL_PRESS_LOST) {

View File

@ -547,7 +547,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
if(ext->opened != 0 || ext->force_sel) {
const lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const lv_font_t * font = style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
/*Draw the selected*/
lv_area_t rect_area;
@ -572,7 +572,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
if(ext->opened || ext->force_sel) {
const lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const lv_font_t * font = style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_area_t area_sel;
area_sel.y1 = ext->label->coords.y1;
@ -604,7 +604,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
const lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const lv_font_t * font = style->text.font;
const lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_style_t new_style;
lv_style_copy(&new_style, style);
new_style.text.color = sel_style->text.color;
@ -869,7 +869,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
else {
const lv_font_t * font = style->text.font;
const lv_style_t * label_style = lv_obj_get_style(ext->label);
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
new_height = font_h + 2 * label_style->text.line_space;
lv_page_set_sb_mode(ddlist, LV_SB_MODE_HIDE);
@ -956,7 +956,7 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist)
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
const lv_style_t * style = lv_obj_get_style(ddlist);
const lv_font_t * font = style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
const lv_style_t * label_style = lv_obj_get_style(ext->label);
lv_obj_t * scrl = lv_page_get_scrl(ddlist);

View File

@ -465,7 +465,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t
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_height(font);
uint8_t letter_height = lv_font_get_line_height(font);
lv_coord_t y = 0;
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
@ -538,7 +538,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_height(font);
uint8_t letter_height = lv_font_get_line_height(font);
lv_coord_t y = 0;
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
@ -572,26 +572,36 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
}
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
uint32_t i = line_start;
uint32_t i_current = i;
uint32_t letter;
while(i <= new_line_start - 1) {
letter =
lv_txt_encoded_next(txt, &i); /*Be careful 'i' already points to the next character*/
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
continue; /*Skip the letter is it is part of a command*/
}
}
uint32_t letter_next;
x += lv_font_get_width(font, letter);
if(pos->x < x) {
i = i_current;
break;
if(new_line_start > 0) {
while(i <= new_line_start - 1) {
/* Get the current letter.
* Be careful 'i' already points to the next character*/
letter = lv_txt_encoded_next(txt, &i);
/*Get the next letter too for kerning*/
letter_next = lv_txt_encoded_next(&txt[i], NULL);
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
continue; /*Skip the letter is it is part of a command*/
}
}
x += lv_font_get_glyph_width(font, letter, letter_next);
if(pos->x < x) {
i = i_current;
break;
}
x += style->text.letter_space;
i_current = i;
}
x += style->text.letter_space;
i_current = i;
}
return lv_encoded_get_char_id(txt, i);
@ -643,7 +653,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_height(font);
uint8_t letter_height = lv_font_get_line_height(font);
lv_coord_t y = 0;
lv_txt_flag_t flag = LV_TXT_FLAG_NONE;
@ -678,29 +688,39 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos)
}
lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT;
uint32_t i = line_start;
uint32_t i_current = i;
uint32_t letter = 0;
while(i <= new_line_start - 1) {
letter =
lv_txt_encoded_next(txt, &i); /*Be careful 'i' already points to the next character*/
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
continue; /*Skip the letter is it is part of a command*/
uint32_t letter;
uint32_t letter_next;
if(new_line_start > 0) {
while(i <= new_line_start - 1) {
/* Get the current letter
* Be careful 'i' already points to the next character */
letter = lv_txt_encoded_next(txt, &i);
/*Get the next letter for kerning*/
letter_next = lv_txt_encoded_next(&txt[i], NULL);
/*Handle the recolor command*/
if((flag & LV_TXT_FLAG_RECOLOR) != 0) {
if(lv_txt_is_cmd(&cmd_state, txt[i]) != false) {
continue; /*Skip the letter is it is part of a command*/
}
}
last_x = x;
x += lv_font_get_glyph_width(font, letter, letter_next);
if(pos->x < x) {
i = i_current;
break;
}
x += style->text.letter_space;
i_current = i;
}
last_x = x;
x += lv_font_get_width(font, letter);
if(pos->x < x) {
i = i_current;
break;
}
x += style->text.letter_space;
i_current = i;
}
int max_diff = lv_font_get_width(font, letter) + style->text.letter_space + 1;
int32_t max_diff = lv_font_get_glyph_width(font, letter, letter_next) + style->text.letter_space + 1;
return (pos->x >= (last_x - style->text.letter_space) && pos->x <= (last_x + max_diff));
}
@ -841,10 +861,11 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
style->text.line_space, LV_COORD_MAX, flag);
lv_point_t ofs;
/*Draw the text again next to the original to make an circular effect */
if(size.x > lv_obj_get_width(label)) {
ofs.x = ext->offset.x + size.x +
lv_font_get_width(style->text.font, ' ') * LV_LABEL_WAIT_CHAR_COUNT;
lv_font_get_glyph_width(style->text.font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
ofs.y = ext->offset.y;
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs,
@ -854,7 +875,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_
/*Draw the text again below the original to make an circular effect */
if(size.y > lv_obj_get_height(label)) {
ofs.x = ext->offset.x;
ofs.y = ext->offset.y + size.y + lv_font_get_height(style->text.font);
ofs.y = ext->offset.y + size.y + lv_font_get_line_height(style->text.font);
lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs,
lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label));
}
@ -958,8 +979,7 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.start = 0;
anim.ready_cb = NULL;
anim.path_cb = lv_anim_path_linear;
anim.playback_pause =
(((lv_font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) /
anim.playback_pause = (((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) /
ext->anim_speed) * LV_LABEL_WAIT_CHAR_COUNT;
anim.repeat_pause = anim.playback_pause;
anim.act_time = -anim.playback_pause;
@ -978,8 +998,9 @@ static void lv_label_refr_text(lv_obj_t * label)
}
if(size.y > lv_obj_get_height(label) && hor_anim == false) {
anim.end = lv_obj_get_height(label) - size.y - (lv_font_get_height(font));
anim.end = lv_obj_get_height(label) - size.y - (lv_font_get_line_height(font));
anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_y;
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
lv_anim_create(&anim);
} else {
@ -997,8 +1018,7 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.repeat = 1;
anim.playback = 0;
anim.start = 0;
anim.act_time =
-(((lv_font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) /
anim.act_time = -(((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) /
ext->anim_speed) * LV_LABEL_WAIT_CHAR_COUNT;
anim.ready_cb = NULL;
anim.path_cb = lv_anim_path_linear;
@ -1007,7 +1027,7 @@ static void lv_label_refr_text(lv_obj_t * label)
bool hor_anim = false;
if(size.x > lv_obj_get_width(label)) {
anim.end = -size.x - lv_font_get_width(font, ' ') * LV_LABEL_WAIT_CHAR_COUNT;
anim.end = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT;
anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_x;
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
lv_anim_create(&anim);
@ -1019,7 +1039,7 @@ static void lv_label_refr_text(lv_obj_t * label)
}
if(size.y > lv_obj_get_height(label) && hor_anim == false) {
anim.end = -size.y - (lv_font_get_height(font));
anim.end = -size.y - (lv_font_get_line_height(font));
anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_y;
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
lv_anim_create(&anim);
@ -1038,10 +1058,10 @@ static void lv_label_refr_text(lv_obj_t * label)
} else {
lv_point_t p;
p.x = lv_obj_get_width(label) -
(lv_font_get_width(style->text.font, '.') + style->text.letter_space) *
(lv_font_get_glyph_width(style->text.font, '.', '.') + style->text.letter_space) *
LV_LABEL_DOT_NUM; /*Shrink with dots*/
p.y = lv_obj_get_height(label);
p.y -= p.y % (lv_font_get_height(style->text.font) +
p.y -= p.y % (lv_font_get_line_height(style->text.font) +
style->text.line_space); /*Round down to the last line*/
p.y -= style->text.line_space; /*Trim the last line space*/
uint32_t letter_id = lv_label_get_letter_on(label, &p);

View File

@ -522,7 +522,7 @@ static void mbox_realign(lv_obj_t * mbox)
if(ext->btnm) {
const lv_style_t * btn_bg_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_BG);
const lv_style_t * btn_rel_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_REL);
lv_coord_t font_h = lv_font_get_height(btn_rel_style->text.font);
lv_coord_t font_h = lv_font_get_line_height(btn_rel_style->text.font);
lv_obj_set_size(ext->btnm, w,
font_h + btn_rel_style->body.padding.top +
btn_rel_style->body.padding.bottom + btn_bg_style->body.padding.top +

View File

@ -214,7 +214,7 @@ void lv_roller_set_visible_row_count(lv_obj_t * roller, uint8_t row_cnt)
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
uint8_t n_line_space = (row_cnt > 1) ? row_cnt - 1 : 1;
lv_ddlist_set_fix_height(roller, lv_font_get_height(style_label->text.font) * row_cnt +
lv_ddlist_set_fix_height(roller, lv_font_get_line_height(style_label->text.font) * row_cnt +
style_label->text.line_space * n_line_space);
}
@ -321,7 +321,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
lv_opa_t opa_scale = lv_obj_get_opa_scale(roller);
const lv_font_t * font = style->text.font;
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_area_t rect_area;
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 -
style->text.line_space / 2;
@ -338,7 +338,7 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig
const lv_style_t * style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
const lv_font_t * font = style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_opa_t opa_scale = lv_obj_get_opa_scale(roller);
/*Redraw the text on the selected area with a different color*/
@ -503,7 +503,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const lv_font_t * font = style_label->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
if(sign == LV_SIGNAL_DRAG_END) {
/*If dragged then align the list to there be an element in the middle*/
@ -615,7 +615,7 @@ static void refr_position(lv_obj_t * roller, bool anim_en)
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const lv_font_t * font = style_label->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_coord_t h = lv_obj_get_height(roller);
/* Normally the animtaion's `end_cb` sets correct position of the roller is infinite.
@ -705,7 +705,7 @@ static void inf_normalize(void * scrl)
/*Move to the new id*/
const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label);
const lv_font_t * font = style_label->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
lv_coord_t h = lv_obj_get_height(roller);
lv_coord_t line_y1 = ext->ddlist.sel_opt_id * (font_h + style_label->text.line_space) +

View File

@ -467,7 +467,7 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
/*Don't let 'width == 0' because the cursor will not be visible*/
if(lv_obj_get_width(ext->label) == 0) {
const lv_style_t * style = lv_obj_get_style(ext->label);
lv_obj_set_width(ext->label, lv_font_get_width(style->text.font, ' '));
lv_obj_set_width(ext->label, lv_font_get_glyph_width(style->text.font, ' ', '\0'));
}
if(ext->pwd_mode != 0) {
@ -559,7 +559,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos)
lv_obj_get_coords(ext->label, &label_cords);
/*Check the top*/
lv_coord_t font_h = lv_font_get_height(font_p);
lv_coord_t font_h = lv_font_get_line_height(font_p);
if(lv_obj_get_y(label_par) + cur_pos.y < 0) {
lv_obj_set_y(label_par, -cur_pos.y + style->body.padding.top);
}
@ -677,7 +677,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
const lv_style_t * style_ta = lv_obj_get_style(ta);
const lv_style_t * style_scrl = lv_obj_get_style(lv_page_get_scrl(ta));
const lv_style_t * style_label = lv_obj_get_style(ext->label);
lv_coord_t font_h = lv_font_get_height(style_label->text.font);
lv_coord_t font_h = lv_font_get_line_height(style_label->text.font);
ext->one_line = 1;
lv_page_set_scrl_fit2(ta, LV_FIT_TIGHT, LV_FIT_FLOOD);
@ -1140,7 +1140,7 @@ void lv_ta_cursor_down(lv_obj_t * ta)
/*Increment the y with one line and keep the valid x*/
const lv_style_t * label_style = lv_obj_get_style(ext->label);
const lv_font_t * font_p = label_style->text.font;
lv_coord_t font_h = lv_font_get_height(font_p);
lv_coord_t font_h = lv_font_get_line_height(font_p);
pos.y += font_h + label_style->text.line_space + 1;
pos.x = ext->cursor.valid_x;
@ -1171,7 +1171,7 @@ void lv_ta_cursor_up(lv_obj_t * ta)
/*Decrement the y with one line and keep the valid x*/
const lv_style_t * label_style = lv_obj_get_style(ext->label);
const lv_font_t * font = label_style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_coord_t font_h = lv_font_get_line_height(font);
pos.y -= font_h + label_style->text.line_space - 1;
pos.x = ext->cursor.valid_x;
@ -1313,7 +1313,7 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
if(ext->one_line) {
/*In one line mode refresh the Text Area height because 'vpad' can modify it*/
const lv_style_t * style_label = lv_obj_get_style(ext->label);
lv_coord_t font_h = lv_font_get_height(style_label->text.font);
lv_coord_t font_h = lv_font_get_line_height(style_label->text.font);
lv_obj_set_height(
ta, font_h + style_ta->body.padding.top + style_ta->body.padding.bottom +
style_scrl->body.padding.top + style_scrl->body.padding.bottom);
@ -1443,7 +1443,7 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) {
/*Set ext. size because the cursor might be out of this object*/
const lv_style_t * style_label = lv_obj_get_style(ext->label);
lv_coord_t font_h = lv_font_get_height(style_label->text.font);
lv_coord_t font_h = lv_font_get_line_height(style_label->text.font);
scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, style_label->text.line_space + font_h);
} else if(sign == LV_SIGNAL_CORD_CHG) {
/*Set the label width according to the text area width*/
@ -1620,13 +1620,15 @@ static void refr_cursor_area(lv_obj_t * ta)
uint32_t letter = lv_txt_encoded_next(&txt[byte_pos], NULL);
lv_coord_t letter_h = lv_font_get_height(label_style->text.font);
lv_coord_t letter_h = lv_font_get_line_height(label_style->text.font);
/*Set letter_w (set not 0 on non printable but valid chars)*/
lv_coord_t letter_w;
if(letter == '\0' || letter == '\n' || letter == '\r') {
letter_w = lv_font_get_width(label_style->text.font, ' ');
letter_w = lv_font_get_glyph_width(label_style->text.font, ' ', '\0');
} else {
letter_w = lv_font_get_width(label_style->text.font, letter);
/*`letter_next` parameter is '\0' to ignore kerning*/
letter_w = lv_font_get_glyph_width(label_style->text.font, letter, '\0');
}
lv_point_t letter_pos;
@ -1644,9 +1646,9 @@ static void refr_cursor_area(lv_obj_t * ta)
}
if(letter == '\0' || letter == '\n' || letter == '\r') {
letter_w = lv_font_get_width(label_style->text.font, ' ');
letter_w = lv_font_get_glyph_width(label_style->text.font, ' ', '\0');
} else {
letter_w = lv_font_get_width(label_style->text.font, letter);
letter_w = lv_font_get_glyph_width(label_style->text.font, letter, '\0');
}
}

View File

@ -804,7 +804,7 @@ static lv_coord_t get_row_height(lv_obj_t * table, uint16_t row_id)
uint16_t row_start = row_id * ext->col_cnt;
uint16_t cell;
uint16_t col;
lv_coord_t h_max = lv_font_get_height(ext->cell_style[0]->text.font) +
lv_coord_t h_max = lv_font_get_line_height(ext->cell_style[0]->text.font) +
ext->cell_style[0]->body.padding.top +
ext->cell_style[0]->body.padding.bottom;
@ -834,7 +834,7 @@ static lv_coord_t get_row_height(lv_obj_t * table, uint16_t row_id)
/*With text crop assume 1 line*/
if(format.s.crop) {
h_max =
LV_MATH_MAX(lv_font_get_height(cell_style->text.font) +
LV_MATH_MAX(lv_font_get_line_height(cell_style->text.font) +
cell_style->body.padding.top + cell_style->body.padding.bottom,
h_max);
}

View File

@ -1042,7 +1042,7 @@ static void tabview_realign(lv_obj_t * tabview)
switch(ext->btns_pos) {
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM:
btns_size = lv_font_get_height(style_btn_rel->text.font) +
btns_size = lv_font_get_line_height(style_btn_rel->text.font) +
style_btn_rel->body.padding.top +
style_btn_rel->body.padding.bottom +
style_btn_bg->body.padding.top + style_btn_bg->body.padding.bottom;
@ -1050,7 +1050,7 @@ static void tabview_realign(lv_obj_t * tabview)
break;
case LV_TABVIEW_BTNS_POS_LEFT:
case LV_TABVIEW_BTNS_POS_RIGHT:
btns_size = lv_font_get_width(style_btn_rel->text.font, 0x0041) + // 'A'
btns_size = lv_font_get_glyph_width(style_btn_rel->text.font, 'A', '\0') +
style_btn_rel->body.padding.left +
style_btn_rel->body.padding.right +
style_btn_bg->body.padding.left + style_btn_bg->body.padding.right;