diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-12-02 13:33:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-12-02 14:10:07 +0400 |
commit | 1815225faa75eb64e83fdc9f066fcd6339502d52 (patch) | |
tree | 6558780d85792c9c41fcf280069870fae70eed7a /source/blender/blenfont/intern/blf.c | |
parent | f64ae4cbe5a724496624de9e479c04f325613be5 (diff) |
Blender Font (BLF): add length argument to string width/height functions
This also fixes a crash editing buttons longer then UI_MAX_DRAW_STR
Diffstat (limited to 'source/blender/blenfont/intern/blf.c')
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 130eaaecba5..746ee3c0d93 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -592,44 +592,44 @@ int BLF_draw_mono(int fontid, const char *str, size_t len, int cwidth) return columns; } -void BLF_boundbox(int fontid, const char *str, rctf *box) +void BLF_boundbox(int fontid, const char *str, size_t len, rctf *box) { FontBLF *font = blf_get(fontid); if (font) { - blf_font_boundbox(font, str, box); + blf_font_boundbox(font, str, len, box); } } -void BLF_width_and_height(int fontid, const char *str, float *width, float *height) +void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_width, float *r_height) { FontBLF *font = blf_get(fontid); if (font && font->glyph_cache) { - blf_font_width_and_height(font, str, width, height); + blf_font_width_and_height(font, str, len, r_width, r_height); } else { - *width = *height = 0.0f; + *r_width = *r_height = 0.0f; } } -void BLF_width_and_height_default(const char *str, float *width, float *height) +void BLF_width_and_height_default(const char *str, size_t len, float *r_width, float *r_height) { if (!blf_global_font_init()) { - *width = *height = 0.0f; + *r_width = *r_height = 0.0f; return; } BLF_size(global_font_default, global_font_points, global_font_dpi); - BLF_width_and_height(global_font_default, str, width, height); + BLF_width_and_height(global_font_default, str, len, r_width, r_height); } -float BLF_width(int fontid, const char *str) +float BLF_width(int fontid, const char *str, size_t len) { FontBLF *font = blf_get(fontid); if (font && font->glyph_cache) { - return blf_font_width(font, str); + return blf_font_width(font, str, len); } return 0.0f; @@ -646,21 +646,21 @@ float BLF_fixed_width(int fontid) return 0.0f; } -float BLF_width_default(const char *str) +float BLF_width_default(const char *str, size_t len) { if (!blf_global_font_init()) return 0.0f; BLF_size(global_font_default, global_font_points, global_font_dpi); - return BLF_width(global_font_default, str); + return BLF_width(global_font_default, str, len); } -float BLF_height(int fontid, const char *str) +float BLF_height(int fontid, const char *str, size_t len) { FontBLF *font = blf_get(fontid); if (font && font->glyph_cache) { - return blf_font_height(font, str); + return blf_font_height(font, str, len); } return 0.0f; @@ -710,14 +710,14 @@ float BLF_ascender(int fontid) return 0.0f; } -float BLF_height_default(const char *str) +float BLF_height_default(const char *str, size_t len) { if (!blf_global_font_init()) return 0.0f; BLF_size(global_font_default, global_font_points, global_font_dpi); - return BLF_height(global_font_default, str); + return BLF_height(global_font_default, str, len); } void BLF_rotation(int fontid, float angle) |