mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-02 01:26:32 +00:00
expo: Calculate text bounding-box correctly
Rather than estimating, measure the text accurately, using the new vidconsole feature. This allows accurate placement of objects. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
ce72c9ec26
commit
50f0203759
1 changed files with 21 additions and 7 deletions
28
boot/scene.c
28
boot/scene.c
|
@ -257,16 +257,30 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp)
|
||||||
case SCENEOBJT_TEXT: {
|
case SCENEOBJT_TEXT: {
|
||||||
struct scene_obj_txt *txt = (struct scene_obj_txt *)obj;
|
struct scene_obj_txt *txt = (struct scene_obj_txt *)obj;
|
||||||
struct expo *exp = scn->expo;
|
struct expo *exp = scn->expo;
|
||||||
|
struct vidconsole_bbox bbox;
|
||||||
|
const char *str;
|
||||||
|
int len, ret;
|
||||||
|
|
||||||
|
str = expo_get_str(exp, txt->str_id);
|
||||||
|
if (!str)
|
||||||
|
return log_msg_ret("str", -ENOENT);
|
||||||
|
len = strlen(str);
|
||||||
|
|
||||||
|
/* if there is no console, make it up */
|
||||||
|
if (!exp->cons) {
|
||||||
|
if (widthp)
|
||||||
|
*widthp = 8 * len;
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = vidconsole_measure(scn->expo->cons, txt->font_name,
|
||||||
|
txt->font_size, str, &bbox);
|
||||||
|
if (ret)
|
||||||
|
return log_msg_ret("mea", ret);
|
||||||
if (widthp)
|
if (widthp)
|
||||||
*widthp = 16; /* fake value for now */
|
*widthp = bbox.x1;
|
||||||
if (txt->font_size)
|
|
||||||
return txt->font_size;
|
|
||||||
if (exp->display)
|
|
||||||
return video_default_font_height(exp->display);
|
|
||||||
|
|
||||||
/* use a sensible default */
|
return bbox.y1;
|
||||||
return 16;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue