Commit: 67454a282d701a852464785f18dd9589d983b3a1 Author: Campbell Barton Date: Mon Apr 22 09:09:06 2019 +1000 Branches: master https://developer.blender.org/rB67454a282d701a852464785f18dd9589d983b3a1
Cleanup: style, use braces for blenfont =================================================================== M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_dir.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_font_win32_compat.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_thumbs.c =================================================================== diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 0da96226143..d16a4d7ed4d 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -86,8 +86,9 @@ int blf_mono_font_render = -1; static FontBLF *blf_get(int fontid) { - if (fontid >= 0 && fontid < BLF_MAX_FONT) + if (fontid >= 0 && fontid < BLF_MAX_FONT) { return global_font[fontid]; + } return NULL; } @@ -95,8 +96,9 @@ int BLF_init(void) { int i; - for (i = 0; i < BLF_MAX_FONT; i++) + for (i = 0; i < BLF_MAX_FONT; i++) { global_font[i] = NULL; + } global_font_points = 11; global_font_dpi = 72; @@ -151,8 +153,9 @@ static int blf_search(const char *name) for (i = 0; i < BLF_MAX_FONT; i++) { font = global_font[i]; - if (font && (STREQ(font->name, name))) + if (font && (STREQ(font->name, name))) { return i; + } } return -1; @@ -162,9 +165,11 @@ 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; } @@ -378,26 +383,32 @@ void BLF_position(int fontid, float x, float y, float z) remainder = x - floorf(x); if (remainder > 0.4f && remainder < 0.6f) { - if (remainder < 0.5f) + if (remainder < 0.5f) { x -= 0.1f * xa; - else + } + else { x += 0.1f * xa; + } } remainder = y - floorf(y); if (remainder > 0.4f && remainder < 0.6f) { - if (remainder < 0.5f) + if (remainder < 0.5f) { y -= 0.1f * ya; - else + } + else { y += 0.1f * ya; + } } remainder = z - floorf(z); if (remainder > 0.4f && remainder < 0.6f) { - if (remainder < 0.5f) + if (remainder < 0.5f) { z -= 0.1f * za; - else + } + else { z += 0.1f * za; + } } font->pos[0] = x; @@ -554,27 +565,32 @@ static void blf_draw_gl__start(FontBLF *font) /* always bind the texture for the first glyph */ font->tex_bind_state = 0; - if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0) + if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) == 0) { return; /* glyphs will be translated individually and batched. */ + } GPU_matrix_push(); - if (font->flags & BLF_MATRIX) + if (font->flags & BLF_MATRIX) { GPU_matrix_mul(font->m); + } GPU_matrix_translate_3fv(font->pos); - if (font->flags & BLF_ASPECT) + if (font->flags & BLF_ASPECT) { GPU_matrix_scale_3fv(font->aspect); + } - if (font->flags & BLF_ROTATION) + if (font->flags & BLF_ROTATION) { GPU_matrix_rotate_2d(RAD2DEG(font->angle)); + } } static void blf_draw_gl__end(FontBLF *font) { - if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0) + if ((font->flags & (BLF_ROTATION | BLF_MATRIX | BLF_ASPECT)) != 0) { GPU_matrix_pop(); + } } void BLF_draw_ex(int fontid, const char *str, size_t len, struct ResultBLF *r_info) diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 89378dc6181..204be5a86b2 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -55,8 +55,9 @@ static DirBLF *blf_dir_find(const char *path) p = global_font_dir.first; while (p) { - if (BLI_path_cmp(p->path, path) == 0) + if (BLI_path_cmp(p->path, path) == 0) { return p; + } p = p->next; } return NULL; @@ -67,8 +68,9 @@ void BLF_dir_add(const char *path) DirBLF *dir; dir = blf_dir_find(path); - if (dir) /* already in the list ? just return. */ + if (dir) { /* already in the list ? just return. */ return; + } dir = (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add"); dir->path = BLI_strdup(path); @@ -95,8 +97,9 @@ char **BLF_dir_get(int *ndir) int i, count; count = BLI_listbase_count(&global_font_dir); - if (!count) + if (!count) { return NULL; + } dirs = (char **)MEM_callocN(sizeof(char *) * count, "BLF_dir_get"); p = global_font_dir.first; @@ -138,8 +141,9 @@ char *blf_dir_search(const char *file) if (!s) { /* check the current directory, why not ? */ - if (BLI_exists(file)) + if (BLI_exists(file)) { s = BLI_strdup(file); + } } return s; @@ -166,14 +170,16 @@ char *blf_dir_metrics_search(const char *filename) s[2] = 'm'; /* first check .afm */ - if (BLI_exists(mfile)) + if (BLI_exists(mfile)) { return mfile; + } /* and now check .pfm */ s[0] = 'p'; - if (BLI_exists(mfile)) + if (BLI_exists(mfile)) { return mfile; + } } MEM_freeN(mfile); return NULL; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index ae406b103a7..7283ade3ae5 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -173,8 +173,9 @@ void blf_batch_draw_begin(FontBLF *font) void blf_batch_draw(void) { - if (g_batch.glyph_len == 0) + if (g_batch.glyph_len == 0) { return; + } GPU_blend(true); GPU_blend_set_func_separate( @@ -235,8 +236,9 @@ void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi) if (gc) { font->glyph_cache = gc; /* Optimization: do not call FT_Set_Char_Size if size did not change. */ - if (font->size == size && font->dpi == dpi) + if (font->size == size && font->dpi == dpi) { return; + } } err = FT_Set_Char_Size(font->face, 0, (FT_F26Dot6)(size * 64), dpi, dpi); @@ -251,10 +253,12 @@ void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi) if (!gc) { gc = blf_glyph_cache_new(font); - if (gc) + if (gc) { font->glyph_cache = gc; - else + } + else { font->glyph_cache = NULL; + } } } @@ -371,12 +375,15 @@ static void blf_font_draw_ex( while ((i < len) && str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (UNLIKELY(c == BLI_UTF8_ERR)) + if (UNLIKELY(c == BLI_UTF8_ERR)) { break; - if (UNLIKELY(g == NULL)) + } + if (UNLIKELY(g == NULL)) { continue; - if (has_kerning) + } + if (has_kerning) { BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x); + } /* do not return this loop if clipped, we want every character tested */ blf_glyph_render(font, g, (float)pen_x, (float)pen_y); @@ -416,10 +423,12 @@ static void blf_font_draw_ascii_ex( while ((c = *(str++)) && len--) { BLI_assert(c < 128); - if ((g = glyph_ascii_table[c]) == NULL) + if ((g = glyph_ascii_table[c]) == NULL) { continue; - if (has_kerning) + } + if (has_kerning) { BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x); + } /* do not return this loop if clipped, we want every character tested */ blf_glyph_render(font, g, (float)pen_x, (float)pen_y); @@ -458,17 +467,20 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth) while ((i < len) && str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (UNLIKELY(c == BLI_UTF8_ERR)) + if (UNLIKELY(c == BLI_UTF8_ERR)) { break; - if (UNLIKELY(g == NULL)) + } + if (UNLIKELY(g == NULL)) { continue; + } /* do not return this loop if clipped, we want every character tested */ blf_glyph_render(font, g, (float)pen_x, (float)pen_y); col = BLI_wcwidth((wchar_t)c); - if (col < 0) + if (col < 0) { col = 1; + } columns += col; pen_x += cwidth * col; @@ -507,12 +519,15 @@ static void blf_font_draw_buffer_ex( while ((i < len) && str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (UNLIKELY(c == BLI_UTF8_ERR)) + if (UNLIKELY(c == BLI_UTF8_ERR)) { break; - if (UNLIKELY(g == NULL)) + } + if (UNLIKELY(g == NULL)) { continue; - if (has_kerning) + } + if (has_kerning) { BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x); + } chx = pen_x + ((int)g->pos_x); chy = pen_y_basis + g->height; @@ -531,10 +546,12 @@ static void blf_font_draw_buffer_ex( int height_clip = g->height; int yb_start = g->pitch < 0 ? 0 : g->height - 1; - if (width_clip + chx > buf_info->w) + if (width_clip + chx > buf_info->w) { width_clip -= chx + width_clip - buf_info->w; - if (height_clip + pen_y > buf_info->h) + } + if (height_clip + pen_y > buf_info->h) { height_clip -= pen_y + height_clip - buf_info->h; + } /* drawing below the image? */ if (pen_y < 0) { @@ -570,10 +587,12 @@ static void blf_font_draw_buffer_ex( } } - if (g->pitch < 0) + if (g->pitch < 0) { yb++; - else + } + else { yb--; + } } } @@ -606,10 +625,12 @@ static void blf_font_draw_buffer_ex( } } - if (g->pitch < 0) + if (g->pitch < 0) { yb++; - else + } + else { yb--; + } } } } @@ -762,27 +783,34 @@ static void blf_font_boundbox_ex( while ((i < len) && str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (UNLIKELY(c == BLI_UTF8_ERR)) + if (UNLIKELY(c == BLI_UTF8_ERR)) { break; - if (UNLIKELY(g == NULL)) + } + if (UNLIKELY(g == NULL)) { continue; - if (has_kerning) + } + if (has_kerning) { BLF_KERNING_STEP_FAST(font, kern_mode, g_prev, g, c_prev, c, pen_x); + } gbox.xmin = (float)pen_x; gbox.xmax = (float)pen_x + g->advance; gbox.ymin = g->box.ymin + (float)pen_y; gbox.ymax = g->box.ymax + (float)pen_y; - if (gbox.xmin < box->xmin) + if (gbox.xmin < box->xmin) { box->xmin = gbox.xmin; - if (gbox.ymin < box->ymin) + } + if (gbox.ymin < box->ymin) { box->ymin = gbox.ym @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs