[Bf-blender-cvs] [f75bbe2] master: Thumbnails: Add translations to font preview.
Bastien Montagne
noreply at git.blender.org
Fri Apr 10 15:35:50 CEST 2015
Commit: f75bbe27e23d2f79490aac82666ded1b1574083c
Author: Bastien Montagne
Date: Fri Apr 10 15:31:38 2015 +0200
Branches: master
https://developer.blender.org/rBf75bbe27e23d2f79490aac82666ded1b1574083c
Thumbnails: Add translations to font preview.
Not much to say, this is pretty straightforward.
We just have to add current locale to thumbnails 'signature', so that
previews get re-generated when we change locale...
Tested with Japanese and French.
Btw, I do not really understand why using BLF in ImBuf is badlevel... :/
===================================================================
M source/blender/blenfont/intern/blf_thumbs.c
M source/blender/imbuf/IMB_thumbs.h
M source/blender/imbuf/intern/thumbs.c
M source/blender/imbuf/intern/thumbs_font.c
===================================================================
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c
index afda6a3..3c400d0 100644
--- a/source/blender/blenfont/intern/blf_thumbs.c
+++ b/source/blender/blenfont/intern/blf_thumbs.c
@@ -45,6 +45,7 @@
#include "blf_internal_types.h"
#include "BLF_api.h"
+#include "BLF_translation.h"
#include "BLI_strict_flags.h"
@@ -97,7 +98,7 @@ void BLF_thumb_preview(
font->pos[1] -= font->glyph_cache->ascender * 1.1f;
- blf_font_buffer(font, draw_str[i]);
+ blf_font_buffer(font, BLF_translate_do(BLF_I18NCONTEXT_DEFAULT, draw_str[i]));
}
blf_font_free(font);
diff --git a/source/blender/imbuf/IMB_thumbs.h b/source/blender/imbuf/IMB_thumbs.h
index c3350ec..f977a63 100644
--- a/source/blender/imbuf/IMB_thumbs.h
+++ b/source/blender/imbuf/IMB_thumbs.h
@@ -82,6 +82,7 @@ void IMB_thumb_overlay_blend(unsigned int *thumb, int width, int height, float
/* special function for previewing fonts */
ImBuf *IMB_thumb_load_font(const char *filename, unsigned int x, unsigned int y);
+const char *IMB_thumb_load_font_get_language(void);
#ifdef __cplusplus
}
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c
index 59b8f27..2318553 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -483,18 +483,22 @@ void IMB_thumb_delete(const char *path, ThumbSize size)
/* create the thumb if necessary and manage failed and old thumbs */
-ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source)
+ImBuf *IMB_thumb_manage(const char *org_path, ThumbSize size, ThumbSource source)
{
char thumb_path[FILE_MAX];
char thumb_name[40];
char uri[URI_MAX];
const char *file_path;
+ const char *path;
char path_buff[FILE_MAX];
BLI_stat_t st;
ImBuf *img = NULL;
- file_path = path;
- UNUSED_VARS(path_buff);
+ path = file_path = org_path;
+ if (source == THB_SOURCE_FONT) {
+ BLI_snprintf(path_buff, sizeof(path_buff), "%s.%s", org_path, IMB_thumb_load_font_get_language());
+ path = path_buff;
+ }
if (BLI_stat(file_path, &st) == -1) {
return NULL;
diff --git a/source/blender/imbuf/intern/thumbs_font.c b/source/blender/imbuf/intern/thumbs_font.c
index c898231..7c94742 100644
--- a/source/blender/imbuf/intern/thumbs_font.c
+++ b/source/blender/imbuf/intern/thumbs_font.c
@@ -34,18 +34,19 @@
/* XXX, bad level call */
#include "../../blenfont/BLF_api.h"
+#include "../../blenfont/BLF_translation.h" /* 'N_' macro and BLF_lang_get()... */
struct ImBuf *IMB_thumb_load_font(const char *filename, unsigned int x, unsigned int y)
{
const int font_size = y / 4;
const char *thumb_str[] = {
- "AaBbCc",
+ N_("AaBbCc"),
- "The quick",
- "brown fox",
- "jumps over",
- "the lazy dog",
+ N_("The quick"),
+ N_("brown fox"),
+ N_("jumps over"),
+ N_("the lazy dog"),
};
struct ImBuf *ibuf;
@@ -71,3 +72,7 @@ struct ImBuf *IMB_thumb_load_font(const char *filename, unsigned int x, unsigned
return ibuf;
}
+const char *IMB_thumb_load_font_get_language(void)
+{
+ return BLF_lang_get();
+}
More information about the Bf-blender-cvs
mailing list