diff options
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 224 |
1 files changed, 112 insertions, 112 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index a387b416c38..626c591c40f 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -62,13 +62,13 @@ static FontBLF *global_font[BLF_MAX_FONT] = {0}; /* Default size and dpi, for BLF_draw_default. */ -static int global_font_default= -1; -static int global_font_points= 11; -static int global_font_dpi= 72; +static int global_font_default = -1; +static int global_font_points = 11; +static int global_font_dpi = 72; -// XXX, should these be made into global_font_'s too? -int blf_mono_font= -1; -int blf_mono_font_render= -1; +/* XXX, should these be made into global_font_'s too? */ +int blf_mono_font = -1; +int blf_mono_font_render = -1; static FontBLF *BLF_get(int fontid) { @@ -81,11 +81,11 @@ int BLF_init(int points, int dpi) { int i; - for (i= 0; i < BLF_MAX_FONT; i++) - global_font[i]= NULL; + for (i = 0; i < BLF_MAX_FONT; i++) + global_font[i] = NULL; - global_font_points= points; - global_font_dpi= dpi; + global_font_points = points; + global_font_dpi = dpi; return blf_font_init(); } @@ -94,11 +94,11 @@ void BLF_exit(void) FontBLF *font; int i; - for (i= 0; i < BLF_MAX_FONT; i++) { - font= global_font[i]; + for (i = 0; i < BLF_MAX_FONT; i++) { + font = global_font[i]; if (font) { blf_font_free(font); - global_font[i]= NULL; + global_font[i] = NULL; } } @@ -110,8 +110,8 @@ void BLF_cache_clear(void) FontBLF *font; int i; - for (i= 0; i < BLF_MAX_FONT; i++) { - font= global_font[i]; + for (i = 0; i < BLF_MAX_FONT; i++) { + font = global_font[i]; if (font) blf_glyph_cache_clear(font); } @@ -122,8 +122,8 @@ static int blf_search(const char *name) FontBLF *font; int i; - for (i= 0; i < BLF_MAX_FONT; i++) { - font= global_font[i]; + for (i = 0; i < BLF_MAX_FONT; i++) { + font = global_font[i]; if (font && (!strcmp(font->name, name))) return i; } @@ -135,8 +135,8 @@ static int blf_search_available(void) { int i; - for (i= 0; i < BLF_MAX_FONT; i++) - if(!global_font[i]) + for (i = 0; i < BLF_MAX_FONT; i++) + if (!global_font[i]) return i; return -1; @@ -152,7 +152,7 @@ int BLF_load(const char *name) return -1; /* check if we already load this font. */ - i= blf_search(name); + i = blf_search(name); if (i >= 0) { /*font= global_font[i];*/ /*UNUSED*/ return i; @@ -164,13 +164,13 @@ int BLF_load(const char *name) return -1; } - filename= blf_dir_search(name); + filename = blf_dir_search(name); if (!filename) { printf("Can't find font: %s\n", name); return -1; } - font= blf_font_new(name, filename); + font = blf_font_new(name, filename); MEM_freeN(filename); if (!font) { @@ -178,7 +178,7 @@ int BLF_load(const char *name) return -1; } - global_font[i]= font; + global_font[i] = font; return i; } @@ -200,13 +200,13 @@ int BLF_load_unique(const char *name) return -1; } - filename= blf_dir_search(name); + filename = blf_dir_search(name); if (!filename) { printf("Can't find font: %s\n", name); return -1; } - font= blf_font_new(name, filename); + font = blf_font_new(name, filename); MEM_freeN(filename); if (!font) { @@ -214,13 +214,13 @@ int BLF_load_unique(const char *name) return -1; } - global_font[i]= font; + global_font[i] = font; return i; } void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { blf_font_attach_from_mem(font, mem, mem_size); @@ -235,7 +235,7 @@ int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) if (!name) return -1; - i= blf_search(name); + i = blf_search(name); if (i >= 0) { /*font= global_font[i];*/ /*UNUSED*/ return i; @@ -252,13 +252,13 @@ int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) return -1; } - font= blf_font_new_from_mem(name, mem, mem_size); + 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[i]= font; + global_font[i] = font; return i; } @@ -285,13 +285,13 @@ int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size) return -1; } - font= blf_font_new_from_mem(name, mem, mem_size); + 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[i]= font; + global_font[i] = font; return i; } @@ -300,19 +300,19 @@ void BLF_unload(const char *name) FontBLF *font; int i; - for (i= 0; i < BLF_MAX_FONT; i++) { - font= global_font[i]; + for (i = 0; i < BLF_MAX_FONT; i++) { + font = global_font[i]; if (font && (!strcmp(font->name, name))) { blf_font_free(font); - global_font[i]= NULL; + global_font[i] = NULL; } } } void BLF_enable(int fontid, int option) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { font->flags |= option; @@ -321,7 +321,7 @@ void BLF_enable(int fontid, int option) void BLF_disable(int fontid, int option) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { font->flags &= ~option; @@ -330,7 +330,7 @@ void BLF_disable(int fontid, int option) void BLF_enable_default(int option) { - FontBLF *font= BLF_get(global_font_default); + FontBLF *font = BLF_get(global_font_default); if (font) { font->flags |= option; @@ -339,7 +339,7 @@ void BLF_enable_default(int option) void BLF_disable_default(int option) { - FontBLF *font= BLF_get(global_font_default); + FontBLF *font = BLF_get(global_font_default); if (font) { font->flags &= ~option; @@ -348,18 +348,18 @@ void BLF_disable_default(int option) void BLF_aspect(int fontid, float x, float y, float z) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->aspect[0]= x; - font->aspect[1]= y; - font->aspect[2]= z; + font->aspect[0] = x; + font->aspect[1] = y; + font->aspect[2] = z; } } void BLF_matrix(int fontid, const double m[16]) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { memcpy(font->m, m, sizeof(font->m)); @@ -368,24 +368,24 @@ void BLF_matrix(int fontid, const double m[16]) void BLF_position(int fontid, float x, float y, float z) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { float xa, ya, za; float remainder; if (font->flags & BLF_ASPECT) { - xa= font->aspect[0]; - ya= font->aspect[1]; - za= font->aspect[2]; + xa = font->aspect[0]; + ya = font->aspect[1]; + za = font->aspect[2]; } else { - xa= 1.0f; - ya= 1.0f; - za= 1.0f; + xa = 1.0f; + ya = 1.0f; + za = 1.0f; } - remainder= x - floorf(x); + remainder = x - floorf(x); if (remainder > 0.4f && remainder < 0.6f) { if (remainder < 0.5f) x -= 0.1f * xa; @@ -393,7 +393,7 @@ void BLF_position(int fontid, float x, float y, float z) x += 0.1f * xa; } - remainder= y - floorf(y); + remainder = y - floorf(y); if (remainder > 0.4f && remainder < 0.6f) { if (remainder < 0.5f) y -= 0.1f * ya; @@ -401,7 +401,7 @@ void BLF_position(int fontid, float x, float y, float z) y += 0.1f * ya; } - remainder= z - floorf(z); + remainder = z - floorf(z); if (remainder > 0.4f && remainder < 0.6f) { if (remainder < 0.5f) z -= 0.1f * za; @@ -409,15 +409,15 @@ void BLF_position(int fontid, float x, float y, float z) z += 0.1f * za; } - font->pos[0]= x; - font->pos[1]= y; - font->pos[2]= z; + font->pos[0] = x; + font->pos[1] = y; + font->pos[2] = z; } } void BLF_size(int fontid, int size, int dpi) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { blf_font_size(font, size, dpi); @@ -426,10 +426,10 @@ void BLF_size(int fontid, int size, int dpi) void BLF_blur(int fontid, int size) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->blur= size; + font->blur = size; } } @@ -439,7 +439,7 @@ void BLF_draw_default(float x, float y, float z, const char *str, size_t len) return; if (global_font_default == -1) - global_font_default= blf_search("default"); + global_font_default = blf_search("default"); if (global_font_default == -1) { printf("Warning: Can't found default font!!\n"); @@ -458,7 +458,7 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l return; if (global_font_default == -1) - global_font_default= blf_search("default"); + global_font_default = blf_search("default"); if (global_font_default == -1) { printf("Warning: Can't found default font!!\n"); @@ -472,10 +472,10 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l void BLF_rotation_default(float angle) { - FontBLF *font= BLF_get(global_font_default); + FontBLF *font = BLF_get(global_font_default); if (font) { - font->angle= angle; + font->angle = angle; } } @@ -511,11 +511,11 @@ static void blf_draw__start(FontBLF *font, GLint *mode, GLint *param) if (font->flags & BLF_ROTATION) glRotatef(font->angle, 0.0f, 0.0f, 1.0f); - if(font->shadow || font->blur) + if (font->shadow || font->blur) glGetFloatv(GL_CURRENT_COLOR, font->orig_col); /* always bind the texture for the first glyph */ - font->tex_bind_state= -1; + font->tex_bind_state = -1; /* Save the current parameter to restore it later. */ glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param); @@ -544,7 +544,7 @@ static void blf_draw__end(GLint mode, GLint param) void BLF_draw(int fontid, const char *str, size_t len) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); GLint mode, param; if (font && font->glyph_cache) { @@ -556,7 +556,7 @@ void BLF_draw(int fontid, const char *str, size_t len) void BLF_draw_ascii(int fontid, const char *str, size_t len) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); GLint mode, param; if (font && font->glyph_cache) { @@ -568,7 +568,7 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len) void BLF_boundbox(int fontid, const char *str, rctf *box) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { blf_font_boundbox(font, str, box); @@ -577,7 +577,7 @@ void BLF_boundbox(int fontid, const char *str, rctf *box) void BLF_width_and_height(int fontid, const char *str, float *width, float *height) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { blf_font_width_and_height(font, str, width, height); @@ -586,7 +586,7 @@ void BLF_width_and_height(int fontid, const char *str, float *width, float *heig float BLF_width(int fontid, const char *str) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return blf_font_width(font, str); @@ -597,7 +597,7 @@ float BLF_width(int fontid, const char *str) float BLF_fixed_width(int fontid) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return blf_font_fixed_width(font); @@ -609,7 +609,7 @@ float BLF_fixed_width(int fontid) float BLF_width_default(const char *str) { if (global_font_default == -1) - global_font_default= blf_search("default"); + global_font_default = blf_search("default"); if (global_font_default == -1) { printf("Error: Can't found default font!!\n"); @@ -622,7 +622,7 @@ float BLF_width_default(const char *str) float BLF_height(int fontid, const char *str) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return blf_font_height(font, str); @@ -633,7 +633,7 @@ float BLF_height(int fontid, const char *str) float BLF_height_max(int fontid) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return font->glyph_cache->max_glyph_height; @@ -644,7 +644,7 @@ float BLF_height_max(int fontid) float BLF_width_max(int fontid) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return font->glyph_cache->max_glyph_width; @@ -655,7 +655,7 @@ float BLF_width_max(int fontid) float BLF_descender(int fontid) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return font->glyph_cache->descender; @@ -666,7 +666,7 @@ float BLF_descender(int fontid) float BLF_ascender(int fontid) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache) { return font->glyph_cache->ascender; @@ -678,7 +678,7 @@ float BLF_ascender(int fontid) float BLF_height_default(const char *str) { if (global_font_default == -1) - global_font_default= blf_search("default"); + global_font_default = blf_search("default"); if (global_font_default == -1) { printf("Error: Can't found default font!!\n"); @@ -692,88 +692,88 @@ float BLF_height_default(const char *str) void BLF_rotation(int fontid, float angle) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->angle= angle; + font->angle = angle; } } void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax) { - FontBLF *font= BLF_get(fontid); + FontBLF *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; + 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= BLF_get(global_font_default); + FontBLF *font = BLF_get(global_font_default); if (font) { - font->clip_rec.xmin= xmin; - font->clip_rec.ymin= ymin; - font->clip_rec.xmax= xmax; - font->clip_rec.ymax= ymax; + font->clip_rec.xmin = xmin; + font->clip_rec.ymin = ymin; + font->clip_rec.xmax = xmax; + font->clip_rec.ymax = ymax; } } void BLF_shadow(int fontid, int level, float r, float g, float b, float a) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->shadow= level; - font->shadow_col[0]= r; - font->shadow_col[1]= g; - font->shadow_col[2]= b; - font->shadow_col[3]= a; + font->shadow = level; + font->shadow_col[0] = r; + font->shadow_col[1] = g; + font->shadow_col[2] = b; + font->shadow_col[3] = a; } } void BLF_shadow_offset(int fontid, int x, int y) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->shadow_x= x; - font->shadow_y= y; + font->shadow_x = x; + font->shadow_y = y; } } void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->b_fbuf= fbuf; - font->b_cbuf= cbuf; - font->bw= w; - font->bh= h; - font->bch= nch; + font->b_fbuf = fbuf; + font->b_cbuf = cbuf; + font->bw = w; + font->bh = h; + font->bch = nch; } } void BLF_buffer_col(int fontid, float r, float g, float b, float a) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font) { - font->b_col[0]= r; - font->b_col[1]= g; - font->b_col[2]= b; - font->b_col[3]= a; + font->b_col[0] = r; + font->b_col[1] = g; + font->b_col[2] = b; + font->b_col[3] = a; } } void BLF_draw_buffer(int fontid, const char *str) { - FontBLF *font= BLF_get(fontid); + FontBLF *font = BLF_get(fontid); if (font && font->glyph_cache && (font->b_fbuf || font->b_cbuf)) { blf_font_buffer(font, str); |