diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-18 13:10:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-18 13:43:52 +0300 |
commit | f2341f829654c4dc97fcf9fd1f74a6526c4f50ff (patch) | |
tree | 7287c4bbe46c06394353e1f57d62a6dff8803876 /source/blender/blenfont/intern/blf_thumbs.c | |
parent | e9dd060102f2ca84530ed000a063abbd53b99962 (diff) |
BLF: initial word-wrap support
- Adds support for word wrapping to Blender's BLF font library.
- Splits lines when width limit is reached or on explicit \n newlines.
Details:
- Word wrapping is used when `BLF_WORD_WRAP` flag is enabled.
- There is a single loop to handle line wrapping,
this runs callback, passing in a substring,
this way we can avoid code-duplication for all word-wrapped
versions of functions... OR... avoid having to add support
for word-wrapping directly into each function.
- The `ResultBLF` struct was added to be able to get the number
of wrapped lines, when calling otherwise unrelated functions
such as `BLF_draw/BLF_width/BLF_boundbox`,
which can be passed as the last argument to `BLF_*_ex()` functions.
- The `ResultBLF` struct is used to store the result of drawing
(currently only the number of lines wrapped, and the width).
Diffstat (limited to 'source/blender/blenfont/intern/blf_thumbs.c')
-rw-r--r-- | source/blender/blenfont/intern/blf_thumbs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c index 4eea5d581d0..76479593b54 100644 --- a/source/blender/blenfont/intern/blf_thumbs.c +++ b/source/blender/blenfont/intern/blf_thumbs.c @@ -84,7 +84,7 @@ void BLF_thumb_preview( /* Always create the image with a white font, * the caller can theme how it likes */ - memcpy(font->buf_info.col, font_color, sizeof(font->buf_info.col)); + memcpy(font->buf_info.col_init, font_color, sizeof(font->buf_info.col_init)); font->pos[1] = (float)h; font_size_curr = font_size; @@ -110,10 +110,10 @@ void BLF_thumb_preview( if (blf_font_count_missing_chars( font, draw_str_i18n, draw_str_i18n_len, &draw_str_i18n_nbr) > (draw_str_i18n_nbr / 2)) { - blf_font_buffer(font, draw_str[i]); + blf_font_draw_buffer(font, draw_str[i], (size_t)draw_str_i18n_nbr, NULL); } else { - blf_font_buffer(font, draw_str_i18n); + blf_font_draw_buffer(font, draw_str_i18n, draw_str_i18n_len, NULL); } } |