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:
authorCampbell Barton <ideasman42@gmail.com>2010-11-11 09:35:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-11 09:35:45 +0300
commit80a650dfb1e73363ae6924dc5738b732bb89ded4 (patch)
tree7d8af50bde3e4c32474d899a7fd00558afe9befc /source/blender/blenfont
parent59cfe81085b06243220cdb075a28a1352edebf7b (diff)
BLF_draw functions take an extra length argument, so the console drawing doenst need to swap in NULL chars to draw word wrapping.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_api.h8
-rw-r--r--source/blender/blenfont/intern/blf.c16
-rw-r--r--source/blender/blenfont/intern/blf_font.c8
-rw-r--r--source/blender/blenfont/intern/blf_internal.h4
4 files changed, 18 insertions, 18 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index c01886be65e..795fb2d51a6 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -48,12 +48,12 @@ void BLF_position(int fontid, float x, float y, float z);
void BLF_size(int fontid, int size, int dpi);
/* Draw the string using the default font, size and dpi. */
-void BLF_draw_default(float x, float y, float z, const char *str);
-void BLF_draw_default_ascii(float x, float y, float z, const char *str);
+void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
+void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
/* Draw the string using the current font. */
-void BLF_draw(int fontid, const char *str);
-void BLF_draw_ascii(int fontid, const char *str);
+void BLF_draw(int fontid, const char *str, size_t len);
+void BLF_draw_ascii(int fontid, const char *str, size_t len);
/*
* This function return the bounding box of the string
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 59189abf1e3..70755ee1f82 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -361,7 +361,7 @@ void BLF_blur(int fontid, int size)
font->blur= size;
}
-void BLF_draw_default(float x, float y, float z, const char *str)
+void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
{
if (!str)
return;
@@ -376,10 +376,10 @@ void BLF_draw_default(float x, float y, float z, const char *str)
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
- BLF_draw(global_font_default, str);
+ BLF_draw(global_font_default, str, len);
}
/* same as above but call 'BLF_draw_ascii' */
-void BLF_draw_default_ascii(float x, float y, float z, const char *str)
+void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
{
if (!str)
return;
@@ -394,7 +394,7 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str)
BLF_size(global_font_default, global_font_points, global_font_dpi);
BLF_position(global_font_default, x, y, z);
- BLF_draw_ascii(global_font_default, str);
+ BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
}
void BLF_rotation_default(float angle)
@@ -432,22 +432,22 @@ static void blf_draw__end(void)
glDisable(GL_TEXTURE_2D);
}
-void BLF_draw(int fontid, const char *str)
+void BLF_draw(int fontid, const char *str, size_t len)
{
FontBLF *font= BLF_get(fontid);
if (font) {
blf_draw__start(font);
- blf_font_draw(font, str);
+ blf_font_draw(font, str, len);
blf_draw__end();
}
}
-void BLF_draw_ascii(int fontid, const char *str)
+void BLF_draw_ascii(int fontid, const char *str, size_t len)
{
FontBLF *font= BLF_get(fontid);
if (font) {
blf_draw__start(font);
- blf_font_draw_ascii(font, str);
+ blf_font_draw_ascii(font, str, len);
blf_draw__end();
}
}
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 9fb40f0206d..7542d200be1 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -92,7 +92,7 @@ void blf_font_size(FontBLF *font, int size, int dpi)
}
}
-void blf_font_draw(FontBLF *font, const char *str)
+void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
{
unsigned int c;
GlyphBLF *g, *g_prev;
@@ -110,7 +110,7 @@ void blf_font_draw(FontBLF *font, const char *str)
has_kerning= FT_HAS_KERNING(font->face);
g_prev= NULL;
- while (str[i]) {
+ while (str[i] && i < len) {
c= blf_utf8_next((unsigned char *)str, &i);
if (c == 0)
break;
@@ -147,7 +147,7 @@ void blf_font_draw(FontBLF *font, const char *str)
}
/* faster version of blf_font_draw, ascii only for view dimensions */
-void blf_font_draw_ascii(FontBLF *font, const char *str)
+void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len)
{
char c;
GlyphBLF *g, *g_prev;
@@ -177,7 +177,7 @@ void blf_font_draw_ascii(FontBLF *font, const char *str)
}
}
- while ((c= *(str++))) {
+ while ((c= *(str++)) && len--) {
g= font->glyph_ascii_table[c];
/* if we don't found a glyph, skip it. */
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h
index c7a3cd54740..ec52a1728f4 100644
--- a/source/blender/blenfont/intern/blf_internal.h
+++ b/source/blender/blenfont/intern/blf_internal.h
@@ -44,8 +44,8 @@ FontBLF *blf_font_new_from_mem(char *name, unsigned char *mem, int mem_size);
void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_size);
void blf_font_size(FontBLF *font, int size, int dpi);
-void blf_font_draw(FontBLF *font, const char *str);
-void blf_font_draw_ascii(FontBLF *font, const char *str);
+void blf_font_draw(FontBLF *font, const char *str, unsigned int len);
+void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len);
void blf_font_buffer(FontBLF *font, char *str);
void blf_font_boundbox(FontBLF *font, char *str, rctf *box);
void blf_font_width_and_height(FontBLF *font, char *str, float *width, float *height);