blob: a1a051fabb47a82ef199779a7079e1cd5258dc3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
* This file is subject to the terms of the GFX License. If a copy of
* the license was not distributed with this file, you can obtain one at:
*
* http://ugfx.io/license.html
*/
/* 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 <stdbool.h>
/* 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
|