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.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 03676ae5e06..8e206f35b7f 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -1,4 +1,4 @@
-/**
+/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -136,7 +136,9 @@ static uiFont *uifont_to_blfont(int id)
/* *************** draw ************************ */
-void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
+
+void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
+ float *r_xofs, float *r_yofs)
{
float height;
int xofs=0, yofs;
@@ -165,16 +167,26 @@ void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, char *str)
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str);
+ BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
BLF_disable(fs->uifont_id, BLF_SHADOW);
if (fs->kerning == 1)
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
+
+ *r_xofs= xofs;
+ *r_yofs= yofs;
+}
+
+void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, const char *str)
+{
+ float xofs, yofs;
+ uiStyleFontDrawExt(fs, rect, str,
+ &xofs, &yofs);
}
/* drawn same as above, but at 90 degree angle */
-void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
+void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
{
float height;
int xofs, yofs;
@@ -218,7 +230,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str);
+ BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
BLF_disable(fs->uifont_id, BLF_ROTATION);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
@@ -230,7 +242,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, char *str)
/* ************** helpers ************************ */
/* temporarily, does widget font */
-int UI_GetStringWidth(char *str)
+int UI_GetStringWidth(const char *str)
{
uiStyle *style= U.uistyles.first;
uiFontStyle *fstyle= &style->widget;
@@ -249,13 +261,19 @@ int UI_GetStringWidth(char *str)
}
/* temporarily, does widget font */
-void UI_DrawString(float x, float y, char *str)
+void UI_DrawString(float x, float y, const char *str)
{
uiStyle *style= U.uistyles.first;
+ if (style->widget.kerning == 1)
+ BLF_enable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
+
uiStyleFontSet(&style->widget);
BLF_position(style->widget.uifont_id, x, y, 0.0f);
- BLF_draw(style->widget.uifont_id, str);
+ BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */
+
+ if (style->widget.kerning == 1)
+ BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
}
/* ************** init exit ************************ */
@@ -308,6 +326,18 @@ void uiStyleInit(void)
if(style==NULL) {
ui_style_new(&U.uistyles, "Default Style");
}
+
+ // XXX, this should be moved into a style, but for now best only load the monospaced font once.
+ if (blf_mono_font == -1)
+ blf_mono_font= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
+
+ BLF_size(blf_mono_font, 12, 72);
+
+ /* second for rendering else we get threading problems */
+ if (blf_mono_font_render == -1)
+ blf_mono_font_render= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
+
+ BLF_size(blf_mono_font_render, 12, 72);
}
void uiStyleFontSet(uiFontStyle *fs)