diff options
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 2 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 9 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 84 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal_types.h | 5 |
4 files changed, 85 insertions, 15 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index d6f0cf38558..adf9742cc9f 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -68,6 +68,8 @@ float BLF_height(char *str); */ void BLF_rotation(float angle); void BLF_clipping(float xmin, float ymin, float xmax, float ymax); +void BLF_blur(int size); + void BLF_enable(int option); void BLF_disable(int option); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 686e54e4986..e5c1e675294 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -280,6 +280,15 @@ void BLF_size(int size, int dpi) (*font->size_set)(font, size, dpi); } +void BLF_blur(int size) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + font->blur= size; +} + void BLF_draw(char *str) { FontBLF *font; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 628e5f3e6af..063093efb1d 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -433,6 +433,69 @@ void blf_glyph_free(GlyphBLF *g) MEM_freeN(g); } +static void blf_glyph_texture_draw(float uv[2][2], float dx, float y1, float dx1, float y2) +{ + + glBegin(GL_QUADS); + glTexCoord2f(uv[0][0], uv[0][1]); + glVertex2f(dx, y1); + + glTexCoord2f(uv[0][0], uv[1][1]); + glVertex2f(dx, y2); + + glTexCoord2f(uv[1][0], uv[1][1]); + glVertex2f(dx1, y2); + + glTexCoord2f(uv[1][0], uv[0][1]); + glVertex2f(dx1, y1); + glEnd(); + +} + +static void blf_glyph_texture5_draw(float uv[2][2], float x1, float y1, float x2, float y2) +{ + float soft[25]= { + 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f, + 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, + 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f, + 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, + 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f}; + + float color[4], *fp= soft; + int dx, dy; + + glGetFloatv(GL_CURRENT_COLOR, color); + + for(dx=-2; dx<3; dx++) { + for(dy=-2; dy<3; dy++, fp++) { + glColor4f(color[0], color[1], color[2], fp[0]*color[3]); + blf_glyph_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + } + } + + glColor4fv(color); +} + +static void blf_glyph_texture3_draw(float uv[2][2], float x1, float y1, float x2, float y2) +{ + float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f}; + float color[4], *fp= soft; + int dx, dy; + + glGetFloatv(GL_CURRENT_COLOR, color); + + for(dx=-1; dx<2; dx++) { + for(dy=-1; dy<2; dy++, fp++) { + glColor4f(color[0], color[1], color[2], fp[0]*color[3]); + blf_glyph_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + } + } + + glColor4fv(color); +} + + + int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) { GlyphTextureBLF *gt; @@ -461,20 +524,13 @@ int blf_glyph_texture_render(FontBLF *font, GlyphBLF *g, float x, float y) if (cur_tex != gt->tex) glBindTexture(GL_TEXTURE_2D, gt->tex); - glBegin(GL_QUADS); - glTexCoord2f(gt->uv[0][0], gt->uv[0][1]); - glVertex2f(dx, y1); - - glTexCoord2f(gt->uv[0][0], gt->uv[1][1]); - glVertex2f(dx, y2); - - glTexCoord2f(gt->uv[1][0], gt->uv[1][1]); - glVertex2f(dx1, y2); - - glTexCoord2f(gt->uv[1][0], gt->uv[0][1]); - glVertex2f(dx1, y1); - glEnd(); - + if (font->blur==3) + blf_glyph_texture3_draw(gt->uv, dx, y1, dx1, y2); + else if (font->blur==5) + blf_glyph_texture5_draw(gt->uv, dx, y1, dx1, y2); + else + blf_glyph_texture_draw(gt->uv, dx, y1, dx1, y2); + return(1); } diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index e176eb2040b..cf42dc69f77 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -157,7 +157,10 @@ typedef struct FontBLF { /* angle in degrees. */ float angle; - + + /* blur: 3 or 5 large kernel */ + int blur; + /* this is the matrix that we load before rotate/scale/translate. */ float mat[4][4]; |