diff options
-rw-r--r-- | desktop/plotters.h | 11 | ||||
-rw-r--r-- | render/font.h | 35 |
2 files changed, 45 insertions, 1 deletions
diff --git a/desktop/plotters.h b/desktop/plotters.h index 4edec321b..076baf242 100644 --- a/desktop/plotters.h +++ b/desktop/plotters.h @@ -114,7 +114,16 @@ struct plotter_table { struct bitmap *bitmap, colour bg, bitmap_flags_t flags); - /* text */ + /** + * Text. + * + * \param x x coordinate + * \param y y coordinate + * \param text UTF-8 string to plot + * \param length length of string, in bytes + * \param fstyle plot style for this text + * \return true on success, false on error and error reported + */ bool (*text)(int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle); diff --git a/render/font.h b/render/font.h index 3012abce0..bc7dc7fba 100644 --- a/render/font.h +++ b/render/font.h @@ -40,12 +40,47 @@ struct font_functions { + /** + * Measure the width of a string. + * + * \param fstyle plot style for this text + * \param string UTF-8 string to measure + * \param length length of string, in bytes + * \param width updated to width of string[0..length) + * \return true on success, false on error and error reported + */ bool (*font_width)(const plot_font_style_t *fstyle, const char *string, size_t length, int *width); + /** + * Find the position in a string where an x coordinate falls. + * + * \param fstyle style for this text + * \param string UTF-8 string to measure + * \param length length of string, in bytes + * \param x x coordinate to search for + * \param char_offset updated to offset in string of actual_x, [0..length] + * \param actual_x updated to x coordinate of character closest to x + * \return true on success, false on error and error reported + */ bool (*font_position_in_string)(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x); + /** + * Find where to split a string to make it fit a width. + * + * \param fstyle style for this text + * \param string UTF-8 string to measure + * \param length length of string, in bytes + * \param x width available + * \param char_offset updated to offset in string of actual_x, [0..length] + * \param actual_x updated to x coordinate of character closest to x + * \return true on success, false on error and error reported + * + * On exit, [char_offset == 0 || + * string[char_offset] == ' ' || + * char_offset == length] + */ bool (*font_split)(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x); |