[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19881] branches/blender2.5/blender/source /blender: Add clipping option for bitmap draw mode and remove the " test code" from

Diego Borghetti bdiego at gmail.com
Wed Apr 22 22:54:27 CEST 2009


Revision: 19881
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19881
Author:   bdiego
Date:     2009-04-22 22:54:27 +0200 (Wed, 22 Apr 2009)

Log Message:
-----------
Add clipping option for bitmap draw mode and remove the "test code" from
space_info.c

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

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c	2009-04-22 20:43:41 UTC (rev 19880)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c	2009-04-22 20:54:27 UTC (rev 19881)
@@ -543,6 +543,17 @@
 	if (!gt->image)
 		return(1);
 
+	if (font->flags & BLF_CLIPPING) {
+		if (!BLI_in_rctf(&font->clip_rec, x + font->pos[0], y + font->pos[1]))
+			return(0);
+		if (!BLI_in_rctf(&font->clip_rec, x + font->pos[0], y + gt->height + font->pos[1]))
+			return(0);
+		if (!BLI_in_rctf(&font->clip_rec, x + gt->width + font->pos[0], y + gt->height + font->pos[1]))
+			return(0);
+		if (!BLI_in_rctf(&font->clip_rec, x + gt->width + font->pos[0], y + font->pos[1]))
+			return(0);
+	}
+
 	glBitmap(0, 0, 0.0, 0.0, x + font->pos[0], y - font->pos[1], (const GLubyte *)&null_bitmap);
 	glPixelStorei(GL_UNPACK_ROW_LENGTH, gt->pitch * 8);
 	glBitmap(gt->width, gt->height, 0.0, gt->pos_y, 0.0, 0.0, (const GLubyte *)gt->image);

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-22 20:43:41 UTC (rev 19880)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.c	2009-04-22 20:54:27 UTC (rev 19881)
@@ -178,14 +178,15 @@
 			dy1= -base_line + y + 16.0;
 
 			if (font->flags & BLF_CLIPPING) {
+				/* Don't return, just skip this character and check the others. */
 				if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], dy + font->pos[1]))
-					return;
+					goto next_tex_char;
 				if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], dy1 + font->pos[1]))
-					return;
+					goto next_tex_char;
 				if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], dy1 + font->pos[1]))
-					return;
+					goto next_tex_char;
 				if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], dy + font->pos[1]))
-					return;
+					goto next_tex_char;
 			}
 
 			glBegin(GL_QUADS);
@@ -202,7 +203,7 @@
 			glVertex3f(dx1, dy, z);
 			glEnd();
 		}
-		
+next_tex_char:
 		pos += cd->advance;
 	}
 }
@@ -213,15 +214,29 @@
 	CharDataBLF *cd;
 	unsigned char c;
 	GLint alignment;
+	float dx;
 
 	data= (FontDataBLF *)font->engine;
 
 	glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
 	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+	dx= 0;
 	
 	while ((c= (unsigned char) *str++)) {
 		cd= &data->chars[c];
 
+		if (font->flags & BLF_CLIPPING) {
+			/* The same here, always check all the characters. */
+			if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], font->pos[1]))
+				goto next_bitmap_char;
+			if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], cd->height + font->pos[1]))
+				goto next_bitmap_char;
+			if (!BLI_in_rctf(&font->clip_rec, dx + cd->width + font->pos[0], cd->height + font->pos[1]))
+				goto next_bitmap_char;
+			if (!BLI_in_rctf(&font->clip_rec, dx + cd->width + font->pos[0], font->pos[1]))
+				goto next_bitmap_char;
+		}
+
 		if (cd->data_offset==-1) {
 			GLubyte nullBitmap= 0;
 			glBitmap(1, 1, 0, 0, cd->advance, 0, &nullBitmap);	
@@ -229,6 +244,8 @@
 			GLubyte *bitmap= &data->bitmap_data[cd->data_offset];
 			glBitmap(cd->width, cd->height, cd->xorig, cd->yorig, cd->advance, 0, bitmap);
 		}
+next_bitmap_char:
+		dx += cd->advance;
 	}
 
 	glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);

Modified: branches/blender2.5/blender/source/blender/editors/space_info/space_info.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_info/space_info.c	2009-04-22 20:43:41 UTC (rev 19880)
+++ branches/blender2.5/blender/source/blender/editors/space_info/space_info.c	2009-04-22 20:54:27 UTC (rev 19881)
@@ -48,7 +48,6 @@
 #include "ED_screen.h"
 
 #include "BIF_gl.h"
-#include "BLF_api.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -133,7 +132,6 @@
 	// SpaceInfo *sinfo= (SpaceInfo*)CTX_wm_space_data(C);
 	View2D *v2d= &ar->v2d;
 	float col[3];
-	float width, height;
 
 	/* clear and setup matrix */
 	UI_GetThemeColor3fv(TH_BACK, col);
@@ -143,39 +141,7 @@
 	UI_view2d_view_ortho(C, v2d);
 		
 	/* data... */
-	// XXX 2.50 Testing new font library - Diego
-	glColor3f(1.0, 0.0, 0.0);
-	BLF_aspect(1.0);
 
-	BLF_size(14, 96);
-	BLF_position(5.0, 5.0, 0.0);
-
-	width= BLF_width("Hello Blender, size 14, dpi 96");
-	height= BLF_height("Hello Blender, size 14, dpi 96");
-
-	glRectf(7.0, 20.0, 7.0+width, 20.0+height);
-	glRectf(5.0+width+10.0, 3.0, 5.0+width+10.0+width, 3.0+height);
-	BLF_draw("Hello Blender, size 14, dpi 96");
-
-	glColor3f(0.0, 0.0, 1.0);
-	BLF_size(11, 96);
-	BLF_position(200.0, 50.0, 0.0);
-	BLF_enable(BLF_ROTATION);
-	BLF_rotation(45.0f);
-	BLF_draw("Another Hello Blender, size 11 and dpi 96!!");
-
-	glColor3f(0.8, 0.0, 0.7);
-	BLF_size(12, 72);
-	BLF_position(200.0, 100.0, 0.0);
-	BLF_rotation(180.0f);
-	BLF_draw("Hello World, size 12, dpi 72");
-	
-	glColor3f(0.8, 0.7, 0.5);
-	BLF_size(12, 96);
-	BLF_position(5.0, 200.0, 0.0);
-	BLF_disable(BLF_ROTATION);
-	BLF_draw("And this make a new glyph cache!!");
-
 	/* reset view matrix */
 	UI_view2d_view_restore(C);
 	





More information about the Bf-blender-cvs mailing list