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/editors/interface/interface_style.c')
-rw-r--r--source/blender/editors/interface/interface_style.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 8d4b4209120..d242da8e480 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -44,6 +44,7 @@
#include "BLI_string.h"
#include "BKE_global.h"
+#include "BKE_font.h"
#include "BLF_api.h"
@@ -76,7 +77,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 +86,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 +95,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 +103,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 +112,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 +252,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 +283,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 +322,17 @@ void uiStyleInit(void)
for(font= U.uifonts.first; font; font= font->next) {
if(font->uifont_id==UIFONT_DEFAULT) {
+#ifdef INTERNATIONAL
+ int unifont_size;
+ unsigned char *unifont_ttf= BKE_font_get_unifont(&unifont_size);
+
+ 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);
+#else
font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+#endif
}
else {
font->blf_id= BLF_load(font->filename);
@@ -337,7 +356,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.