Translation: reload font on enabling/disabling use international fonts.

This commit is contained in:
Brecht Van Lommel
2011-09-21 15:15:30 +00:00
parent a12e06dc35
commit ae0124157f
7 changed files with 35 additions and 9 deletions

View File

@@ -610,6 +610,7 @@ void UI_remove_popup_handlers(struct ListBase *handlers, uiPopupBlockHandle *pop
void UI_init(void);
void UI_init_userdef(void);
void UI_reinit_font(void);
void UI_exit(void);
/* Layout

View File

@@ -3552,6 +3552,11 @@ void UI_init_userdef(void)
uiStyleInit();
}
void UI_reinit_font()
{
uiStyleInit();
}
void UI_exit(void)
{
ui_resources_free();

View File

@@ -323,13 +323,28 @@ void uiStyleInit(void)
if(font->uifont_id==UIFONT_DEFAULT) {
#ifdef INTERNATIONAL
int unifont_size;
unsigned char *unifont_ttf= BLF_get_unifont(&unifont_size);
int font_size= datatoc_bfont_ttf_size;
unsigned char *font_ttf= (unsigned char*)datatoc_bfont_ttf;
static int last_font_size = 0;
if(unifont_ttf)
font->blf_id= BLF_load_mem_unique("default", unifont_ttf, unifont_size);
else
font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
/* use unicode font for translation */
if(U.transopts & USER_DOTRANSLATE) {
font_ttf= BLF_get_unifont(&font_size);
if(!font_ttf) {
/* fall back if not found */
font_size= datatoc_bfont_ttf_size;
font_ttf= (unsigned char*)datatoc_bfont_ttf;
}
}
/* relload only if needed */
if(last_font_size != font_size) {
BLF_unload("default");
last_font_size = font_size;
}
font->blf_id= BLF_load_mem("default", font_ttf, font_size);
#else
font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
#endif

View File

@@ -2488,7 +2488,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
uiLayout *ui_abs;
uiBlock *block;
uiBut *but;
uiStyle *style= U.uistyles.first;
uiStyle *style= UI_GetStyle();
int width;
int icon=0;

View File

@@ -129,7 +129,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
block= uiBeginBlock(C, ar, "socket menu", UI_EMBOSS);
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, U.uistyles.first), 0);
layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, UI_GetStyle()), 0);
uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE);
@@ -788,7 +788,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColor(TH_TEXT_HI);
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header),
MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, U.uistyles.first);
MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, UI_GetStyle());
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL);
uiBlockLayoutResolve(gnode->block, NULL, NULL);

View File

@@ -65,6 +65,8 @@
#include "MEM_guardedalloc.h"
#include "MEM_CacheLimiterC-Api.h"
#include "UI_interface.h"
static void rna_userdef_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -79,7 +81,9 @@ static void rna_userdef_dpi_update(Main *bmain, Scene *scene, PointerRNA *ptr)
static void rna_userdef_language_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
{
BLF_cache_clear();
BLF_lang_set(NULL);
UI_reinit_font();
}
static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, PointerRNA *ptr)

View File

@@ -340,6 +340,7 @@ void uiItemS(struct uiLayout *layout){}
void uiItemFullR(struct uiLayout *layout, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int flag, char *name, int icon){}
void uiLayoutSetContextPointer(struct uiLayout *layout, char *name, struct PointerRNA *ptr){}
char *uiLayoutIntrospect(struct uiLayout *layout){return (char *)NULL;}
void UI_reinit_font() {}
/* rna template */
void uiTemplateAnyID(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, char *text){}