diff options
Diffstat (limited to 'source/blender/blenfont/intern/blf_glyph.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 510204b0f51..551db2cdaa9 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -31,16 +31,12 @@ #include <string.h> #include <math.h> -#ifdef WITH_FREETYPE2 - #include <ft2build.h> #include FT_FREETYPE_H #include FT_GLYPH_H #include FT_OUTLINE_H -#endif /* WITH_FREETYPE2 */ - #include "MEM_guardedalloc.h" #include "DNA_listBase.h" @@ -59,8 +55,6 @@ #include "blf_internal.h" -#ifdef WITH_FREETYPE2 - GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi) { GlyphCacheBLF *p; @@ -433,6 +427,67 @@ void blf_glyph_free(GlyphBLF *g) MEM_freeN(g); } +static void blf_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_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_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + } + } + + glColor4fv(color); +} + +static void blf_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_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; @@ -504,5 +559,3 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) return(blf_glyph_bitmap_render(font, g, x, y)); return(blf_glyph_texture_render(font, g, x, y)); } - -#endif /* WITH_FREETYPE2 */ |