1 /* Word wrapping algorithm with UTF-8 support. More than just a basic greedy 2 * word-wrapper: it attempts to balance consecutive lines as pairs. 3 */ 4 5 #ifndef _MF_WORDWRAP_H_ 6 #define _MF_WORDWRAP_H_ 7 8 #include "mf_rlefont.h" 9 #include <stdbool.h> 10 11 /* Callback function for handling each line. 12 * 13 * line: Pointer to the beginning of the string for this line. 14 * count: Number of characters on the line. 15 * state: Free variable that was passed to wordwrap(). 16 * 17 * Returns: true to continue, false to stop after this line. 18 */ 19 typedef bool (*mf_line_callback_t) (mf_str line, uint16_t count, 20 void *state); 21 22 /* Word wrap a piece of text. Calls the callback function for each line. 23 * 24 * font: Font to use for metrics. 25 * width: Maximum line width in pixels. 26 * text: Pointer to the start of the text to process. 27 * state: Free variable for caller to use (can be NULL). 28 */ 29 MF_EXTERN void mf_wordwrap(const struct mf_font_s *font, int16_t width, 30 mf_str text, mf_line_callback_t callback, void *state); 31 32 void mf_text_draw_area(const struct mf_font_s *font, int16_t width, 33 mf_str text, int *total_height_in_rows, 34 int *max_pixels_per_row); 35 #endif 36