Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenfont/intern/blf_thumbs.c')
-rw-r--r--source/blender/blenfont/intern/blf_thumbs.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index a75072f854f..bafa927a440 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -32,26 +32,34 @@
void BLF_thumb_preview(const char *filepath,
const char **draw_str,
const char **i18n_draw_str,
- const unsigned char draw_str_lines,
+ const uchar draw_str_lines,
const float font_color[4],
const int font_size,
- unsigned char *buf,
- int w,
- int h,
- int channels)
+ uchar *buf,
+ const int w,
+ const int h,
+ const int channels)
{
- const unsigned int dpi = 72;
+ const uint dpi = 72;
const int font_size_min = 6;
int font_size_curr;
/* shrink 1/th each line */
int font_shrink = 4;
- FontBLF *font;
+ /* While viewing thumbnails in font directories this function can be called simultaneously from a
+ * greater number of threads than we want the FreeType cache to keep open at a time. Therefore
+ * pass own FT_Library to font creation so that it is not managed by the FreeType cache system.
+ */
- /* Create a new blender font obj and fill it with default values */
- font = blf_font_new("thumb_font", filepath);
+ FT_Library ft_library = NULL;
+ if (FT_Init_FreeType(&ft_library) != FT_Err_Ok) {
+ return;
+ }
+
+ FontBLF *font = blf_font_new_ex("thumb_font", filepath, NULL, 0, ft_library);
if (!font) {
printf("Info: Can't load font '%s', no preview possible\n", filepath);
+ FT_Done_FreeType(ft_library);
return;
}
@@ -87,7 +95,7 @@ void BLF_thumb_preview(const char *filepath,
font->pos[1] -= (int)((float)blf_font_ascender(font) * 1.1f);
/* We fallback to default english strings in case not enough chars are available in current
- * font for given translated string (useful in non-latin i18n context, like Chinese,
+ * font for given translated string (useful in non-Latin i18n context, like Chinese,
* since many fonts will then show nothing but ugly 'missing char' in their preview).
* Does not handle all cases, but much better than nothing.
*/
@@ -102,4 +110,5 @@ void BLF_thumb_preview(const char *filepath,
blf_draw_buffer__end();
blf_font_free(font);
+ FT_Done_FreeType(ft_library);
}