Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-04-30 12:54:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-30 12:54:06 +0400
commit03c362f1ab75dcf647b14a4de0ad636ece05ca82 (patch)
tree86e68a063230b4a05f272f6f12801de7aab0973c /source/blender/blenfont
parented76b3cb77279b2be246b54e0f45c5eaabc04bb6 (diff)
fix [#27221] stamp text bug in lower lines
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_api.h2
-rw-r--r--source/blender/blenfont/intern/blf.c2
-rw-r--r--source/blender/blenfont/intern/blf_font.c14
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h6
4 files changed, 16 insertions, 8 deletions
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;