[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19507] branches/blender2.5/blender/source /blender/blenfont/intern/blf_internal.c: Add clipping option to the internal font.

Diego Borghetti bdiego at gmail.com
Thu Apr 2 22:01:37 CEST 2009


Revision: 19507
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19507
Author:   bdiego
Date:     2009-04-02 22:01:37 +0200 (Thu, 02 Apr 2009)

Log Message:
-----------
Add clipping option to the internal font.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.c

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.c	2009-04-02 19:28:14 UTC (rev 19506)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.c	2009-04-02 20:01:37 UTC (rev 19507)
@@ -152,6 +152,7 @@
 	float pos, cell_x, cell_y, x, y, z;
 	int base_line;
 	GLint cur_tex;
+	float dx, dx1, dy, dy1;
 
 	data= (FontDataBLF *)font->engine;
 	base_line= -(data->ymin);
@@ -164,7 +165,6 @@
 	if (cur_tex != data->texid)
 		glBindTexture(GL_TEXTURE_2D, data->texid);
 
-	glBegin(GL_QUADS);
 	while ((c= (unsigned char) *str++)) {
 		cd= &data->chars[c];
 
@@ -172,22 +172,39 @@
 			cell_x= (c%16)/16.0;
 			cell_y= (c/16)/16.0;
 
+			dx= x + pos + 16.0;
+			dx1= x + pos + 0.0;
+			dy= -base_line + y + 0.0;
+			dy1= -base_line + y + 16.0;
+
+			if (font->flags & BLF_CLIPPING) {
+				if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], dy + font->pos[1]))
+					return;
+				if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], dy1 + font->pos[1]))
+					return;
+				if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], dy1 + font->pos[1]))
+					return;
+				if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], dy + font->pos[1]))
+					return;
+			}
+
+			glBegin(GL_QUADS);
 			glTexCoord2f(cell_x + 1.0/16.0, cell_y);
-			glVertex3f(x + pos + 16.0, -base_line + y + 0.0, z);
+			glVertex3f(dx, dy, z);
 
 			glTexCoord2f(cell_x + 1.0/16.0, cell_y + 1.0/16.0);
-			glVertex3f(x + pos + 16.0, -base_line + y + 16.0, z);
+			glVertex3f(dx, dy1, z);
 
 			glTexCoord2f(cell_x, cell_y + 1.0/16.0);
-			glVertex3f(x + pos + 0.0, -base_line + y + 16.0, z);
+			glVertex3f(dx1, dy1, z);
 
 			glTexCoord2f(cell_x, cell_y);
-			glVertex3f(x + pos + 0.0, -base_line + y + 0.0, z);
+			glVertex3f(dx1, dy, z);
+			glEnd();
 		}
 		
 		pos += cd->advance;
 	}
-	glEnd();
 }
 
 void blf_internal_boundbox(FontBLF *font, char *str, rctf *box)





More information about the Bf-blender-cvs mailing list