diff options
Diffstat (limited to 'source/blender/editors/interface/interface_style.c')
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 5f2a757d2e3..7d1596459dd 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -76,7 +76,7 @@ /* ********************************************** */ -static uiStyle *ui_style_new(ListBase *styles, const char *name) +static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id) { uiStyle *style= MEM_callocN(sizeof(uiStyle), "new style"); @@ -85,7 +85,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->panelzoom= 1.0; /* unused */ - style->paneltitle.uifont_id= UIFONT_DEFAULT; + style->paneltitle.uifont_id= uifont_id; style->paneltitle.points= 12; style->paneltitle.kerning= 1; style->paneltitle.shadow= 1; @@ -94,7 +94,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->paneltitle.shadowalpha= 0.15f; style->paneltitle.shadowcolor= 1.0f; - style->grouplabel.uifont_id= UIFONT_DEFAULT; + style->grouplabel.uifont_id= uifont_id; style->grouplabel.points= 12; style->grouplabel.kerning= 1; style->grouplabel.shadow= 3; @@ -102,7 +102,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->grouplabel.shady= -1; style->grouplabel.shadowalpha= 0.25f; - style->widgetlabel.uifont_id= UIFONT_DEFAULT; + style->widgetlabel.uifont_id= uifont_id; style->widgetlabel.points= 11; style->widgetlabel.kerning= 1; style->widgetlabel.shadow= 3; @@ -111,7 +111,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->widgetlabel.shadowalpha= 0.15f; style->widgetlabel.shadowcolor= 1.0f; - style->widget.uifont_id= UIFONT_DEFAULT; + style->widget.uifont_id= uifont_id; style->widget.points= 11; style->widget.kerning= 1; style->widget.shadowalpha= 0.25f; @@ -251,11 +251,19 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) } /* ************** helpers ************************ */ +/* XXX: read a style configure */ +uiStyle* UI_GetStyle(void) +{ + uiStyle *style = NULL; + /* offset is two struct uiStyle pointers */ + /* style = BLI_findstring( &U.uistyles, "Unifont Style", sizeof(style)*2 ) */; + return (style != NULL) ? style : U.uistyles.first; +} /* temporarily, does widget font */ int UI_GetStringWidth(const char *str) { - uiStyle *style= U.uistyles.first; + uiStyle *style= UI_GetStyle(); uiFontStyle *fstyle= &style->widget; int width; @@ -274,7 +282,7 @@ int UI_GetStringWidth(const char *str) /* temporarily, does widget font */ void UI_DrawString(float x, float y, const char *str) { - uiStyle *style= U.uistyles.first; + uiStyle *style= UI_GetStyle(); if (style->widget.kerning == 1) BLF_enable(style->widget.uifont_id, BLF_KERNING_DEFAULT); @@ -313,7 +321,7 @@ void uiStyleInit(void) for(font= U.uifonts.first; font; font= font->next) { if(font->uifont_id==UIFONT_DEFAULT) { - font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); + font->blf_id= BLF_load_mem_unique("default", (unsigned char *)get_datatoc_bunifont_ttf(), datatoc_bunifont_ttf_size); } else { font->blf_id= BLF_load(font->filename); @@ -337,7 +345,7 @@ void uiStyleInit(void) } if(style==NULL) { - ui_style_new(&U.uistyles, "Default Style"); + ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT ); } // XXX, this should be moved into a style, but for now best only load the monospaced font once. |