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:
authorDiego Borghetti <bdiego@gmail.com>2010-04-22 14:56:45 +0400
committerDiego Borghetti <bdiego@gmail.com>2010-04-22 14:56:45 +0400
commita56b72fd82e5de17ad0f688857c31cf3a9623ea1 (patch)
tree496997dd98d65a3c14f70e7a8928870b6654b45a /source/blender/editors
parentc8c22d2cf65504443574961cea0ec1773c18735e (diff)
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders Blenfont was not thread safe, that is why one thread can change the font properties (size, dpi, color, etc) at the same time that the stamp draw on the image, and then the problem. To make blenfont thread safe I have to change two important things: 1) Every BLF_* function take one argument, the font id. 2) We have two new function to make font "thread safe": BLF_load_unique BLF_load_mem_unique This two function are for case like stamp, that need and own font that don't share the glyph cache, so can draw without problem in a different thread. Why the BLF_*_unique function ? Because blenfont keep only one copy of a font and keep a list of "glyph cache". Every glyph cache have size and dpi, so if two different thread access the same font at the same time, they can change value and finish with something like the stamp problem. Why don't remove the glyph cache ? Because if we do that, we finish with a font object for every size and dpi, and the stamp is really a special case that happen in the rendering process, so I really thing is better keep the glyph cache and make this two new function to handle this special case. (When I say "font object" I mean have the same freetype font multiple times just to have differents size and dpi) As Matt point we still can have one case that two thread access the BLF_*_unique function at the same time, but I am looking to fix this with some class of thread lock. For now I test and work fine, so if some one found problem, please let me know. Campbell I have to change the python api (python/generic/blf_api.c) to the new syntax, so maybe you can take a look at this.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c8
-rw-r--r--source/blender/editors/interface/interface_regions.c4
-rw-r--r--source/blender/editors/interface/interface_style.c80
-rw-r--r--source/blender/editors/interface/interface_widgets.c36
-rw-r--r--source/blender/editors/interface/view2d.c15
-rw-r--r--source/blender/editors/space_console/console_draw.c33
-rw-r--r--source/blender/editors/space_file/file_draw.c10
-rw-r--r--source/blender/editors/space_file/filesel.c4
-rw-r--r--source/blender/editors/space_text/text_draw.c25
10 files changed, 106 insertions, 111 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 1267a1c1737..d639b881fe6 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -230,7 +230,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
//int transopts= ui_translate_buttons();
//if(bt->type==TEX || bt->type==IDPOIN) transopts= 0;
- j= BLF_width(bt->drawstr);
+ j= BLF_width(style->widget.uifont_id, 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 8aeca23a188..c444ef253d5 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1165,7 +1165,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
uiStyleFontSet(fstyle);
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
origstr= MEM_callocN(sizeof(char)*data->maxlen, "ui_textedit origstr");
@@ -1188,7 +1188,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
while (i > 0) {
i--;
- if (BLF_width(origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity
+ if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25) break; // 0.25 == scale factor for less sensitivity
}
but->ofs = i;
but->pos = but->ofs;
@@ -1200,7 +1200,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
but->pos= strlen(origstr)-but->ofs;
/* XXX does not take zoom level into account */
- while (aspect*startx + aspect*BLF_width(origstr+but->ofs) > x) {
+ while (aspect*startx + aspect*BLF_width(fstyle->uifont_id, origstr+but->ofs) > x) {
if (but->pos <= 0) break;
but->pos--;
origstr[but->pos+but->ofs] = 0;
@@ -1210,7 +1210,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
}
if (fstyle->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
MEM_freeN(origstr);
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index ce3fe61b2f9..102b7e342b3 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -453,10 +453,10 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
data->fstyle.align= UI_STYLE_TEXT_CENTER;
uiStyleFontSet(&data->fstyle);
- h= BLF_height(data->lines[0]);
+ h= BLF_height(data->fstyle.uifont_id, data->lines[0]);
for(a=0, fontw=0, fonth=0; a<data->totline; a++) {
- w= BLF_width(data->lines[a]);
+ w= BLF_width(data->fstyle.uifont_id, data->lines[a]);
fontw= MAX2(fontw, w);
fonth += (a == 0)? h: h+5;
}
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index aaebdf5693a..e3317e5598f 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -147,34 +147,34 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
uiStyleFontSet(fs);
- height= BLF_height("2"); /* correct offset is on baseline, the j is below that */
+ height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */
yofs= floor( 0.5f*(rect->ymax - rect->ymin - height));
if(fs->align==UI_STYLE_TEXT_CENTER)
- xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(str)));
+ xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
else if(fs->align==UI_STYLE_TEXT_RIGHT)
- xofs= rect->xmax - rect->xmin - BLF_width(str) - 1;
+ xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
/* clip is very strict, so we give it some space */
- BLF_clipping(rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
- BLF_enable(BLF_CLIPPING);
- BLF_position(rect->xmin+xofs, rect->ymin+yofs, 0.0f);
+ BLF_clipping(fs->uifont_id, rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
+ BLF_enable(fs->uifont_id, BLF_CLIPPING);
+ BLF_position(fs->uifont_id, rect->xmin+xofs, rect->ymin+yofs, 0.0f);
if (fs->shadow) {
- BLF_enable(BLF_SHADOW);
- BLF_shadow(fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
- BLF_shadow_offset(fs->shadx, fs->shady);
+ BLF_enable(fs->uifont_id, BLF_SHADOW);
+ BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
+ BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
if (fs->kerning == 1)
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(str);
- BLF_disable(BLF_CLIPPING);
+ BLF_draw(fs->uifont_id, str);
+ BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
- BLF_disable(BLF_SHADOW);
+ BLF_disable(fs->uifont_id, BLF_SHADOW);
if (fs->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
/* drawn same as above, but at 90 degree angle */
@@ -187,7 +187,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
uiStyleFontSet(fs);
- height= BLF_height("2"); /* correct offset is on baseline, the j is below that */
+ height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */
/* becomes x-offset when rotated */
xofs= floor( 0.5f*(rect->ymax - rect->ymin - height)) + 1;
@@ -195,7 +195,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
/* rotate counter-clockwise for now (assumes left-to-right language)*/
xofs+= height;
- yofs= BLF_width(str) + 5;
+ yofs= BLF_width(fs->uifont_id, str) + 5;
angle= 90.0f;
/* translate rect to vertical */
@@ -206,29 +206,29 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
/* clip is very strict, so we give it some space */
/* clipping is done without rotation, so make rect big enough to contain both positions */
- BLF_clipping(txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
- BLF_enable(BLF_CLIPPING);
- BLF_position(txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);
+ BLF_clipping(fs->uifont_id, txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
+ BLF_enable(fs->uifont_id, BLF_CLIPPING);
+ BLF_position(fs->uifont_id, txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);
- BLF_enable(BLF_ROTATION);
- BLF_rotation(angle);
+ BLF_enable(fs->uifont_id, BLF_ROTATION);
+ BLF_rotation(fs->uifont_id, angle);
if (fs->shadow) {
- BLF_enable(BLF_SHADOW);
- BLF_shadow(fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
- BLF_shadow_offset(fs->shadx, fs->shady);
+ BLF_enable(fs->uifont_id, BLF_SHADOW);
+ BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
+ BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
}
if (fs->kerning == 1)
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(str);
- BLF_disable(BLF_ROTATION);
- BLF_disable(BLF_CLIPPING);
+ BLF_draw(fs->uifont_id, str);
+ BLF_disable(fs->uifont_id, BLF_ROTATION);
+ BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
- BLF_disable(BLF_SHADOW);
+ BLF_disable(fs->uifont_id, BLF_SHADOW);
if (fs->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
/* ************** helpers ************************ */
@@ -241,13 +241,13 @@ int UI_GetStringWidth(char *str)
int width;
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
uiStyleFontSet(fstyle);
- width= BLF_width(str);
+ width= BLF_width(fstyle->uifont_id, str);
if (fstyle->kerning==1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
return width;
}
@@ -258,8 +258,8 @@ void UI_DrawString(float x, float y, char *str)
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
- BLF_position(x, y, 0.0f);
- BLF_draw(str);
+ BLF_position(style->widget.uifont_id, x, y, 0.0f);
+ BLF_draw(style->widget.uifont_id, str);
}
/* ************** init exit ************************ */
@@ -299,14 +299,13 @@ void uiStyleInit(void)
printf("uiStyleInit error, no fonts available\n");
}
else {
- BLF_set(font->blf_id);
/* ? just for speed to initialize?
* Yes, this build the glyph cache and create
* the texture.
*/
- BLF_size(11, U.dpi);
- BLF_size(12, U.dpi);
- BLF_size(14, U.dpi);
+ BLF_size(font->blf_id, 11, U.dpi);
+ BLF_size(font->blf_id, 12, U.dpi);
+ BLF_size(font->blf_id, 14, U.dpi);
}
}
@@ -319,7 +318,6 @@ void uiStyleFontSet(uiFontStyle *fs)
{
uiFont *font= uifont_to_blfont(fs->uifont_id);
- BLF_set(font->blf_id);
- BLF_size(fs->points, U.dpi);
+ BLF_size(font->blf_id, fs->points, U.dpi);
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index dac689ca933..558cdb798c2 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -813,15 +813,15 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
uiStyleFontSet(fstyle);
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- but->strwidth= BLF_width(but->drawstr);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr);
but->ofs= 0;
while(but->strwidth > okwidth ) {
but->ofs++;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
/* textbut exception */
if(but->editstr && but->pos != -1) {
@@ -842,7 +842,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
}
if (fstyle->kerning==1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
@@ -856,9 +856,9 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
uiStyleFontSet(fstyle);
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- but->strwidth= BLF_width(but->drawstr);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr);
but->ofs= 0;
/* find the space after ':' separator */
@@ -873,7 +873,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
memmove(cp2-1, cp2, strlen(cp2)+1);
cp2--;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
if(but->strwidth < 10) break;
}
@@ -882,7 +882,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
while ((but->strwidth > okwidth) && (but->ofs < 2))
{
but->ofs++;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
if(but->strwidth < 10) break;
}
@@ -895,12 +895,12 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
but->drawstr[ pos-1 ] = 0;
pos--;
- but->strwidth= BLF_width(but->drawstr+but->ofs);
+ but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
if(but->strwidth < 10) break;
}
if (fstyle->kerning==1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
@@ -917,7 +917,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
fstyle->align= UI_STYLE_TEXT_CENTER;
if (fstyle->kerning==1) /* for BLF_width */
- BLF_enable(BLF_KERNING_DEFAULT);
+ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
/* text button selection and cursor */
if(but->editstr && but->pos != -1) {
@@ -935,7 +935,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
ch= but->drawstr[selsta_tmp];
but->drawstr[selsta_tmp]= 0;
- selsta_draw = BLF_width(but->drawstr+but->ofs);
+ selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
but->drawstr[selsta_tmp]= ch;
} else
@@ -944,7 +944,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
ch= but->drawstr[selend_tmp];
but->drawstr[selend_tmp]= 0;
- selwidth_draw = BLF_width(but->drawstr+but->ofs);
+ selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
but->drawstr[selend_tmp]= ch;
@@ -959,7 +959,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
ch= but->drawstr[pos];
but->drawstr[pos]= 0;
- t= BLF_width(but->drawstr+but->ofs) / but->aspect;
+ t= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs) / but->aspect;
but->drawstr[pos]= ch;
}
@@ -971,7 +971,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
if (fstyle->kerning == 1)
- BLF_disable(BLF_KERNING_DEFAULT);
+ BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
// ui_rasterpos_safe(x, y, but->aspect);
// if(but->type==IDPOIN) transopts= 0; // no translation, of course!
@@ -2839,7 +2839,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, char *name, int iconid,
cpoin= strchr(name, '|');
if(cpoin) {
*cpoin= 0;
- rect->xmax -= BLF_width(cpoin+1) + 10;
+ rect->xmax -= BLF_width(fstyle->uifont_id, cpoin+1) + 10;
}
glColor3ubv((unsigned char*)wt->wcol.text);
@@ -2882,8 +2882,8 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, char *name, int iconi
glColor3ubv((unsigned char*)wt->wcol.text_sel);
trect.xmin += 0;
- trect.xmax = trect.xmin + BLF_width(name) + 10;
+ trect.xmax = trect.xmin + BLF_width(fstyle->uifont_id, name) + 10;
trect.ymin += 10;
- trect.ymax = trect.ymin + BLF_height(name);
+ trect.ymax = trect.ymin + BLF_height(fstyle->uifont_id, name);
uiStyleFontDraw(fstyle, &trect, name);
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index d41317f7078..5e8cab7c4b3 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1702,8 +1702,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* draw vertical steps */
if (dfac > 0.0f) {
- BLF_default_rotation(90.0f);
-
+ BLF_rotation_default(90.0f);
+ BLF_enable_default(BLF_ROTATION);
+
for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) {
/* make prints look nicer for scrollers */
@@ -1713,7 +1714,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
scroll_printstr(vs, scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v');
}
- BLF_default_rotation(0.0f);
+ BLF_disable_default(BLF_ROTATION);
}
}
}
@@ -2053,12 +2054,10 @@ void UI_view2d_text_cache_draw(ARegion *ar)
yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
if(yofs<1) yofs= 1;
- BLF_clipping(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
- BLF_enable(BLF_CLIPPING);
-
+ BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
+ BLF_enable_default(BLF_CLIPPING);
BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, v2s->str);
-
- BLF_disable(BLF_CLIPPING);
+ BLF_disable_default(BLF_CLIPPING);
}
}
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index db7bb8419e8..2fab998b9b6 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -59,17 +59,16 @@
#include "console_intern.h"
+
+static int mono= -1; // XXX needs proper storage and change all the BLF_* here!
+
static void console_font_begin(SpaceConsole *sc)
{
- static int mono= -1; // XXX needs proper storage
-
if(mono == -1)
mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
- BLF_set(mono);
- BLF_aspect(1.0);
-
- BLF_size(sc->lheight-2, 72);
+ BLF_aspect(mono, 1.0);
+ BLF_size(mono, sc->lheight-2, 72);
}
static void console_line_color(unsigned char *fg, int type)
@@ -224,8 +223,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
glColor3ub(fg[0], fg[1], fg[2]);
/* last part needs no clipping */
- BLF_position(cdc->xy[0], cdc->xy[1], 0);
- BLF_draw(line_stride);
+ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
+ BLF_draw(mono, line_stride);
if(cdc->sel[0] != cdc->sel[1]) {
cdc->sel[0] += str_len - (cdc->console_width % str_len);
@@ -242,8 +241,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
eol = line_stride[cdc->console_width];
line_stride[cdc->console_width]= '\0';
- BLF_position(cdc->xy[0], cdc->xy[1], 0);
- BLF_draw(line_stride);
+ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
+ BLF_draw(mono, line_stride);
if(cdc->sel[0] != cdc->sel[1]) {
console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->console_width, cdc->lheight);
@@ -268,8 +267,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
glColor3ub(fg[0], fg[1], fg[2]);
- BLF_position(cdc->xy[0], cdc->xy[1], 0);
- BLF_draw(str);
+ BLF_position(mono, cdc->xy[0], cdc->xy[1], 0);
+ BLF_draw(mono, str);
if(cdc->sel[0] != cdc->sel[1])
console_draw_sel(cdc->sel, cdc->xy, str_len, cdc->cwidth, cdc->console_width, cdc->lheight);
@@ -301,7 +300,7 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
unsigned char fg[3];
console_font_begin(sc);
- cwidth = BLF_fixed_width();
+ cwidth = BLF_fixed_width(mono);
console_width= (ar->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN*2) )/cwidth;
if (console_width < 8) console_width= 8;
@@ -344,11 +343,11 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
/* command line */
if(prompt_len) {
- BLF_position(xy[0], xy[1], 0); xy[0] += cwidth * prompt_len;
- BLF_draw(sc->prompt);
+ BLF_position(mono, xy[0], xy[1], 0); xy[0] += cwidth * prompt_len;
+ BLF_draw(mono, sc->prompt);
}
- BLF_position(xy[0], xy[1], 0);
- BLF_draw(cl->line);
+ BLF_position(mono, xy[0], xy[1], 0);
+ BLF_draw(mono, cl->line);
/* cursor */
UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, (char *)fg);
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 2f056e4e0b4..0773ad96a7c 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -46,12 +46,11 @@
#include "BLF_api.h"
-
-
#include "IMB_imbuf_types.h"
#include "MEM_guardedalloc.h"
+#include "DNA_userdef_types.h"
#include "RNA_access.h"
@@ -329,11 +328,13 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon,
static void file_draw_string(int sx, int sy, const char* string, float width, int height, int flag)
{
+ uiStyle *style= U.uistyles.first;
int soffs;
char fname[FILE_MAXFILE];
float sw;
float x,y;
+
BLI_strncpy(fname,string, FILE_MAXFILE);
sw = shorten_string(fname, width, flag );
@@ -341,8 +342,9 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in
x = (float)(sx);
y = (float)(sy-height);
- BLF_position(x, y, 0);
- BLF_draw(fname);
+ uiStyleFontSet(&style->widget);
+ BLF_position(style->widget.uifont_id, x, y, 0);
+ BLF_draw(style->widget.uifont_id, fname);
}
void file_calc_previews(const bContext *C, ARegion *ar)
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index fbcc5c3cb42..64ca0a8e572 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -260,7 +260,7 @@ float file_string_width(const char* str)
{
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
- return BLF_width((char *)str);
+ return BLF_width(style->widget.uifont_id, (char *)str);
}
float file_font_pointsize()
@@ -269,7 +269,7 @@ float file_font_pointsize()
char tmp[2] = "X";
uiStyle *style= U.uistyles.first;
uiStyleFontSet(&style->widget);
- s = BLF_height(tmp);
+ s = BLF_height(style->widget.uifont_id, tmp);
return style->widget.points;
}
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 510429140d7..7ae432e3d6f 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -60,18 +60,15 @@
#include "text_intern.h"
/******************** text font drawing ******************/
+static int mono= -1; // XXX needs proper storage and change all the BLF_* here
static void text_font_begin(SpaceText *st)
{
- static int mono= -1; // XXX needs proper storage
-
if(mono == -1)
mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
- BLF_set(mono);
- BLF_aspect(1.0);
-
- BLF_size(st->lheight, 72);
+ BLF_aspect(mono, 1.0);
+ BLF_size(mono, st->lheight, 72);
}
static void text_font_end(SpaceText *st)
@@ -80,10 +77,10 @@ static void text_font_end(SpaceText *st)
static int text_font_draw(SpaceText *st, int x, int y, char *str)
{
- BLF_position(x, y, 0);
- BLF_draw(str);
+ BLF_position(mono, x, y, 0);
+ BLF_draw(mono, str);
- return BLF_width(str);
+ return BLF_width(mono, str);
}
static int text_font_draw_character(SpaceText *st, int x, int y, char c)
@@ -93,15 +90,15 @@ static int text_font_draw_character(SpaceText *st, int x, int y, char c)
str[0]= c;
str[1]= '\0';
- BLF_position(x, y, 0);
- BLF_draw(str);
+ BLF_position(mono, x, y, 0);
+ BLF_draw(mono, str);
return st->cwidth;
}
int text_font_width(SpaceText *st, char *str)
{
- return BLF_width(str);
+ return BLF_width(mono, str);
}
/****************** flatten string **********************/
@@ -1237,7 +1234,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
}
text_font_begin(st);
- st->cwidth= BLF_fixed_width();
+ st->cwidth= BLF_fixed_width(mono);
st->cwidth= MAX2(st->cwidth, 1);
/* draw line numbers background */
@@ -1307,7 +1304,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
void text_update_character_width(SpaceText *st)
{
text_font_begin(st);
- st->cwidth= BLF_fixed_width();
+ st->cwidth= BLF_fixed_width(mono);
st->cwidth= MAX2(st->cwidth, 1);
text_font_end(st);
}