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:
authorDiego Borghetti <bdiego@gmail.com>2009-04-23 00:54:27 +0400
committerDiego Borghetti <bdiego@gmail.com>2009-04-23 00:54:27 +0400
commit6a5a94a8feadaf1cf4d5fca2b73ca68a0582c20b (patch)
tree477874e6c255c008e93e0d7695b1d020d8969afa /source/blender/blenfont
parent76d000fd9625981189d55fc3fbe4619aaeaf1676 (diff)
Add clipping option for bitmap draw mode and remove the "test code" from
space_info.c
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c11
-rw-r--r--source/blender/blenfont/intern/blf_internal.c27
2 files changed, 33 insertions, 5 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index 063093efb1d..bdec76e01ff 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -543,6 +543,17 @@ int blf_glyph_bitmap_render(FontBLF *font, GlyphBLF *g, float x, float y)
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);
diff --git a/source/blender/blenfont/intern/blf_internal.c b/source/blender/blenfont/intern/blf_internal.c
index d868a0fa32a..bc569e3d080 100644
--- a/source/blender/blenfont/intern/blf_internal.c
+++ b/source/blender/blenfont/intern/blf_internal.c
@@ -178,14 +178,15 @@ void blf_internal_texture_draw(FontBLF *font, char *str)
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 @@ void blf_internal_texture_draw(FontBLF *font, char *str)
glVertex3f(dx1, dy, z);
glEnd();
}
-
+next_tex_char:
pos += cd->advance;
}
}
@@ -213,15 +214,29 @@ void blf_internal_bitmap_draw(FontBLF *font, char *str)
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 @@ void blf_internal_bitmap_draw(FontBLF *font, char *str)
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);