mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
font rework
This commit is contained in:
parent
ac89e880a7
commit
4e6aac2157
@ -243,7 +243,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv
|
||||
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 letter_h = lv_font_get_line_height(font_p);
|
||||
uint8_t bpp = lv_font_get_bpp(font_p, letter); /*Bit per pixel (1,2, 4 or 8)*/
|
||||
const uint8_t * bpp_opa_table;
|
||||
uint8_t mask_init;
|
||||
|
@ -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;
|
||||
|
@ -90,20 +90,22 @@ void lv_font_remove(lv_font_t * child, lv_font_t * parent)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,28 +128,26 @@ const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t lett
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font. If `monospace` is set then return with it.
|
||||
* Get the description of a glyph in a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter an UNICODE character code
|
||||
* @return the width of a letter
|
||||
* @return pointer to a glyph descriptor
|
||||
*/
|
||||
uint8_t lv_font_get_glyph_dsc(const lv_font_t * font_p, uint32_t letter, lv_font_glyph_dsc_t * dsc)
|
||||
lv_font_glyph_dsc_t * lv_font_get_glyph_dsc(const lv_font_t * font_p, uint32_t letter)
|
||||
{
|
||||
const lv_font_t * font_i = font_p;
|
||||
int16_t w;
|
||||
lv_font_glyph_dsc_t * dsc;
|
||||
while(font_i != NULL) {
|
||||
w = font_i->get_dsc(font_i, letter, dsc);
|
||||
if(w >= 0) {
|
||||
dsc = font_i->get_dsc(font_i, letter);
|
||||
if(dsc) {
|
||||
/*Glyph found*/
|
||||
uint8_t m = font_i->monospace;
|
||||
if(m) w = m;
|
||||
return w;
|
||||
return dsc;
|
||||
}
|
||||
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,13 +35,14 @@ extern "C" {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bitmap_index : 20; /* Start index of the bitmap. A font can be max 1 MB. */
|
||||
uint32_t adv_w :8; /*The glyph need this space. Draw the next glyph after this width */
|
||||
uint32_t adv_w_fract :4; /*Fractional part of `advance_width` in 1/16 unit*/
|
||||
uint32_t box_w :8; /*Width of the glyph's bounding box*/
|
||||
uint32_t box_h :8; /*Height of the glyph's bounding box*/
|
||||
uint32_t ofs_x :8; /*x offset of the bounding box*/
|
||||
uint32_t ofs_y :8; /*y offset of the bounding box*/
|
||||
uint32_t bitmap_index : 20; /* Start index of the bitmap. A font can be max 1 MB. */
|
||||
|
||||
uint8_t box_w; /*Width of the glyph's bounding box*/
|
||||
uint8_t box_h; /*Height of the glyph's bounding box*/
|
||||
uint8_t ofs_x; /*x offset of the bounding box*/
|
||||
int8_t ofs_y; /*y offset of the bounding box*/
|
||||
} lv_font_glyph_dsc_t;
|
||||
|
||||
typedef struct _lv_font_struct
|
||||
@ -60,10 +61,12 @@ typedef struct _lv_font_struct
|
||||
|
||||
/*Pointer to a font extension*/
|
||||
struct _lv_font_struct * next_page;
|
||||
uint32_t line_height :8;
|
||||
uint32_t monospace :8; /*Fix width (0: normal width)*/
|
||||
uint32_t bpp :4; /*Bit per pixel: 1, 2, 4 or 8*/
|
||||
uint16_t glyph_cnt :11; /*Number of glyphs in the font. Max. 2048*/
|
||||
uint8_t size;
|
||||
uint8_t ascent;
|
||||
int8_t descent;
|
||||
uint8_t monospace; /*Fix width (0: normal width)*/
|
||||
uint8_t bpp; /*Bit per pixel: 1, 2, 4 or 8*/
|
||||
uint16_t glyph_cnt; /*Number of glyphs in the font. Max. 2048*/
|
||||
} lv_font_t;
|
||||
|
||||
/**********************
|
||||
@ -122,13 +125,13 @@ uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter);
|
||||
uint8_t lv_font_get_real_width(const lv_font_t * font_p, uint32_t letter);
|
||||
|
||||
/**
|
||||
* 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 (uint8_t)((int16_t)font_p->ascent - font_p->descent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,7 +97,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') {
|
||||
|
@ -624,7 +624,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;
|
||||
}
|
||||
|
||||
@ -637,7 +637,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;
|
||||
}
|
||||
|
||||
@ -702,7 +702,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;
|
||||
@ -725,15 +725,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;
|
||||
@ -854,8 +854,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -544,7 +544,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;
|
||||
@ -569,7 +569,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;
|
||||
@ -601,7 +601,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;
|
||||
@ -861,7 +861,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
|
||||
} else { /*Close the list*/
|
||||
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);
|
||||
@ -933,7 +933,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);
|
||||
|
||||
|
@ -457,7 +457,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;
|
||||
|
||||
@ -530,7 +530,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;
|
||||
|
||||
@ -635,7 +635,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;
|
||||
|
||||
@ -846,7 +846,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));
|
||||
}
|
||||
@ -970,7 +970,7 @@ 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.fp = (lv_anim_fp_t)lv_label_set_offset_y;
|
||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
||||
lv_anim_create(&anim);
|
||||
@ -1011,7 +1011,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.fp = (lv_anim_fp_t)lv_label_set_offset_y;
|
||||
anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
|
||||
lv_anim_create(&anim);
|
||||
@ -1033,7 +1033,7 @@ static void lv_label_refr_text(lv_obj_t * label)
|
||||
(lv_font_get_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);
|
||||
|
@ -483,7 +483,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 +
|
||||
|
@ -202,7 +202,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);
|
||||
}
|
||||
|
||||
@ -309,7 +309,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;
|
||||
@ -326,7 +326,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*/
|
||||
@ -505,7 +505,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*/
|
||||
@ -610,7 +610,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.
|
||||
@ -667,7 +667,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) +
|
||||
|
@ -547,7 +547,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);
|
||||
}
|
||||
@ -663,7 +663,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);
|
||||
@ -1049,7 +1049,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;
|
||||
|
||||
@ -1080,7 +1080,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;
|
||||
|
||||
@ -1222,7 +1222,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);
|
||||
@ -1352,7 +1352,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*/
|
||||
@ -1520,7 +1520,7 @@ 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') {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -867,7 +867,7 @@ static void tabview_realign(lv_obj_t * tabview)
|
||||
lv_obj_set_width(ext->indic, indic_width);
|
||||
|
||||
/*Set the tabs height*/
|
||||
lv_coord_t btns_height = lv_font_get_height(style_btn_rel->text.font) +
|
||||
lv_coord_t btns_height = 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user