[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36390] trunk/blender/source/blender/ blenfont: fix [#27221] stamp text bug in lower lines
Campbell Barton
ideasman42 at gmail.com
Sat Apr 30 10:54:06 CEST 2011
Revision: 36390
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36390
Author: campbellbarton
Date: 2011-04-30 08:54:06 +0000 (Sat, 30 Apr 2011)
Log Message:
-----------
fix [#27221] stamp text bug in lower lines
Modified Paths:
--------------
trunk/blender/source/blender/blenfont/BLF_api.h
trunk/blender/source/blender/blenfont/intern/blf.c
trunk/blender/source/blender/blenfont/intern/blf_font.c
trunk/blender/source/blender/blenfont/intern/blf_internal_types.h
Modified: trunk/blender/source/blender/blenfont/BLF_api.h
===================================================================
--- trunk/blender/source/blender/blenfont/BLF_api.h 2011-04-30 08:42:32 UTC (rev 36389)
+++ trunk/blender/source/blender/blenfont/BLF_api.h 2011-04-30 08:54:06 UTC (rev 36390)
@@ -157,7 +157,7 @@
*
* 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.
Modified: trunk/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf.c 2011-04-30 08:42:32 UTC (rev 36389)
+++ trunk/blender/source/blender/blenfont/intern/blf.c 2011-04-30 08:54:06 UTC (rev 36390)
@@ -657,7 +657,7 @@
}
}
-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;
Modified: trunk/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_font.c 2011-04-30 08:42:32 UTC (rev 36389)
+++ trunk/blender/source/blender/blenfont/intern/blf_font.c 2011-04-30 08:54:06 UTC (rev 36390)
@@ -218,7 +218,7 @@
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 @@
/* 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;
+
+ /* drawing below the image? */
+ if(pen_y < 0) {
+ yb_start += (g->pitch < 0) ? -pen_y : pen_y;
+ height_clip += pen_y;
+ pen_y= 0;
+ }
- yb= g->pitch < 0 ? 0 : g->height-1;
-
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 @@
}
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;
Modified: trunk/blender/source/blender/blenfont/intern/blf_internal_types.h
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_internal_types.h 2011-04-30 08:42:32 UTC (rev 36389)
+++ trunk/blender/source/blender/blenfont/intern/blf_internal_types.h 2011-04-30 08:54:06 UTC (rev 36390)
@@ -200,9 +200,9 @@
/* 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;
More information about the Bf-blender-cvs
mailing list