Fix text wrapping off-by-one error w/ string width

Caused odd white space error in tooltip enum values.
This commit is contained in:
Campbell Barton 2016-01-04 01:41:00 +11:00
parent a3df65dea8
commit d57847ca5b
2 changed files with 7 additions and 5 deletions

@ -721,11 +721,13 @@ static void blf_font_wrap_apply(
}
else if (UNLIKELY(g->c != ' ' && (g_prev ? g_prev->c == ' ' : false))) {
wrap.last[0] = i_curr;
wrap.last[1] = i;
wrap.last[1] = i_curr;
}
if (UNLIKELY(do_draw)) {
// printf("(%d..%d) `%.*s`\n", wrap.start, wrap.last[0], (wrap.last[0] - wrap.start) - 1, &str[wrap.start]);
// printf("(%03d..%03d) `%.*s`\n",
// wrap.start, wrap.last[0], (wrap.last[0] - wrap.start) - 1, &str[wrap.start]);
callback(font, &str[wrap.start], (wrap.last[0] - wrap.start) - 1, pen_y, userdata);
wrap.start = wrap.last[0];
i = wrap.last[1];
@ -740,7 +742,7 @@ static void blf_font_wrap_apply(
g_prev = g;
}
// printf("done! %d lines\n", lines);
// printf("done! lines: %d, width, %d\n", lines, pen_x_next);
if (r_info) {
r_info->lines = lines;

@ -616,7 +616,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
if (data->format[i].style == UI_TIP_STYLE_HEADER) {
w = BLF_width_ex(data->fstyle.uifont_id, data->header, sizeof(data->header), &info);
if (enum_label.strinfo) {
x_pos = info.width + (U.widget_unit / 2);
x_pos = info.width;
w = max_ii(w, x_pos + BLF_width(data->fstyle.uifont_id, data->active_info, sizeof(data->active_info)));
}
}