From 03c362f1ab75dcf647b14a4de0ad636ece05ca82 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 30 Apr 2011 08:54:06 +0000 Subject: fix [#27221] stamp text bug in lower lines --- source/blender/blenfont/BLF_api.h | 2 +- source/blender/blenfont/intern/blf.c | 2 +- source/blender/blenfont/intern/blf_font.c | 14 +++++++++++--- source/blender/blenfont/intern/blf_internal_types.h | 6 +++--- 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 93b9cbc0bdf..44d3cf2c61b 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -157,7 +157,7 @@ void BLF_shadow_offset(int fontid, int x, int y); * * BLF_buffer(NULL, NULL, 0, 0, 0); */ -void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch); +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch); /* * Set the color to be used for text. diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 930f55a48fa..5db71948024 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -657,7 +657,7 @@ void BLF_shadow_offset(int fontid, int x, int y) } } -void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, unsigned int w, unsigned int h, int nch) +void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch) { FontBLF *font; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 80d0a48954a..708b3708ab7 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -218,7 +218,7 @@ void blf_font_buffer(FontBLF *font, const char *str) FT_Vector delta; FT_UInt glyph_index; float a, *fbuf; - int pen_x, y, x, yb; + int pen_x, y, x; int i, has_kerning, st, chx, chy; if (!font->glyph_cache || (!font->b_fbuf && !font->b_cbuf)) @@ -276,13 +276,20 @@ void blf_font_buffer(FontBLF *font, const char *str) /* dont draw beyond the buffer bounds */ int width_clip= g->width; int height_clip= g->height; + int yb_start= g->pitch < 0 ? 0 : g->height-1; if (width_clip + chx > font->bw) width_clip -= chx + width_clip - font->bw; if (height_clip + pen_y > font->bh) height_clip -= pen_y + height_clip - font->bh; - - yb= g->pitch < 0 ? 0 : g->height-1; + /* drawing below the image? */ + if(pen_y < 0) { + yb_start += (g->pitch < 0) ? -pen_y : pen_y; + height_clip += pen_y; + pen_y= 0; + } + if (font->b_fbuf) { + int yb= yb_start; for (y=(chy >= 0 ? 0:-chy); y < height_clip; y++) { for (x=(chx >= 0 ? 0:-chx); x < width_clip; x++) { @@ -311,6 +318,7 @@ void blf_font_buffer(FontBLF *font, const char *str) } if (font->b_cbuf) { + int yb= yb_start; for (y= 0; y < height_clip; y++) { for (x= 0; x < width_clip; x++) { a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index deb13006eaf..c4e192626e8 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -200,9 +200,9 @@ typedef struct FontBLF { /* the same but unsigned char */ unsigned char *b_cbuf; - /* buffer size. */ - unsigned int bw; - unsigned int bh; + /* buffer size, keep signed so comparisons with negative values work */ + int bw; + int bh; /* number of channels. */ int bch; -- cgit v1.2.3