Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_thumbs.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * This function is used for generating thumbnail previews. | * This function is used for generating thumbnail previews. | ||||
| * | * | ||||
| * \note called from a thread, so it bypasses the normal BLF_* api (which isn't thread-safe). | * \note called from a thread, so it bypasses the normal BLF_* api (which isn't thread-safe). | ||||
| */ | */ | ||||
| void BLF_thumb_preview(const char *filename, | void BLF_thumb_preview(const char *filename, | ||||
| const char **draw_str, | const char **draw_str, | ||||
| const char **i18n_draw_str, | |||||
| const unsigned char draw_str_lines, | const unsigned char draw_str_lines, | ||||
| const float font_color[4], | const float font_color[4], | ||||
| const int font_size, | const int font_size, | ||||
| unsigned char *buf, | unsigned char *buf, | ||||
| int w, | int w, | ||||
| int h, | int h, | ||||
| int channels) | int channels) | ||||
| { | { | ||||
| Show All 24 Lines | void BLF_thumb_preview(const char *filename, | ||||
| memcpy(font->buf_info.col_init, font_color, sizeof(font->buf_info.col_init)); | memcpy(font->buf_info.col_init, font_color, sizeof(font->buf_info.col_init)); | ||||
| font->pos[1] = (float)h; | font->pos[1] = (float)h; | ||||
| font_size_curr = font_size; | font_size_curr = font_size; | ||||
| blf_draw_buffer__start(font); | blf_draw_buffer__start(font); | ||||
| for (i = 0; i < draw_str_lines; i++) { | for (i = 0; i < draw_str_lines; i++) { | ||||
| const char *draw_str_i18n = BLT_translate_do(BLT_I18NCONTEXT_DEFAULT, draw_str[i]); | const char *draw_str_i18n = i18n_draw_str[i] != NULL ? i18n_draw_str[i] : draw_str[i]; | ||||
| const size_t draw_str_i18n_len = strlen(draw_str_i18n); | const size_t draw_str_i18n_len = strlen(draw_str_i18n); | ||||
| int draw_str_i18n_nbr = 0; | int draw_str_i18n_nbr = 0; | ||||
| blf_font_size(font, (unsigned int)MAX2(font_size_min, font_size_curr), dpi); | blf_font_size(font, (unsigned int)MAX2(font_size_min, font_size_curr), dpi); | ||||
| /* font->glyph_cache remains NULL if blf_font_size() failed to set font size */ | /* font->glyph_cache remains NULL if blf_font_size() failed to set font size */ | ||||
| if (!font->glyph_cache) { | if (!font->glyph_cache) { | ||||
| break; | break; | ||||
| Show All 25 Lines | |||||