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/blenkernel/intern | |
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/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 22 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image_gen.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 4 |
3 files changed, 22 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 36aeb97c3f0..b6645a35b60 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1917,7 +1917,7 @@ void BKE_image_stamp_buf( /* and draw the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.file); + BLF_draw_buffer(mono, stamp_data.file, BLF_DRAW_STR_DUMMY_MAX); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -1932,7 +1932,7 @@ void BKE_image_stamp_buf( 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.note); + BLF_draw_buffer(mono, stamp_data.note, BLF_DRAW_STR_DUMMY_MAX); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -1947,7 +1947,7 @@ void BKE_image_stamp_buf( 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.date); + BLF_draw_buffer(mono, stamp_data.date, BLF_DRAW_STR_DUMMY_MAX); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -1962,7 +1962,7 @@ void BKE_image_stamp_buf( 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.rendertime); + BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX); } x = 0; @@ -1977,7 +1977,7 @@ void BKE_image_stamp_buf( /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.marker); + BLF_draw_buffer(mono, stamp_data.marker, BLF_DRAW_STR_DUMMY_MAX); /* space width. */ x += w + pad; @@ -1992,7 +1992,7 @@ void BKE_image_stamp_buf( /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.time); + BLF_draw_buffer(mono, stamp_data.time, BLF_DRAW_STR_DUMMY_MAX); /* space width. */ x += w + pad; @@ -2006,7 +2006,7 @@ void BKE_image_stamp_buf( /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.frame); + BLF_draw_buffer(mono, stamp_data.frame, BLF_DRAW_STR_DUMMY_MAX); /* space width. */ x += w + pad; @@ -2018,7 +2018,7 @@ void BKE_image_stamp_buf( buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.camera); + BLF_draw_buffer(mono, stamp_data.camera, BLF_DRAW_STR_DUMMY_MAX); /* space width. */ x += w + pad; @@ -2030,7 +2030,7 @@ void BKE_image_stamp_buf( buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.cameralens); + BLF_draw_buffer(mono, stamp_data.cameralens, BLF_DRAW_STR_DUMMY_MAX); } if (TEXT_SIZE_CHECK(stamp_data.scene, w, h)) { @@ -2044,7 +2044,7 @@ void BKE_image_stamp_buf( /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.scene); + BLF_draw_buffer(mono, stamp_data.scene, BLF_DRAW_STR_DUMMY_MAX); } if (TEXT_SIZE_CHECK(stamp_data.strip, w, h)) { @@ -2058,7 +2058,7 @@ void BKE_image_stamp_buf( x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.strip); + BLF_draw_buffer(mono, stamp_data.strip, BLF_DRAW_STR_DUMMY_MAX); } /* cleanup the buffer. */ diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 4f9ed5f258d..303d0c6adfc 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -309,26 +309,26 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0); BLF_position(mono, pen_x - outline, pen_y, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x + outline, pen_y, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x, pen_y - outline, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x, pen_y + outline, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x - outline, pen_y - outline, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x + outline, pen_y + outline, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x - outline, pen_y + outline, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_position(mono, pen_x + outline, pen_y - outline, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0); BLF_position(mono, pen_x, pen_y, 0.0); - BLF_draw_buffer(mono, text); + BLF_draw_buffer(mono, text, 2); text[1]++; } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c65ed527568..3e93fb53bfc 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2968,11 +2968,11 @@ static ImBuf *do_text_effect(const SeqRenderData *context, Sequence *seq, float fonty = BLF_height_max(mono); BLF_position(mono, x + max_ii(fontx / 25, 1), y + max_ii(fonty / 25, 1), 0.0f); BLF_buffer_col(mono, 0.0f, 0.0f, 0.0f, 1.0f); - BLF_draw_buffer(mono, data->text); + BLF_draw_buffer(mono, data->text, BLF_DRAW_STR_DUMMY_MAX); } BLF_position(mono, x, y, 0.0f); BLF_buffer_col(mono, 1.0f, 1.0f, 1.0f, 1.0f); - BLF_draw_buffer(mono, data->text); + BLF_draw_buffer(mono, data->text, BLF_DRAW_STR_DUMMY_MAX); BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL); |