[ui] Set text view height to font height

Text_StringView sets the view bounds to the bounds of the glyphs in the
view. This has its advantages, but is not suitable for automatic UI
sizing. However, the view is positioned correctly, so nothing needs to
be done there. Now full height glyphs (eg, C) look balanced in the view,
and glyphs with descenders (g) brush the bottom of the view.
This commit is contained in:
Bill Currie 2023-07-02 03:02:13 +09:00
parent ed5ef3a5fb
commit 85fd3c34cc

View file

@ -279,6 +279,12 @@ add_text (view_t view, imui_state_t *state, imui_ctx_t *ctx)
auto text = Text_StringView (ctx->tsys, view, ctx->font,
state->label, state->label_len, 0, 0);
int ascender = ctx->font->face->size->metrics.ascender / 64;
int descender = ctx->font->face->size->metrics.descender / 64;
auto len = View_GetLen (text);
View_SetLen (text, len.x, ascender - descender);
View_SetVisible (text, 1);
Ent_SetComponent (text.id, c_glyphs, reg,
Ent_GetComponent (text.id, c_passage_glyphs, reg));