diff options
author | Diego Borghetti <bdiego@gmail.com> | 2009-08-18 23:26:53 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2009-08-18 23:26:53 +0400 |
commit | 7d812822bd9c522efc0730a4f219ccec9cfb4a57 (patch) | |
tree | abd0a537d339cb3f4c63a05ab9016b96312671ca /source/blender/blenfont/intern/blf.c | |
parent | 94511c672920e8ae0ebca4fca2a563a46d07b85b (diff) |
Stamp info back only for float buffer. (next commit add unsigned char).
A couple of new functions:
BLF_width_and_height - Merge of BLF_width and BLF_height in one call to avoid freetype2 stuff.
BLF_buffer - Set the buffer, size and number of channel.
BLF_buffer_col - Set the text color (the alpha is not used right now).
BLF_draw_buffer - Draw the text in the current buffer.
Also tweak a little the boundbox and draw function to avoid access the freetype2 and use the cache info.
By default the font size is 12, the UI still need work to allow change the font and size.
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index ded89d18387..8cb237a19ac 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -371,6 +371,15 @@ void BLF_boundbox(char *str, rctf *box) blf_font_boundbox(font, str, box); } +void BLF_width_and_height(char *str, float *width, float *height) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + blf_font_width_and_height(font, str, width, height); +} + float BLF_width(char *str) { FontBLF *font; @@ -513,3 +522,39 @@ void BLF_shadow_offset(int x, int y) font->shadow_y= y; } } + +void BLF_buffer(float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) { + font->b_fbuf= fbuf; + font->b_cbuf= cbuf; + font->bw= w; + font->bh= h; + font->bch= nch; + } +} + +void BLF_buffer_col(float r, float g, float b, float a) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) { + font->b_col[0]= r; + font->b_col[1]= g; + font->b_col[2]= b; + font->b_col[3]= a; + } +} + +void BLF_draw_buffer(char *str) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + blf_font_buffer(font, str); +} |