diff options
Diffstat (limited to 'source/blender/blenfont/intern')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 30 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 9 |
2 files changed, 23 insertions, 16 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 52597a282eb..9ec9dd1caa0 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -385,28 +385,28 @@ void BLF_position(int fontid, float x, float y, float z) za= 1.0f; } - remainder= x - floor(x); - if (remainder > 0.4 && remainder < 0.6) { - if (remainder < 0.5) - x -= 0.1 * xa; + remainder= x - floorf(x); + if (remainder > 0.4f && remainder < 0.6f) { + if (remainder < 0.5f) + x -= 0.1f * xa; else - x += 0.1 * xa; + x += 0.1f * xa; } - remainder= y - floor(y); - if (remainder > 0.4 && remainder < 0.6) { - if (remainder < 0.5) - y -= 0.1 * ya; + remainder= y - floorf(y); + if (remainder > 0.4f && remainder < 0.6f) { + if (remainder < 0.5f) + y -= 0.1f * ya; else - y += 0.1 * ya; + y += 0.1f * ya; } - remainder= z - floor(z); - if (remainder > 0.4 && remainder < 0.6) { - if (remainder < 0.5) - z -= 0.1 * za; + remainder= z - floorf(z); + if (remainder > 0.4f && remainder < 0.6f) { + if (remainder < 0.5f) + z -= 0.1f * za; else - z += 0.1 * za; + z += 0.1f * za; } font->pos[0]= x; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 708b3708ab7..fb6505fe935 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -213,7 +213,7 @@ void blf_font_buffer(FontBLF *font, const char *str) { unsigned char *cbuf; unsigned int c; - unsigned char b_col_char[3]; + unsigned char b_col_char[4]; GlyphBLF *g, *g_prev; FT_Vector delta; FT_UInt glyph_index; @@ -232,6 +232,7 @@ void blf_font_buffer(FontBLF *font, const char *str) b_col_char[0]= font->b_col[0] * 255; b_col_char[1]= font->b_col[1] * 255; b_col_char[2]= font->b_col[2] * 255; + b_col_char[3]= font->b_col[3] * 255; while (str[i]) { int pen_y; @@ -296,16 +297,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + float alphatest; fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { fbuf[0]= font->b_col[0]; fbuf[1]= font->b_col[1]; fbuf[2]= font->b_col[2]; + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f; } else { fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a)); fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a)); fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a)); + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f; } } } @@ -324,16 +328,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + int alphatest; cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { cbuf[0]= b_col_char[0]; cbuf[1]= b_col_char[1]; cbuf[2]= b_col_char[2]; + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255; } else { cbuf[0]= (b_col_char[0]*a) + (cbuf[0] * (1-a)); cbuf[1]= (b_col_char[1]*a) + (cbuf[1] * (1-a)); cbuf[2]= (b_col_char[2]*a) + (cbuf[2] * (1-a)); + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < 255 ? alphatest : 255; } } } |