From 394263bb2f81ce0d330058468496ecfa387ca60e Mon Sep 17 00:00:00 2001 From: Chris Young Date: Thu, 7 Aug 2008 18:44:28 +0000 Subject: Basic plotter functions and support code for the plotters. svn path=/trunk/netsurf/; revision=4948 --- amiga/font.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'amiga/font.c') diff --git a/amiga/font.c b/amiga/font.c index 49c1cdc8c..a6c3b4e1e 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -20,6 +20,8 @@ #include #include "css/css.h" #include "render/font.h" +#include "amiga/gui.h" +#include static bool nsfont_width(const struct css_style *style, const char *string, size_t length, @@ -43,13 +45,28 @@ bool nsfont_width(const struct css_style *style, const char *string, size_t length, int *width) { - assert(style); - assert(string); +// ULONG w; + +printf("nsfont_width\n"); - *width = length * 10; + *width = TextLength(currp,string,length); + +// *width = length*10; return true; } +/** + * Find the position in a string where an x coordinate falls. + * + * \param style css_style for this text, with style->font_size.size == + * CSS_FONT_SIZE_LENGTH + * \param string UTF-8 string to measure + * \param length length of string + * \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 nsfont_position_in_string(const struct css_style *style, const char *string, size_t length, @@ -66,6 +83,23 @@ bool nsfont_position_in_string(const struct css_style *style, } +/** + * Find where to split a string to make it fit a width. + * + * \param style css_style for this text, with style->font_size.size == + * CSS_FONT_SIZE_LENGTH + * \param string UTF-8 string to measure + * \param length length of string + * \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 nsfont_split(const struct css_style *style, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) -- cgit v1.2.3