forked from bartvdbraak/blender
Fix Broken Font Preview (reported over IRC by kopias, thanks).
Broken by font wrap commit rBf2341f829654c4dc97, there was actually two things here: * Using non-initialized color (which lead to transparent drawing...), we need to use new `blf_draw_buffer__start/end` helpers here too, made them shared internally. * Using `draw_str_i18n_nbr` as `draw_str[i]` length, ugh! That's the number of utf8 glyphs of translated string, not the length of untranslated string! This fix must be backported to final 2.76.
This commit is contained in:
parent
41d0547490
commit
ffe03cd264
@ -908,7 +908,7 @@ void BLF_buffer_col(int fontid, float r, float g, float b, float a)
|
||||
}
|
||||
|
||||
|
||||
static void blf_draw_buffer__start(FontBLF *font)
|
||||
void blf_draw_buffer__start(FontBLF *font)
|
||||
{
|
||||
FontBufInfoBLF *buf_info = &font->buf_info;
|
||||
|
||||
@ -925,7 +925,7 @@ static void blf_draw_buffer__start(FontBLF *font)
|
||||
srgb_to_linearrgb_v4(buf_info->col_float, buf_info->col_init);
|
||||
}
|
||||
}
|
||||
static void blf_draw_buffer__end(void) {}
|
||||
void blf_draw_buffer__end(void) {}
|
||||
|
||||
void BLF_draw_buffer_ex(
|
||||
int fontid, const char *str, size_t len,
|
||||
|
@ -47,6 +47,9 @@ char *blf_dir_metrics_search(const char *filename);
|
||||
int blf_font_init(void);
|
||||
void blf_font_exit(void);
|
||||
|
||||
void blf_draw_buffer__start(struct FontBLF *font);
|
||||
void blf_draw_buffer__end(void);
|
||||
|
||||
struct FontBLF *blf_font_new(const char *name, const char *filename);
|
||||
struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size);
|
||||
void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size);
|
||||
|
@ -89,6 +89,8 @@ void BLF_thumb_preview(
|
||||
|
||||
font_size_curr = font_size;
|
||||
|
||||
blf_draw_buffer__start(font);
|
||||
|
||||
for (i = 0; i < draw_str_lines; i++) {
|
||||
const char *draw_str_i18n = BLT_translate_do(BLT_I18NCONTEXT_DEFAULT, draw_str[i]);
|
||||
const size_t draw_str_i18n_len = strlen(draw_str_i18n);
|
||||
@ -110,12 +112,13 @@ void BLF_thumb_preview(
|
||||
if (blf_font_count_missing_chars(
|
||||
font, draw_str_i18n, draw_str_i18n_len, &draw_str_i18n_nbr) > (draw_str_i18n_nbr / 2))
|
||||
{
|
||||
blf_font_draw_buffer(font, draw_str[i], (size_t)draw_str_i18n_nbr, NULL);
|
||||
blf_font_draw_buffer(font, draw_str[i], strlen(draw_str[i]), NULL);
|
||||
}
|
||||
else {
|
||||
blf_font_draw_buffer(font, draw_str_i18n, draw_str_i18n_len, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
blf_draw_buffer__end();
|
||||
blf_font_free(font);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user