From 3977ee687ffff23e49dcac0ea9a7c3e8652248f0 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 28 Jul 2013 17:08:45 +1000 Subject: First cut - beautiful new font handling by PetteriAimonen --- src/gdisp/mcufont/mf_wordwrap.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/gdisp/mcufont/mf_wordwrap.h (limited to 'src/gdisp/mcufont/mf_wordwrap.h') diff --git a/src/gdisp/mcufont/mf_wordwrap.h b/src/gdisp/mcufont/mf_wordwrap.h new file mode 100644 index 00000000..bf3dbcb7 --- /dev/null +++ b/src/gdisp/mcufont/mf_wordwrap.h @@ -0,0 +1,32 @@ +/* Word wrapping algorithm with UTF-8 support. More than just a basic greedy + * word-wrapper: it attempts to balance consecutive lines as pairs. + */ + +#ifndef _MF_WORDWRAP_H_ +#define _MF_WORDWRAP_H_ + +#include "mf_rlefont.h" +#include + +/* Callback function for handling each line. + * + * line: Pointer to the beginning of the string for this line. + * count: Number of characters on the line. + * state: Free variable that was passed to wordwrap(). + * + * Returns: true to continue, false to stop after this line. + */ +typedef bool (*mf_line_callback_t) (mf_str line, uint16_t count, + void *state); + +/* Word wrap a piece of text. Calls the callback function for each line. + * + * font: Font to use for metrics. + * width: Maximum line width in pixels. + * text: Pointer to the start of the text to process. + * state: Free variable for caller to use (can be NULL). + */ +MF_EXTERN void mf_wordwrap(const struct mf_font_s *font, int16_t width, + mf_str text, mf_line_callback_t callback, void *state); + +#endif -- cgit v1.2.3