|
ginnOS
The reference: libc, the libraries and the kernel
|
bragi: UTF-8, measuring and drawing lines, wrapping, text boxes. More...
Macros | |
| #define | REPLACEMENT 0xFFFDu |
| #define | ELLIPSIS 0x2026u |
Functions | |
| uint32_t | bragi_utf8_next (const char **text, const char *end) |
| decode one character of UTF-8. | |
| int32_t | bragi_measure (bragi_face_t *face, const char *text, int32_t length) |
| the width of a line of text in pixels (rounded up). | |
| int32_t | bragi_draw (gfx_buffer_t *buf, bragi_face_t *face, int32_t x, int32_t baseline, const char *text, int32_t length, gfx_color_t color) |
| draw a line of text. | |
| int32_t | bragi_caret_x (bragi_face_t *face, const char *text, int32_t length, int32_t offset) |
| where a caret before the byte at offset goes, in pixels from the start of the line (rounded to the nearest pixel). | |
| int32_t | bragi_offset_at (bragi_face_t *face, const char *text, int32_t length, int32_t x) |
| the caret place nearest to x (pixels from the start of the line), for a click in a text field. | |
| int32_t | bragi_wrap (bragi_face_t *face, const char *text, int32_t width, const char **next) |
| how many bytes of a line fit in a width, broken at a space if one is in the part that fits, else inside a word (at least one character). | |
| int32_t | bragi_measure_box (bragi_face_t *face, const char *text, int32_t width) |
| the height a paragraph needs at a width (all of it, nothing cut off). | |
| int32_t | bragi_draw_box (gfx_buffer_t *buf, bragi_face_t *face, gfx_rect_t box, const char *text, bragi_align_t align, gfx_color_t color) |
| draw a paragraph in a box: wrapped to the box's width, aligned, and as many lines as fit in its height. | |
bragi: UTF-8, measuring and drawing lines, wrapping, text boxes.
| #define REPLACEMENT 0xFFFDu |
| #define ELLIPSIS 0x2026u |
| uint32_t bragi_utf8_next | ( | const char ** | text, |
| const char * | end ) |
decode one character of UTF-8.
| text | the bytes; *text moves past the character. |
| end | the end of the bytes. |
| int32_t bragi_measure | ( | bragi_face_t * | face, |
| const char * | text, | ||
| int32_t | length ) |
the width of a line of text in pixels (rounded up).
a newline does not end it: use the layout calls for more than one line.
| length | bytes of text, or -1 for up to the terminating zero. |
| int32_t bragi_draw | ( | gfx_buffer_t * | buf, |
| bragi_face_t * | face, | ||
| int32_t | x, | ||
| int32_t | baseline, | ||
| const char * | text, | ||
| int32_t | length, | ||
| gfx_color_t | color ) |
draw a line of text.
| x | the left end of the text. |
| baseline | the y of the baseline. |
| int32_t bragi_caret_x | ( | bragi_face_t * | face, |
| const char * | text, | ||
| int32_t | length, | ||
| int32_t | offset ) |
where a caret before the byte at offset goes, in pixels from the start of the line (rounded to the nearest pixel).
| offset | a byte offset at the start of a character; it is cut to the text. |
| int32_t bragi_offset_at | ( | bragi_face_t * | face, |
| const char * | text, | ||
| int32_t | length, | ||
| int32_t | x ) |
the caret place nearest to x (pixels from the start of the line), for a click in a text field.
| int32_t bragi_wrap | ( | bragi_face_t * | face, |
| const char * | text, | ||
| int32_t | width, | ||
| const char ** | next ) |
how many bytes of a line fit in a width, broken at a space if one is in the part that fits, else inside a word (at least one character).
| next | receives where the following line starts (after the spaces and the newline the line ends with). |
| int32_t bragi_measure_box | ( | bragi_face_t * | face, |
| const char * | text, | ||
| int32_t | width ) |
the height a paragraph needs at a width (all of it, nothing cut off).
| int32_t bragi_draw_box | ( | gfx_buffer_t * | buf, |
| bragi_face_t * | face, | ||
| gfx_rect_t | box, | ||
| const char * | text, | ||
| bragi_align_t | align, | ||
| gfx_color_t | color ) |
draw a paragraph in a box: wrapped to the box's width, aligned, and as many lines as fit in its height.
if not all the text fits, the last line ends with "..." (U+2026 when the font has it).