diff options
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 59 | ||||
-rw-r--r-- | source/blender/blenfont/BLF_types.h | 0 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 260 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 85 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image_gen.c | 56 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 80 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 36 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 33 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 25 | ||||
-rw-r--r-- | source/blender/python/generic/blf_api.c | 90 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 6 |
17 files changed, 414 insertions, 359 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index c898820b949..1cec570fd09 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -37,50 +37,47 @@ void BLF_exit(void); int BLF_load(char *name); int BLF_load_mem(char *name, unsigned char *mem, int mem_size); -/* Attach a file with metrics information from memory. */ -void BLF_metrics_attach(unsigned char *mem, int mem_size); +int BLF_load_unique(char *name); +int BLF_load_mem_unique(char *name, unsigned char *mem, int mem_size); -/* - * Set/Get the current font. - */ -void BLF_set(int fontid); -int BLF_get(void); +/* Attach a file with metrics information from memory. */ +void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size); -void BLF_aspect(float aspect); -void BLF_position(float x, float y, float z); -void BLF_size(int size, int dpi); +void BLF_aspect(int fontid, float aspect); +void BLF_position(int fontid, float x, float y, float z); +void BLF_size(int fontid, int size, int dpi); /* Draw the string using the default font, size and dpi. */ void BLF_draw_default(float x, float y, float z, char *str); /* Draw the string using the current font. */ -void BLF_draw(char *str); +void BLF_draw(int fontid, char *str); /* * This function return the bounding box of the string * and are not multiplied by the aspect. */ -void BLF_boundbox(char *str, struct rctf *box); +void BLF_boundbox(int fontid, char *str, struct rctf *box); /* * The next both function return the width and height * of the string, using the current font and both value * are multiplied by the aspect of the font. */ -float BLF_width(char *str); -float BLF_height(char *str); +float BLF_width(int fontid, char *str); +float BLF_height(int fontid, char *str); /* * The following function return the width and height of the string, but * just in one call, so avoid extra freetype2 stuff. */ -void BLF_width_and_height(char *str, float *width, float *height); +void BLF_width_and_height(int fontid, char *str, float *width, float *height); /* * For fixed width fonts only, returns the width of a * character. */ -float BLF_fixed_width(void); +float BLF_fixed_width(int fontid); /* * and this two function return the width and height @@ -91,27 +88,33 @@ float BLF_width_default(char *str); float BLF_height_default(char *str); /* - * set rotation for default font + * Set rotation for default font. + */ +void BLF_rotation_default(float angle); + +/* + * Enable/disable options to the default font. */ -void BLF_default_rotation(float angle); +void BLF_enable_default(int option); +void BLF_disable_default(int option); /* * By default, rotation and clipping are disable and * have to be enable/disable using BLF_enable/disable. */ -void BLF_rotation(float angle); -void BLF_clipping(float xmin, float ymin, float xmax, float ymax); -void BLF_blur(int size); +void BLF_rotation(int fontid, float angle); +void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax); +void BLF_blur(int fontid, int size); -void BLF_enable(int option); -void BLF_disable(int option); +void BLF_enable(int fontid, int option); +void BLF_disable(int fontid, int option); /* * Shadow options, level is the blur level, can be 3, 5 or 0 and * the other argument are the rgba color. * Take care that shadow need to be enable using BLF_enable!!. */ -void BLF_shadow(int level, float r, float g, float b, float a); +void BLF_shadow(int fontid, int level, float r, float g, float b, float a); /* * Set the offset for shadow text, this is the current cursor @@ -119,7 +122,7 @@ void BLF_shadow(int level, float r, float g, float b, float a); * this function, the current position is calculate only on * BLF_draw, so it's safe call this whenever you like. */ -void BLF_shadow_offset(int x, int y); +void BLF_shadow_offset(int fontid, int x, int y); /* * Set the buffer, size and number of channels to draw, one thing to take care is call @@ -130,18 +133,18 @@ void BLF_shadow_offset(int x, int y); * * BLF_buffer(NULL, NULL, 0, 0, 0); */ -void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch); +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch); /* * Set the color to be used for text. */ -void BLF_buffer_col(float r, float g, float b, float a); +void BLF_buffer_col(int fontid, float r, float g, float b, float a); /* * Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_ * it's not necessary set both buffer, NULL is valid here. */ -void BLF_draw_buffer(char *str); +void BLF_draw_buffer(int fontid, char *str); /* * Search the path directory to the locale files, this try all diff --git a/source/blender/blenfont/BLF_types.h b/source/blender/blenfont/BLF_types.h new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/source/blender/blenfont/BLF_types.h diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 9a65b15200f..1d227e271dd 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -61,14 +61,18 @@ FontBLF *global_font[BLF_MAX_FONT]; /* Number of font. */ int global_font_num= 0; -/* Current font. */ -int global_font_cur= 0; - /* Default size and dpi, for BLF_draw_default. */ int global_font_default= -1; int global_font_points= 11; int global_font_dpi= 72; +static FontBLF *BLF_get(int fontid) +{ + if (fontid >= 0 && fontid < BLF_MAX_FONT) + return(global_font[fontid]); + return(NULL); +} + int BLF_init(int points, int dpi) { int i; @@ -149,11 +153,48 @@ int BLF_load(char *name) return(i); } -void BLF_metrics_attach(unsigned char *mem, int mem_size) +int BLF_load_unique(char *name) +{ + FontBLF *font; + char *filename; + int i; + + if (!name) + return(-1); + + /* Don't search in the cache!! make a new + * object font, this is for keep fonts threads safe. + */ + if (global_font_num+1 >= BLF_MAX_FONT) { + printf("Too many fonts!!!\n"); + return(-1); + } + + filename= blf_dir_search(name); + if (!filename) { + printf("Can't find font: %s\n", name); + return(-1); + } + + font= blf_font_new(name, filename); + MEM_freeN(filename); + + if (!font) { + printf("Can't load font: %s\n", name); + return(-1); + } + + global_font[global_font_num]= font; + i= global_font_num; + global_font_num++; + return(i); +} + +void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) blf_font_attach_from_mem(font, mem, mem_size); } @@ -194,50 +235,91 @@ int BLF_load_mem(char *name, unsigned char *mem, int mem_size) return(i); } -void BLF_set(int fontid) +int BLF_load_mem_unique(char *name, unsigned char *mem, int mem_size) { - if (fontid >= 0 && fontid < BLF_MAX_FONT) - global_font_cur= fontid; + FontBLF *font; + int i; + + if (!name) + return(-1); + + /* + * Don't search in the cache, make a new object font! + * this is to keep the font thread safe. + */ + if (global_font_num+1 >= BLF_MAX_FONT) { + printf("Too many fonts!!!\n"); + return(-1); + } + + if (!mem || !mem_size) { + printf("Can't load font: %s from memory!!\n", name); + return(-1); + } + + font= blf_font_new_from_mem(name, mem, mem_size); + if (!font) { + printf("Can't load font: %s from memory!!\n", name); + return(-1); + } + + global_font[global_font_num]= font; + i= global_font_num; + global_font_num++; + return(i); +} + +void BLF_enable(int fontid, int option) +{ + FontBLF *font; + + font= BLF_get(fontid); + if (font) + font->flags |= option; } -int BLF_get(void) +void BLF_disable(int fontid, int option) { - return(global_font_cur); + FontBLF *font; + + font= BLF_get(fontid); + if (font) + font->flags &= ~option; } -void BLF_enable(int option) +void BLF_enable_default(int option) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(global_font_default); if (font) font->flags |= option; } -void BLF_disable(int option) +void BLF_disable_default(int option) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(global_font_default); if (font) font->flags &= ~option; } -void BLF_aspect(float aspect) +void BLF_aspect(int fontid, float aspect) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) font->aspect= aspect; } -void BLF_position(float x, float y, float z) +void BLF_position(int fontid, float x, float y, float z) { FontBLF *font; float remainder; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) { remainder= x - floor(x); if (remainder > 0.4 && remainder < 0.6) { @@ -261,20 +343,20 @@ void BLF_position(float x, float y, float z) } } -void BLF_size(int size, int dpi) +void BLF_size(int fontid, int size, int dpi) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) blf_font_size(font, size, dpi); } -void BLF_blur(int size) +void BLF_blur(int fontid, int size) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) font->blur= size; } @@ -295,38 +377,21 @@ void BLF_draw_default(float x, float y, float z, char *str) return; } - font= global_font[global_font_cur]; - if (font) { - old_font= global_font_cur; - old_point= font->size; - old_dpi= font->dpi; - } - - global_font_cur= global_font_default; - BLF_size(global_font_points, global_font_dpi); - BLF_position(x, y, z); - BLF_draw(str); - - /* restore the old font. */ - if (font) { - global_font_cur= old_font; - BLF_size(old_point, old_dpi); - } + BLF_size(global_font_default, global_font_points, global_font_dpi); + BLF_position(global_font_default, x, y, z); + BLF_draw(global_font_default, str); } -void BLF_default_rotation(float angle) +void BLF_rotation_default(float angle) { - - if (global_font_default>=0) { - global_font[global_font_default]->angle= angle; - if(angle) - global_font[global_font_default]->flags |= BLF_ROTATION; - else - global_font[global_font_default]->flags &= ~BLF_ROTATION; - } + FontBLF *font; + + font= BLF_get(global_font_default); + if (font) + font->angle= angle; } -void BLF_draw(char *str) +void BLF_draw(int fontid, char *str) { FontBLF *font; @@ -334,7 +399,7 @@ void BLF_draw(char *str) * The pixmap alignment hack is handle * in BLF_position (old ui_rasterpos_safe). */ - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) { glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); @@ -355,39 +420,39 @@ void BLF_draw(char *str) } } -void BLF_boundbox(char *str, rctf *box) +void BLF_boundbox(int fontid, char *str, rctf *box) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) blf_font_boundbox(font, str, box); } -void BLF_width_and_height(char *str, float *width, float *height) +void BLF_width_and_height(int fontid, char *str, float *width, float *height) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) blf_font_width_and_height(font, str, width, height); } -float BLF_width(char *str) +float BLF_width(int fontid, char *str) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) return(blf_font_width(font, str)); return(0.0f); } -float BLF_fixed_width(void) +float BLF_fixed_width(int fontid) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) return(blf_font_fixed_width(font)); return(0.0f); @@ -407,30 +472,17 @@ float BLF_width_default(char *str) return(0.0f); } - font= global_font[global_font_cur]; - if (font) { - old_font= global_font_cur; - old_point= font->size; - old_dpi= font->dpi; - } + BLF_size(global_font_default, global_font_points, global_font_dpi); + width= BLF_width(global_font_default, str); - global_font_cur= global_font_default; - BLF_size(global_font_points, global_font_dpi); - width= BLF_width(str); - - /* restore the old font. */ - if (font) { - global_font_cur= old_font; - BLF_size(old_point, old_dpi); - } return(width); } -float BLF_height(char *str) +float BLF_height(int fontid, char *str) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) return(blf_font_height(font, str)); return(0.0f); @@ -450,39 +502,39 @@ float BLF_height_default(char *str) return(0.0f); } - font= global_font[global_font_cur]; - if (font) { - old_font= global_font_cur; - old_point= font->size; - old_dpi= font->dpi; - } - - global_font_cur= global_font_default; - BLF_size(global_font_points, global_font_dpi); - height= BLF_height(str); + BLF_size(global_font_default, global_font_points, global_font_dpi); + height= BLF_height(global_font_default, str); - /* restore the old font. */ - if (font) { - global_font_cur= old_font; - BLF_size(old_point, old_dpi); - } return(height); } -void BLF_rotation(float angle) +void BLF_rotation(int fontid, float angle) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) font->angle= angle; } -void BLF_clipping(float xmin, float ymin, float xmax, float ymax) +void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax) +{ + FontBLF *font; + + font= BLF_get(fontid); + if (font) { + font->clip_rec.xmin= xmin; + font->clip_rec.ymin= ymin; + font->clip_rec.xmax= xmax; + font->clip_rec.ymax= ymax; + } +} + +void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(global_font_default); if (font) { font->clip_rec.xmin= xmin; font->clip_rec.ymin= ymin; @@ -491,11 +543,11 @@ void BLF_clipping(float xmin, float ymin, float xmax, float ymax) } } -void BLF_shadow(int level, float r, float g, float b, float a) +void BLF_shadow(int fontid, int level, float r, float g, float b, float a) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) { font->shadow= level; font->shadow_col[0]= r; @@ -505,22 +557,22 @@ void BLF_shadow(int level, float r, float g, float b, float a) } } -void BLF_shadow_offset(int x, int y) +void BLF_shadow_offset(int fontid, int x, int y) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) { font->shadow_x= x; font->shadow_y= y; } } -void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch) +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) { font->b_fbuf= fbuf; font->b_cbuf= cbuf; @@ -530,11 +582,11 @@ void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h } } -void BLF_buffer_col(float r, float g, float b, float a) +void BLF_buffer_col(int fontid, float r, float g, float b, float a) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) { font->b_col[0]= r; font->b_col[1]= g; @@ -543,11 +595,11 @@ void BLF_buffer_col(float r, float g, float b, float a) } } -void BLF_draw_buffer(char *str) +void BLF_draw_buffer(int fontid, char *str) { FontBLF *font; - font= global_font[global_font_cur]; + font= BLF_get(fontid); if (font) blf_font_buffer(font, str); } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 7d194461c78..66e6171d9ee 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1019,17 +1019,17 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) extern int datatoc_bmonofont_ttf_size; extern char datatoc_bmonofont_ttf[]; -// XXX - copied from text_font_begin -void stamp_font_begin(int size) -{ - static int mono= -1; +// XXX - copied from text_font_begin ! Change all the BLF_* here +static int mono= -1; +int stamp_font_begin(int size) +{ if (mono == -1) - mono= BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); + mono= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - BLF_set(mono); - BLF_aspect(1.0); - BLF_size(size, 72); + BLF_aspect(mono, 1.0); + BLF_size(mono, size, 72); + return(mono); // XXX This is for image_gen.c!! } void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) @@ -1049,24 +1049,24 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i stamp_font_begin(scene->r.stamp_font_id); - BLF_buffer(rectf, rect, width, height, channels); - BLF_buffer_col(scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); - pad= BLF_width("--"); + BLF_buffer(mono, rectf, rect, width, height, channels); + BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); + pad= BLF_width(mono, "--"); x= 0; y= height; if (stamp_data.file[0]) { /* Top left corner */ - BLF_width_and_height(stamp_data.file, &w, &h); + BLF_width_and_height(mono, stamp_data.file, &w, &h); y -= h; /* also a little of space to the background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3); /* and draw the text. */ - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.file); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.file); /* the extra pixel for background. */ y -= 4; @@ -1074,14 +1074,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File */ if (stamp_data.note[0]) { - BLF_width_and_height(stamp_data.note, &w, &h); + BLF_width_and_height(mono, stamp_data.note, &w, &h); y -= h; /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2); - BLF_position(x, y+1, 0.0); - BLF_draw_buffer(stamp_data.note); + BLF_position(mono, x, y+1, 0.0); + BLF_draw_buffer(mono, stamp_data.note); /* the extra pixel for background. */ y -= 4; @@ -1089,14 +1089,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - BLF_width_and_height(stamp_data.date, &w, &h); + BLF_width_and_height(mono, stamp_data.date, &w, &h); y -= h; /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.date); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.date); /* the extra pixel for background. */ y -= 4; @@ -1104,14 +1104,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Top left corner, below File, Date or Note */ if (stamp_data.rendertime[0]) { - BLF_width_and_height(stamp_data.rendertime, &w, &h); + BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); y -= h; /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3); - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.rendertime); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.rendertime); } x= 0; @@ -1119,14 +1119,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - BLF_width_and_height(stamp_data.marker, &w, &h); + BLF_width_and_height(mono, stamp_data.marker, &w, &h); /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.marker); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.marker); /* space width. */ x += w + pad; @@ -1134,45 +1134,44 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* Left bottom corner */ if (stamp_data.time[0]) { - BLF_width_and_height(stamp_data.time, &w, &h); + BLF_width_and_height(mono, stamp_data.time, &w, &h); /* extra space for background */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.time); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.time); /* space width. */ x += w + pad; } if (stamp_data.frame[0]) { - BLF_width_and_height(stamp_data.frame, &w, &h); + BLF_width_and_height(mono, stamp_data.frame, &w, &h); /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - - BLF_draw_buffer(stamp_data.frame); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.frame); /* space width. */ x += w + pad; } if (stamp_data.camera[0]) { - BLF_width_and_height(stamp_data.camera, &w, &h); + BLF_width_and_height(mono, stamp_data.camera, &w, &h); /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3); - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.camera); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.camera); } if (stamp_data.scene[0]) { - BLF_width_and_height(stamp_data.scene, &w, &h); + BLF_width_and_height(mono, stamp_data.scene, &w, &h); /* Bottom right corner, with an extra space because blenfont is too strict! */ x= width - w - 2; @@ -1181,12 +1180,12 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3); /* and pad the text. */ - BLF_position(x, y+3, 0.0); - BLF_draw_buffer(stamp_data.scene); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.scene); } if (stamp_data.strip[0]) { - BLF_width_and_height(stamp_data.scene, &w, &h); + BLF_width_and_height(mono, stamp_data.scene, &w, &h); /* Top right corner, with an extra space because blenfont is too strict! */ x= width - w - pad; @@ -1195,12 +1194,12 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3); - BLF_position(x, y, 0.0); - BLF_draw_buffer(stamp_data.strip); + BLF_position(mono, x, y, 0.0); + BLF_draw_buffer(mono, stamp_data.strip); } /* cleanup the buffer. */ - BLF_buffer(NULL, NULL, 0, 0, 0); + BLF_buffer(mono, NULL, NULL, 0, 0, 0); } void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index eb256e3775b..9248ce69280 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -24,6 +24,7 @@ */ #include <math.h> +#include <stdlib.h> #include "BLI_math_color.h" #include "BLF_api.h" @@ -297,17 +298,17 @@ static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int } /* defined in image.c */ -extern void stamp_font_begin(int size); +extern int stamp_font_begin(int size); static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline) { - int x, y; + int x, y, mono; int pen_x, pen_y; char text[3]= {'A', '1', '\0'}; /* hard coded size! */ - stamp_font_begin(54); - BLF_buffer(rect_float, rect, width, height, 4); + mono= stamp_font_begin(54); + BLF_buffer(mono, rect_float, rect, width, height, 4); for(y= 0; y < height; y+=step) { @@ -320,29 +321,29 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width pen_y = y + 44; /* terribly crappy outline font! */ - BLF_buffer_col(1.0, 1.0, 1.0, 1.0); - - BLF_position(pen_x-outline, pen_y, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x+outline, pen_y, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x, pen_y-outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x, pen_y+outline, 0.0); - BLF_draw_buffer(text); + BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0); + + BLF_position(mono, pen_x-outline, pen_y, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x+outline, pen_y, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x, pen_y-outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x, pen_y+outline, 0.0); + BLF_draw_buffer(mono, text); - BLF_position(pen_x-outline, pen_y-outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x+outline, pen_y+outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x-outline, pen_y+outline, 0.0); - BLF_draw_buffer(text); - BLF_position(pen_x+outline, pen_y-outline, 0.0); - BLF_draw_buffer(text); - - BLF_buffer_col(0.0, 0.0, 0.0, 1.0); - BLF_position(pen_x, pen_y, 0.0); - BLF_draw_buffer(text); + BLF_position(mono, pen_x-outline, pen_y-outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x+outline, pen_y+outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x-outline, pen_y+outline, 0.0); + BLF_draw_buffer(mono, text); + BLF_position(mono, pen_x+outline, pen_y-outline, 0.0); + BLF_draw_buffer(mono, text); + + BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0); + BLF_position(mono, pen_x, pen_y, 0.0); + BLF_draw_buffer(mono, text); text[1]++; } @@ -350,8 +351,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width } /* cleanup the buffer. */ - BLF_buffer(0, 0, 0, 0, 0); - + BLF_buffer(mono, NULL, NULL, 0, 0, 0); } void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int width, int height) 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); } diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c index f1cbd0f7e7e..a12120df14a 100644 --- a/source/blender/python/generic/blf_api.c +++ b/source/blender/python/generic/blf_api.c @@ -28,25 +28,26 @@ #include "../../blenfont/BLF_api.h" static char py_blf_position_doc[] = -".. function:: position(x, y, z)\n" +".. function:: position(fontid, x, y, z)\n" "\n" " Set the position for drawing text.\n"; static PyObject *py_blf_position(PyObject *self, PyObject *args) { + int fontid; float x, y, z; - if (!PyArg_ParseTuple(args, "fff:BLF.position", &x, &y, &z)) + if (!PyArg_ParseTuple(args, "ifff:BLF.position", &fontid, &x, &y, &z)) return NULL; - BLF_position(x, y, z); + BLF_position(fontid, x, y, z); Py_RETURN_NONE; } static char py_blf_size_doc[] = -".. function:: size(size, dpi)\n" +".. function:: size(fontid, size, dpi)\n" "\n" " Set the size and dpi for drawing text.\n" "\n" @@ -57,19 +58,19 @@ static char py_blf_size_doc[] = static PyObject *py_blf_size(PyObject *self, PyObject *args) { - int size, dpi; + int fontid, size, dpi; - if (!PyArg_ParseTuple(args, "ii:BLF.size", &size, &dpi)) + if (!PyArg_ParseTuple(args, "iii:BLF.size", &fontid, &size, &dpi)) return NULL; - BLF_size(size, dpi); + BLF_size(fontid, size, dpi); Py_RETURN_NONE; } static char py_blf_aspect_doc[] = -".. function:: aspect(aspect)\n" +".. function:: aspect(fontid, aspect)\n" "\n" " Set the aspect for drawing text.\n" "\n" @@ -79,18 +80,19 @@ static char py_blf_aspect_doc[] = static PyObject *py_blf_aspect(PyObject *self, PyObject *args) { float aspect; + int fontid; - if (!PyArg_ParseTuple(args, "f:BLF.aspect", &aspect)) + if (!PyArg_ParseTuple(args, "if:BLF.aspect", &fontid, &aspect)) return NULL; - BLF_aspect(aspect); + BLF_aspect(fontid, aspect); Py_RETURN_NONE; } static char py_blf_blur_doc[] = -".. function:: blur(radius)\n" +".. function:: blur(fontid, radius)\n" "\n" " Set the blur radius for drawing text.\n" "\n" @@ -99,19 +101,19 @@ static char py_blf_blur_doc[] = static PyObject *py_blf_blur(PyObject *self, PyObject *args) { - int blur; + int blur, fontid; - if (!PyArg_ParseTuple(args, "i:BLF.blur", &blur)) + if (!PyArg_ParseTuple(args, "ii:BLF.blur", &fontid, &blur)) return NULL; - BLF_blur(blur); + BLF_blur(fontid, blur); Py_RETURN_NONE; } static char py_blf_draw_doc[] = -".. function:: draw(text)\n" +".. function:: draw(fontid, text)\n" "\n" " Draw text in the current context.\n" "\n" @@ -121,17 +123,18 @@ static char py_blf_draw_doc[] = static PyObject *py_blf_draw(PyObject *self, PyObject *args) { char *text; + int fontid; - if (!PyArg_ParseTuple(args, "s:BLF.draw", &text)) + if (!PyArg_ParseTuple(args, "is:BLF.draw", &fontid, &text)) return NULL; - BLF_draw(text); + BLF_draw(fontid, text); Py_RETURN_NONE; } static char py_blf_dimensions_doc[] = -".. function:: dimensions(text)\n" +".. function:: dimensions(fontid, text)\n" "\n" " Return the width and hight of the text.\n" "\n" @@ -145,11 +148,12 @@ static PyObject *py_blf_dimensions(PyObject *self, PyObject *args) char *text; float r_width, r_height; PyObject *ret; + int fontid; - if (!PyArg_ParseTuple(args, "s:BLF.dimensions", &text)) + if (!PyArg_ParseTuple(args, "is:BLF.dimensions", &fontid, &text)) return NULL; - BLF_width_and_height(text, &r_width, &r_height); + BLF_width_and_height(fontid, text, &r_width, &r_height); ret= PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, PyFloat_FromDouble(r_width)); @@ -158,24 +162,25 @@ static PyObject *py_blf_dimensions(PyObject *self, PyObject *args) } static char py_blf_clipping_doc[] = -".. function:: clipping(xmin, ymin, xmax, ymax)\n" +".. function:: clipping(fontid, xmin, ymin, xmax, ymax)\n" "\n" " Set the clipping, enable/disable using CLIPPING.\n"; static PyObject *py_blf_clipping(PyObject *self, PyObject *args) { float xmin, ymin, xmax, ymax; + int fontid; - if (!PyArg_ParseTuple(args, "ffff:BLF.clipping", &xmin, &ymin, &xmax, &ymax)) + if (!PyArg_ParseTuple(args, "iffff:BLF.clipping", &fontid, &xmin, &ymin, &xmax, &ymax)) return NULL; - BLF_clipping(xmin, ymin, xmax, ymax); + BLF_clipping(fontid, xmin, ymin, xmax, ymax); Py_RETURN_NONE; } static char py_blf_disable_doc[] = -".. function:: disable(option)\n" +".. function:: disable(fontid, option)\n" "\n" " Disable option.\n" "\n" @@ -184,18 +189,18 @@ static char py_blf_disable_doc[] = static PyObject *py_blf_disable(PyObject *self, PyObject *args) { - int option; + int option, fontid; - if (!PyArg_ParseTuple(args, "i:BLF.disable", &option)) + if (!PyArg_ParseTuple(args, "ii:BLF.disable", &fontid, &option)) return NULL; - BLF_disable(option); + BLF_disable(fontid, option); Py_RETURN_NONE; } static char py_blf_enable_doc[] = -".. function:: enable(option)\n" +".. function:: enable(fontid, option)\n" "\n" " Enable option.\n" "\n" @@ -204,18 +209,18 @@ static char py_blf_enable_doc[] = static PyObject *py_blf_enable(PyObject *self, PyObject *args) { - int option; + int option, fontid; - if (!PyArg_ParseTuple(args, "i:BLF.enable", &option)) + if (!PyArg_ParseTuple(args, "ii:BLF.enable", &fontid, &option)) return NULL; - BLF_enable(option); + BLF_enable(fontid, option); Py_RETURN_NONE; } static char py_blf_rotation_doc[] = -".. function:: rotation(angle)\n" +".. function:: rotation(fontid, angle)\n" "\n" " Set the text rotation angle, enable/disable using ROTATION.\n" "\n" @@ -225,17 +230,18 @@ static char py_blf_rotation_doc[] = static PyObject *py_blf_rotation(PyObject *self, PyObject *args) { float angle; + int fontid; - if (!PyArg_ParseTuple(args, "f:BLF.rotation", &angle)) + if (!PyArg_ParseTuple(args, "if:BLF.rotation", &fontid, &angle)) return NULL; - BLF_rotation(angle); + BLF_rotation(fontid, angle); Py_RETURN_NONE; } static char py_blf_shadow_doc[] = -".. function:: shadow(level, r, g, b, a)\n" +".. function:: shadow(fontid, level, r, g, b, a)\n" "\n" " Shadow options, enable/disable using SHADOW .\n" "\n" @@ -244,10 +250,10 @@ static char py_blf_shadow_doc[] = static PyObject *py_blf_shadow(PyObject *self, PyObject *args) { - int level; + int level, fontid; float r, g, b, a; - if (!PyArg_ParseTuple(args, "iffff:BLF.shadow", &level, &r, &g, &b, &a)) + if (!PyArg_ParseTuple(args, "iiffff:BLF.shadow", &fontid, &level, &r, &g, &b, &a)) return NULL; if (level != 0 && level != 3 && level != 5) { @@ -255,24 +261,24 @@ static PyObject *py_blf_shadow(PyObject *self, PyObject *args) return NULL; } - BLF_shadow(level, r, g, b, a); + BLF_shadow(fontid, level, r, g, b, a); Py_RETURN_NONE; } static char py_blf_shadow_offset_doc[] = -".. function:: shadow_offset(x, y)\n" +".. function:: shadow_offset(fontid, x, y)\n" "\n" " Set the offset for shadow text.\n"; static PyObject *py_blf_shadow_offset(PyObject *self, PyObject *args) { - int x, y; + int x, y, fontid; - if (!PyArg_ParseTuple(args, "ii:BLF.shadow_offset", &x, &y)) + if (!PyArg_ParseTuple(args, "iii:BLF.shadow_offset", &fontid, &x, &y)) return NULL; - BLF_shadow_offset(x, y); + BLF_shadow_offset(fontid, x, y); Py_RETURN_NONE; } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 306db16132a..6ea8352b95a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1165,9 +1165,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse sprintf(version_str, "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); sprintf(revision_str, "r%s", build_rev); - BLF_size(style->widgetlabel.points, U.dpi); - ver_width = BLF_width(version_str)+5; - rev_width = BLF_width(revision_str)+5; + BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi); + ver_width = BLF_width(style->widgetlabel.uifont_id, version_str)+5; + rev_width = BLF_width(style->widgetlabel.uifont_id, revision_str)+5; #endif //NAN_BUILDINFO block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); |