diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-26 19:33:42 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-26 19:33:42 +0300 |
commit | cf0820d6285c3a9379dd529ee50dcf39e2efa21c (patch) | |
tree | 08fb7672ce9f8e355ca2e99f6a52a14e3584f986 /source/blender/editors | |
parent | 782d7b312ff6799258fb318e2aa5bbd64dbd2a9d (diff) |
change monospace font to be an extern, not good final design but better then loading the same font 3 times.
need to load twice still because render may use the font in a thread.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_info/textview.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 6 |
3 files changed, 23 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 0baee38d396..f7079c04a66 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -264,6 +264,9 @@ void UI_DrawString(float x, float y, const char *str) BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT); } +int blf_mono_font= -1; +int blf_mono_font_render= -1; + /* ************** init exit ************************ */ /* called on each startup.blend read */ @@ -314,6 +317,20 @@ 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_aspect(blf_mono_font, 1.0); + 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_aspect(blf_mono_font_render, 1.0); + BLF_size(blf_mono_font_render, 12, 72); } void uiStyleFontSet(uiFontStyle *fs) diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 5f2ed46789e..315130136a2 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -39,18 +39,10 @@ #include "textview.h" - -static int mono= -1; // XXX needs proper storage and change all the BLF_* here! - - static void console_font_begin(TextViewContext *sc) { - if(mono == -1) { - mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - } - - BLF_aspect(mono, 1.0); - BLF_size(mono, sc->lheight-2, 72); + BLF_aspect(blf_mono_font, 1.0); + BLF_size(blf_mono_font, sc->lheight-2, 72); } typedef struct ConsoleDrawContext { @@ -95,6 +87,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str int rct_ofs= cdc->lheight/4; int tot_lines = (str_len/cdc->console_width)+1; /* total number of lines for wrapping */ int y_next = (str_len > cdc->console_width) ? cdc->xy[1]+cdc->lheight*tot_lines : cdc->xy[1]+cdc->lheight; + const int mono= blf_mono_font; /* just advance the height */ if(cdc->draw==0) { @@ -228,6 +221,7 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick int xy[2], y_prev; int sel[2]= {-1, -1}; /* defaults disabled */ unsigned char fg[3], bg[3]; + const int mono= blf_mono_font; console_font_begin(tvc); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 2b27186041f..3b0d8bb7a29 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -56,13 +56,11 @@ #include "text_intern.h" /******************** text font drawing ******************/ -static int mono= -1; // XXX needs proper storage and change all the BLF_* here +// XXX, fixme +#define mono blf_mono_font static void text_font_begin(SpaceText *st) { - if(mono == -1) - mono= BLF_load_mem("monospace", (unsigned char*)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - BLF_aspect(mono, 1.0); BLF_size(mono, st->lheight, 72); } |