diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 911a94cb56a..18932ffdac8 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -174,12 +174,12 @@ char **BLF_dir_get(int *ndir); void BLF_dir_free(char **dirs, int count); /* font->flags. */ -#define BLF_ROTATION (1<<0) -#define BLF_CLIPPING (1<<1) -#define BLF_SHADOW (1<<2) -#define BLF_KERNING_DEFAULT (1<<3) -#define BLF_MATRIX (1<<4) -#define BLF_ASPECT (1<<5) +#define BLF_ROTATION (1 << 0) +#define BLF_CLIPPING (1 << 1) +#define BLF_SHADOW (1 << 2) +#define BLF_KERNING_DEFAULT (1 << 3) +#define BLF_MATRIX (1 << 4) +#define BLF_ASPECT (1 << 5) #define BLF_DRAW_STR_DUMMY_MAX 1024 diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 824f1715f3c..4fde9fe6787 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -163,10 +163,10 @@ int blf_dir_split(const char *str, char *file, int *size) file[i] = str[i]; file[i] = '.'; - file[i+1] = 't'; - file[i+2] = 't'; - file[i+3] = 'f'; - file[i+4] = '\0'; + file[i + 1] = 't'; + file[i + 2] = 't'; + file[i + 3] = 'f'; + file[i + 4] = '\0'; s++; *size = atoi(s); return 1; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 7a4e1d4b781..1b4ce59067d 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -45,7 +45,7 @@ #include "BLI_blenlib.h" -#include "BLI_linklist.h" /* linknode */ +#include "BLI_linklist.h" /* linknode */ #include "BLI_math.h" #include "BIF_gl.h" @@ -103,7 +103,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font) if (glyph_ascii_table['0'] == NULL) { GlyphBLF *g; unsigned int i; - for (i = 0; i<256; i++) { + for (i = 0; i < 256; i++) { g = blf_glyph_search(font->glyph_cache, i); if (!g) { FT_UInt glyph_index = FT_Get_Char_Index(font->face, i); @@ -263,7 +263,7 @@ void blf_font_buffer(FontBLF *font, const char *str) /* don't draw beyond the buffer bounds */ int width_clip = g->width; int height_clip = g->height; - int yb_start = g->pitch < 0 ? 0 : g->height-1; + int yb_start = g->pitch < 0 ? 0 : g->height - 1; if (width_clip + chx > font->bw) width_clip -= chx + width_clip - font->bw; @@ -285,7 +285,7 @@ void blf_font_buffer(FontBLF *font, const char *str) if (a > 0.0f) { float alphatest; - fbuf = font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + fbuf = font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y) * font->bw)); if (a >= 1.0f) { fbuf[0] = font->b_col[0]; fbuf[1] = font->b_col[1]; @@ -293,10 +293,10 @@ void blf_font_buffer(FontBLF *font, const char *str) fbuf[3] = (alphatest = (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f; } else { - fbuf[0] = (font->b_col[0]*a) + (fbuf[0] * (1-a)); - fbuf[1] = (font->b_col[1]*a) + (fbuf[1] * (1-a)); - fbuf[2] = (font->b_col[2]*a) + (fbuf[2] * (1-a)); - fbuf[3] = (alphatest = (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f; + fbuf[0] = (font->b_col[0] * a) + (fbuf[0] * (1 - a)); + fbuf[1] = (font->b_col[1] * a) + (fbuf[1] * (1 - a)); + fbuf[2] = (font->b_col[2] * a) + (fbuf[2] * (1 - a)); + fbuf[3] = (alphatest = (fbuf[3] + (font->b_col[3] * a))) < 1.0f ? alphatest : 1.0f; } } } @@ -316,7 +316,7 @@ void blf_font_buffer(FontBLF *font, const char *str) if (a > 0.0f) { int alphatest; - cbuf = font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + cbuf = font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y) * font->bw)); if (a >= 1.0f) { cbuf[0] = b_col_char[0]; cbuf[1] = b_col_char[1]; @@ -324,10 +324,10 @@ void blf_font_buffer(FontBLF *font, const char *str) cbuf[3] = (alphatest = ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255; } else { - cbuf[0] = (b_col_char[0]*a) + (cbuf[0] * (1-a)); - cbuf[1] = (b_col_char[1]*a) + (cbuf[1] * (1-a)); - cbuf[2] = (b_col_char[2]*a) + (cbuf[2] * (1-a)); - cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < + cbuf[0] = (b_col_char[0] * a) + (cbuf[0] * (1 - a)); + cbuf[1] = (b_col_char[1] * a) + (cbuf[1] * (1 - a)); + cbuf[2] = (b_col_char[2] * a) + (cbuf[2] * (1 - a)); + cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((font->b_col[3] * a) * 255.0f))) < 255 ? alphatest : 255; } } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 9309cf15667..39945bf19b0 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -82,7 +82,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); - gc->textures = (GLuint *)malloc(sizeof(GLuint)*256); + gc->textures = (GLuint *)malloc(sizeof(GLuint) * 256); gc->ntex = 256; gc->cur_tex = -1; gc->x_offs = 0; @@ -147,8 +147,8 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) } } - if (gc->cur_tex+1 > 0) - glDeleteTextures(gc->cur_tex+1, gc->textures); + if (gc->cur_tex + 1 > 0) + glDeleteTextures(gc->cur_tex + 1, gc->textures); free((void *)gc->textures); MEM_freeN(gc); } @@ -163,7 +163,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) if (gc->cur_tex >= gc->ntex) { gc->ntex *= 2; - gc->textures = (GLuint *)realloc((void *)gc->textures, sizeof(GLuint)*gc->ntex); + gc->textures = (GLuint *)realloc((void *)gc->textures, sizeof(GLuint) * gc->ntex); } gc->p2_width = blf_next_p2((gc->rem_glyphs * gc->max_glyph_width) + (gc->pad * 2)); @@ -223,7 +223,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) if (sharp) err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO); else - err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ + err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ if (err) return NULL; @@ -314,11 +314,11 @@ static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, floa static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[25] = {1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f, - 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, - 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f, - 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, - 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f}; + float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f, + 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, + 2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f, + 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, + 1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f}; float color[4], *fp = soft; int dx, dy; @@ -331,7 +331,7 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x for (dy = -2; dy < 3; dy++, fp++) { color[3] = *(fp) * shadow_col[3]; glColor4fv(color); - blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy); } } @@ -340,9 +340,9 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[9] = {1/16.0f, 2/16.0f, 1/16.0f, - 2/16.0f, 4/16.0f, 2/16.0f, - 1/16.0f, 2/16.0f, 1/16.0f}; + float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f, + 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, + 1 / 16.0f, 2 / 16.0f, 1 / 16.0f}; float color[4], *fp = soft; int dx, dy; @@ -355,7 +355,7 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x for (dy = -1; dy < 2; dy++, fp++) { color[3] = *(fp) * shadow_col[3]; glColor4fv(color); - blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy); } } diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 96d3a231ba5..88d34b5e36f 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -42,7 +42,7 @@ #include -#if defined (_WIN32) +#if defined(_WIN32) #include #endif @@ -83,7 +83,7 @@ static const char *locales[] = { "catalan", "ca_AD", "czech", "cs_CZ", "ptb", "pt", -#if defined (_WIN32) && !defined(FREE_WINDOWS) +#if defined(_WIN32) && !defined(FREE_WINDOWS) "Chinese (Simplified)_China.1252", "zh_CN", "Chinese (Traditional)_China.1252", "zh_TW", #else @@ -170,19 +170,19 @@ void BLF_lang_set(const char *str) int ok = 1; const char *long_locale = locales[2 * U.language]; - if ((U.transopts&USER_DOTRANSLATE) == 0) + if ((U.transopts & USER_DOTRANSLATE) == 0) return; if (str) short_locale = str; else - short_locale = locales[ 2 * U.language + 1]; + short_locale = locales[2 * U.language + 1]; -#if defined (_WIN32) && !defined(FREE_WINDOWS) +#if defined(_WIN32) && !defined(FREE_WINDOWS) if (short_locale) { char *envStr; - if (U.language == 0)/* use system setting */ + if (U.language == 0) /* use system setting */ envStr = BLI_sprintfN("LANG=%s", getenv("LANG")); else envStr = BLI_sprintfN("LANG=%s", short_locale); @@ -201,8 +201,8 @@ void BLF_lang_set(const char *str) } #else { - static char default_lang[64] ="\0"; - static char default_language[64] ="\0"; + static char default_lang[64] = "\0"; + static char default_language[64] = "\0"; if (default_lang[0] == 0) get_language_variable("LANG", default_lang, sizeof(default_lang)); diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index 12fa15afa3c..9c863da9eba 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -39,7 +39,7 @@ /* needed for windows version of gettext */ #ifndef LC_MESSAGES -# define LC_MESSAGES 1729 +# define LC_MESSAGES 1729 #endif #endif @@ -57,7 +57,7 @@ #include "DNA_userdef_types.h" /* For user settings. */ #ifdef WITH_INTERNATIONAL -static const char unifont_filename[] ="droidsans.ttf.gz"; +static const char unifont_filename[] = "droidsans.ttf.gz"; static unsigned char *unifont_ttf = NULL; static int unifont_size = 0; @@ -70,7 +70,7 @@ unsigned char *BLF_get_unifont(int *unifont_size_r) BLI_snprintf(unifont_path, sizeof(unifont_path), "%s/%s", fontpath, unifont_filename); - unifont_ttf = (unsigned char*)BLI_file_ungzip_to_mem(unifont_path, &unifont_size); + unifont_ttf = (unsigned char *)BLI_file_ungzip_to_mem(unifont_path, &unifont_size); } else { printf("%s: 'fonts' data path not found for international font, continuing\n", __func__); @@ -90,7 +90,7 @@ void BLF_free_unifont(void) #endif -const char* BLF_gettext(const char *msgid) +const char *BLF_gettext(const char *msgid) { #ifdef WITH_INTERNATIONAL if (msgid && msgid[0]) @@ -124,7 +124,7 @@ const char *BLF_pgettext(const char *context, const char *message) sprintf(msg_ctxt_id, "%s%s%s", context, GETTEXT_CONTEXT_GLUE, message); - translation = (char*)dcgettext(TEXT_DOMAIN_NAME, msg_ctxt_id, LC_MESSAGES); + translation = (char *)dcgettext(TEXT_DOMAIN_NAME, msg_ctxt_id, LC_MESSAGES); if (dynamic_msg_ctxt_id) free(dynamic_msg_ctxt_id);