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-03 00:01:37 +0400
committerDiego Borghetti <bdiego@gmail.com>2009-04-03 00:01:37 +0400
commit879a7529fdb2f93eecf51e4857e7719c1863a2ae (patch)
treecee6a92c3970810314ea58824e37037510e6a4ad /source/blender
parent742cf7263172ac7cf92c5f8fa361d8ac71023698 (diff)
Add clipping option to the internal font.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenfont/intern/blf_internal.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/blenfont/intern/blf_internal.c b/source/blender/blenfont/intern/blf_internal.c
index 5f4126ecb47..8ba88d054a5 100644
--- a/source/blender/blenfont/intern/blf_internal.c
+++ b/source/blender/blenfont/intern/blf_internal.c
@@ -152,6 +152,7 @@ void blf_internal_draw(FontBLF *font, char *str)
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 @@ void blf_internal_draw(FontBLF *font, char *str)
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 @@ void blf_internal_draw(FontBLF *font, char *str)
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)