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_internal.h | |
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_internal.h')
-rw-r--r-- | source/blender/blenfont/intern/blf_internal.h | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 85410a4d856..55bc61e0e43 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -31,6 +31,7 @@ #ifndef __BLF_INTERNAL_H__ #define __BLF_INTERNAL_H__ +struct ResultBLF; struct FontBLF; struct GlyphBLF; struct GlyphCacheBLF; @@ -51,16 +52,19 @@ struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); void blf_font_size(struct FontBLF *font, unsigned int size, unsigned int dpi); -void blf_font_draw(struct FontBLF *font, const char *str, size_t len); -void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len); +void blf_font_draw(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); +void blf_font_draw__wrap(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); +void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); int blf_font_draw_mono(struct FontBLF *font, const char *str, size_t len, int cwidth); -void blf_font_buffer(struct FontBLF *font, const char *str); +void blf_font_draw_buffer(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); +void blf_font_draw_buffer__wrap(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); size_t blf_font_width_to_strlen(struct FontBLF *font, const char *str, size_t len, float width, float *r_width); size_t blf_font_width_to_rstrlen(struct FontBLF *font, const char *str, size_t len, float width, float *r_width); -void blf_font_boundbox(struct FontBLF *font, const char *str, size_t len, struct rctf *box); -void blf_font_width_and_height(struct FontBLF *font, const char *str, size_t len, float *width, float *height); -float blf_font_width(struct FontBLF *font, const char *str, size_t len); -float blf_font_height(struct FontBLF *font, const char *str, size_t len); +void blf_font_boundbox(struct FontBLF *font, const char *str, size_t len, struct rctf *r_box, struct ResultBLF *r_info); +void blf_font_boundbox__wrap(struct FontBLF *font, const char *str, size_t len, struct rctf *r_box, struct ResultBLF *r_info); +void blf_font_width_and_height(struct FontBLF *font, const char *str, size_t len, float *r_width, float *r_height, struct ResultBLF *r_info); +float blf_font_width(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); +float blf_font_height(struct FontBLF *font, const char *str, size_t len, struct ResultBLF *r_info); float blf_font_fixed_width(struct FontBLF *font); int blf_font_count_missing_chars(struct FontBLF *font, const char *str, const size_t len, int *r_tot_chars); |