Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_thumbs.c
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "blf_internal.h" | #include "blf_internal.h" | ||||
| #include "blf_internal_types.h" | #include "blf_internal_types.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "CLG_log.h" | |||||
| #include "BLI_strict_flags.h" | #include "BLI_strict_flags.h" | ||||
| static CLG_LogRef LOG = {"blf.thumbs"}; | |||||
| /** | /** | ||||
| * 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( | void BLF_thumb_preview( | ||||
| const char *filename, | const char *filename, | ||||
| const char **draw_str, const unsigned char draw_str_lines, | const char **draw_str, const unsigned char draw_str_lines, | ||||
| const float font_color[4], const int font_size, | const float font_color[4], const int font_size, | ||||
| unsigned char *buf, int w, int h, int channels) | unsigned char *buf, int w, int h, int channels) | ||||
| { | { | ||||
| const unsigned int dpi = 72; | const unsigned int dpi = 72; | ||||
| const int font_size_min = 6; | const int font_size_min = 6; | ||||
| int font_size_curr; | int font_size_curr; | ||||
| /* shrink 1/th each line */ | /* shrink 1/th each line */ | ||||
| int font_shrink = 4; | int font_shrink = 4; | ||||
| FontBLF *font; | FontBLF *font; | ||||
| int i; | int i; | ||||
| /* Create a new blender font obj and fill it with default values */ | /* Create a new blender font obj and fill it with default values */ | ||||
| font = blf_font_new("thumb_font", filename); | font = blf_font_new("thumb_font", filename); | ||||
| if (!font) { | if (!font) { | ||||
| printf("Info: Can't load font '%s', no preview possible\n", filename); | CLOG_WARN(&LOG, "Can't load font '%s', no preview possible", filename); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Would be done via the BLF API, but we're not using a fontid here */ | /* Would be done via the BLF API, but we're not using a fontid here */ | ||||
| font->buf_info.cbuf = buf; | font->buf_info.cbuf = buf; | ||||
| font->buf_info.ch = channels; | font->buf_info.ch = channels; | ||||
| font->buf_info.w = w; | font->buf_info.w = w; | ||||
| font->buf_info.h = h; | font->buf_info.h = h; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||