Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-02 13:33:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-02 14:10:07 +0400
commit1815225faa75eb64e83fdc9f066fcd6339502d52 (patch)
tree6558780d85792c9c41fcf280069870fae70eed7a /source/blender/editors
parentf64ae4cbe5a724496624de9e479c04f325613be5 (diff)
Blender Font (BLF): add length argument to string width/height functions
This also fixes a crash editing buttons longer then UI_MAX_DRAW_STR
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c11
-rw-r--r--source/blender/editors/interface/interface_regions.c2
-rw-r--r--source/blender/editors/interface/interface_style.c12
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c54
-rw-r--r--source/blender/editors/interface/view2d.c2
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c2
-rw-r--r--source/blender/editors/space_clip/clip_draw.c2
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/editors/space_image/image_draw.c28
-rw-r--r--source/blender/editors/space_node/drawnode.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c4
-rw-r--r--source/blender/editors/transform/transform.c2
16 files changed, 58 insertions, 73 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 9d541b56bf4..0300b7bc685 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -903,7 +903,7 @@ void uiIDContextProperty(struct bContext *C, struct PointerRNA *ptr, struct Prop
/* Styled text draw */
void uiStyleFontSet(struct uiFontStyle *fs);
void uiStyleFontDrawExt(struct uiFontStyle *fs, const struct rcti *rect, const char *str,
- float *r_xofs, float *r_yofs);
+ size_t len, float *r_xofs, float *r_yofs);
void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, const char *str);
void uiStyleFontDrawRotated(struct uiFontStyle *fs, struct rcti *rect, const char *str);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c82026eace6..46ee1700a06 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -218,7 +218,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
for (bt = block->buttons.first; bt; bt = bt->next) {
if (bt->type != SEPR) {
- j = BLF_width(style->widget.uifont_id, bt->drawstr);
+ j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
if (j > i) i = j;
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index ee6663d7954..1ed0c128a20 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1616,8 +1616,7 @@ void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but
/* save original string */
BLI_strncpy(password_str, but->drawstr, UI_MAX_DRAW_STR);
- for (i = 0; i < len; i++)
- but->drawstr[i] = '*';
+ memset(but->drawstr, '*', len);
but->drawstr[i] = '\0';
}
}
@@ -1656,9 +1655,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
ui_button_text_password_hide(password_str, but, FALSE);
origstr = MEM_mallocN(sizeof(char) * data->maxlen, "ui_textedit origstr");
-
+
BLI_strncpy(origstr, but->drawstr, data->maxlen);
-
+
/* XXX solve generic, see: #widget_draw_text_icon */
if (but->type == NUM || but->type == NUMSLI) {
startx += (int)(0.5f * (BLI_rctf_size_y(&but->rect)));
@@ -1680,7 +1679,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
while (i > 0) {
if (BLI_str_cursor_step_prev_utf8(origstr, but->ofs, &i)) {
/* 0.25 == scale factor for less sensitivity */
- if (BLF_width(fstyle->uifont_id, origstr + i) > (startx - x) * 0.25f) {
+ if (BLF_width(fstyle->uifont_id, origstr + i, BLF_DRAW_STR_DUMMY_MAX) > (startx - x) * 0.25f) {
break;
}
}
@@ -1702,7 +1701,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
but->pos = pos_prev = strlen(origstr) - but->ofs;
while (true) {
- cdist = startx + BLF_width(fstyle->uifont_id, origstr + but->ofs);
+ cdist = startx + BLF_width(fstyle->uifont_id, origstr + but->ofs, BLF_DRAW_STR_DUMMY_MAX);
/* check if position is found */
if (cdist < x) {
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index a6216b486ad..2f37d8e6e98 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -660,7 +660,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
h = BLF_height_max(data->fstyle.uifont_id);
for (a = 0, fontw = 0, fonth = 0; a < data->totline; a++) {
- w = BLF_width(data->fstyle.uifont_id, data->lines[a]);
+ w = BLF_width(data->fstyle.uifont_id, data->lines[a], sizeof(data->lines[a]));
fontw = max_ff(fontw, (float)w);
fonth += (a == 0) ? h : h + TIP_MARGIN_Y;
}
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 1c6263c9dd5..38d9f4fcc12 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -144,7 +144,7 @@ static uiFont *uifont_to_blfont(int id)
void uiStyleFontDrawExt(uiFontStyle *fs, const rcti *rect, const char *str,
- float *r_xofs, float *r_yofs)
+ size_t len, float *r_xofs, float *r_yofs)
{
float height;
int xofs = 0, yofs;
@@ -155,14 +155,14 @@ void uiStyleFontDrawExt(uiFontStyle *fs, const rcti *rect, const char *str,
yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
if (fs->align == UI_STYLE_TEXT_CENTER) {
- xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str)));
+ xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));
/* don't center text if it chops off the start of the text, 2 gives some margin */
if (xofs < 2) {
xofs = 2;
}
}
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
- xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str) - 0.1f * U.widget_unit;
+ xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
}
/* clip is very strict, so we give it some space */
@@ -194,7 +194,7 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, const char *str)
{
float xofs, yofs;
uiStyleFontDrawExt(fs, rect, str,
- &xofs, &yofs);
+ BLF_DRAW_STR_DUMMY_MAX, &xofs, &yofs);
}
/* drawn same as above, but at 90 degree angle */
@@ -215,7 +215,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
/* rotate counter-clockwise for now (assumes left-to-right language)*/
xofs += height;
- yofs = BLF_width(fs->uifont_id, str) + 5;
+ yofs = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX) + 5;
angle = (float)M_PI / 2.0f;
/* translate rect to vertical */
@@ -298,7 +298,7 @@ int UI_GetStringWidth(const char *str)
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
uiStyleFontSet(fstyle);
- width = BLF_width(fstyle->uifont_id, str);
+ width = BLF_width(fstyle->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 8926a16481d..6bb6081d135 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3299,7 +3299,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
ui_abs = uiLayoutAbsolute(layout, FALSE);
block = uiLayoutGetBlock(ui_abs);
- width = BLF_width(style->widget.uifont_id, report->message);
+ width = BLF_width(style->widget.uifont_id, report->message, report->len);
width = min_ii((int)(rti->widthfac * width), width);
width = max_ii(width, 10);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 0691eb4a9b8..27f16a6fd5c 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -967,11 +967,11 @@ static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, const rcti *rect)
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
but->ofs = 0;
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
while (but->strwidth > okwidth) {
ui_text_clip_give_next_off(but);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
@@ -1001,10 +1001,10 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
if (but->ofs > but->pos)
but->ofs = but->pos;
- if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth)
+ if (BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr)) <= okwidth)
but->ofs = 0;
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
while (but->strwidth > okwidth) {
float width;
@@ -1014,7 +1014,7 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf));
/* string position of cursor */
buf[but->pos] = 0;
- width = BLF_width(fstyle->uifont_id, buf + but->ofs);
+ width = BLF_width(fstyle->uifont_id, buf + but->ofs, sizeof(buf) - but->ofs);
/* if cursor is at 20 pixels of right side button we clip left */
if (width > okwidth - 20) {
@@ -1032,7 +1032,7 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
but->drawstr[len - bytes] = 0;
}
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
@@ -1061,7 +1061,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
but->ofs = 0;
@@ -1089,7 +1089,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
drawstr_len -= bytes;
// BLI_assert(strlen(but->drawstr) == drawstr_len);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
@@ -1097,7 +1097,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
/* after the leading text is gone, chop off the : and following space, with ofs */
while ((but->strwidth > okwidth) && (but->ofs < 2)) {
ui_text_clip_give_next_off(but);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
@@ -1115,7 +1115,7 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
but->drawstr[drawstr_len] = 0;
// BLI_assert(strlen(but->drawstr) == drawstr_len);
- but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, sizeof(but->drawstr) - but->ofs);
if (but->strwidth < 10) break;
}
@@ -1146,7 +1146,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* text button selection and cursor */
if (but->editstr && but->pos != -1) {
- short t = 0, pos = 0, ch;
+ short t = 0, pos = 0;
short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
if ((but->selend - but->selsta) > 0) {
@@ -1157,23 +1157,13 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
if (but->drawstr[0] != 0) {
if (but->selsta >= but->ofs) {
- ch = but->drawstr[selsta_tmp];
- but->drawstr[selsta_tmp] = 0;
-
- selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
-
- but->drawstr[selsta_tmp] = ch;
+ selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, selsta_tmp - but->ofs);
}
else {
selsta_draw = 0;
}
-
- ch = but->drawstr[selend_tmp];
- but->drawstr[selend_tmp] = 0;
-
- selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
-
- but->drawstr[selend_tmp] = ch;
+
+ selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, selend_tmp - but->ofs);
glColor4ubv((unsigned char *)wcol->item);
glRects(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2);
@@ -1184,12 +1174,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
pos = but->pos;
if (pos >= but->ofs) {
if (but->drawstr[0] != 0) {
- ch = but->drawstr[pos];
- but->drawstr[pos] = 0;
-
- t = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs) / but->aspect;
-
- but->drawstr[pos] = ch;
+ t = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, pos - but->ofs) / but->aspect;
}
glColor3f(0.20, 0.6, 0.9);
@@ -1216,7 +1201,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
glColor4ubv((unsigned char *)wcol->text);
- uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs, &font_xofs, &font_yofs);
+ uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs,
+ sizeof(but->drawstr) - but->ofs, &font_xofs, &font_yofs);
if (but->menu_key != '\0') {
char fixedbuf[128];
@@ -1239,7 +1225,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
fixedbuf[ul_index] = '\0';
- ul_advance = BLF_width(fstyle->uifont_id, fixedbuf);
+ ul_advance = BLF_width(fstyle->uifont_id, fixedbuf, ul_index);
BLF_position(fstyle->uifont_id, rect->xmin + font_xofs + ul_advance, rect->ymin + font_yofs, 0.0f);
BLF_draw(fstyle->uifont_id, "_", 2);
@@ -3528,7 +3514,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
cpoin = strchr(name, UI_SEP_CHAR);
if (cpoin) {
*cpoin = 0;
- rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10;
+ rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + 10;
}
}
@@ -3574,7 +3560,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
widget_draw_preview(iconid, 1.0f, rect);
- BLF_width_and_height(fstyle->uifont_id, name, &font_dims[0], &font_dims[1]);
+ BLF_width_and_height(fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]);
/* text rect */
trect.xmin += 0;
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index e3787789165..6bb623155a5 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -2196,7 +2196,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
int col_pack_prev = 0;
/* investigate using BLF_ascender() */
- const float default_height = strings.first ? BLF_height_default("28") : 0.0f;
+ const float default_height = strings.first ? BLF_height_default("28", 3) : 0.0f;
// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 83a261bc140..8b89c2f0553 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1825,7 +1825,7 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float fill_co
/* box fill entire width or just around text */
if (!block)
- rect.xmax = min_ii(rect.xmax, rect.xmin + BLF_width(fontid, text) + 1.2f * U.widget_unit);
+ rect.xmax = min_ii(rect.xmax, rect.xmin + BLF_width(fontid, text, BLF_DRAW_STR_DUMMY_MAX) + 1.2f * U.widget_unit);
rect.ymax = BLI_rcti_size_y(&ar->winrct);
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 059b8ace7b9..e85b055bc59 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -341,7 +341,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
else
UI_ThemeColor(TH_TEXT);
- font_height = BLF_height(fontid, channel->name);
+ font_height = BLF_height(fontid, channel->name, sizeof(channel->name));
BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD,
y - font_height / 2.0f, 0.0f);
BLF_draw(fontid, channel->name, strlen(channel->name));
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 38e7f87f478..3ca9a9478fa 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -87,7 +87,7 @@ void clip_draw_curfra_label(const int framenr, const float x, const float y)
BLF_size(fontid, 11.0f, U.dpi);
BLI_snprintf(numstr, sizeof(numstr), "%d", framenr);
- BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]);
+ BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]);
glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index ff0add36bdc..d329d505138 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -435,7 +435,7 @@ float file_string_width(const char *str)
{
uiStyle *style = UI_GetStyle();
uiStyleFontSet(&style->widget);
- return BLF_width(style->widget.uifont_id, str);
+ return BLF_width(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
}
float file_font_pointsize(void)
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 89e57955339..3d5f6a6ce7e 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -195,21 +195,21 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_Y, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
if (zp) {
glColor3ub(255, 255, 255);
BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff));
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
}
if (zpf) {
glColor3ub(255, 255, 255);
BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
}
if (channels >= 3) {
@@ -222,7 +222,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " R:-");
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
glColor3ubv(green);
if (fp)
@@ -233,7 +233,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " G:-");
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
glColor3ubv(blue);
if (fp)
@@ -244,7 +244,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " B:-");
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
if (channels == 4) {
glColor3ub(255, 255, 255);
@@ -256,7 +256,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), "- ");
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
}
if (color_manage) {
@@ -276,7 +276,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
}
}
@@ -350,12 +350,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
}
else if (channels >= 3) {
rgb_to_hsv(finalcol[0], finalcol[1], finalcol[2], &hue, &sat, &val);
@@ -364,22 +364,22 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " S:%-.4f", sat);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " V:%-.4f", val);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
BLI_snprintf(str, sizeof(str), " L:%-.4f", lum);
BLF_position(blf_mono_font, dx, 0.3f * UI_UNIT_X, 0);
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
- dx += BLF_width(blf_mono_font, str);
+ dx += BLF_width(blf_mono_font, str, sizeof(str));
}
(void)dx;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 3040789852f..d4af66b7eb9 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -406,7 +406,7 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp
/* title color */
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
- width = BLF_width(fontid, label);
+ width = BLF_width(fontid, label, sizeof(label));
ascender = BLF_ascender(fontid);
/* 'x' doesn't need aspect correction */
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 64b747b389b..6aa34baeac6 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -541,7 +541,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);
- BLF_width_and_height(blf_mono_font, numstr, &numstr_size[0], &numstr_size[1]);
+ BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);
pos[0] = co_ss[1][0] + (cap_size * 2.0f);
pos[1] = co_ss[1][1] - (numstr_size[1] / 2.0f);
@@ -627,7 +627,7 @@ static void ruler_info_draw_pixel(const struct bContext *C, ARegion *ar, void *a
ruler_item_as_string(ruler_item, unit, numstr, sizeof(numstr), prec);
- BLF_width_and_height(blf_mono_font, numstr, &numstr_size[0], &numstr_size[1]);
+ BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]);
mid_v2_v2v2(pos, co_ss[0], co_ss[2]);
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index f88d8366b8d..2ae94fb6d5a 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1758,7 +1758,7 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
ED_region_visible_rect(ar, &rect);
- BLF_width_and_height_default(printable, &printable_size[0], &printable_size[1]);
+ BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
xco = rect.xmax - (int)printable_size[0] - 10;
yco = rect.ymax - (int)printable_size[1] - 10;