diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-08-07 18:44:28 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-08-07 18:44:28 +0000 |
commit | 394263bb2f81ce0d330058468496ecfa387ca60e (patch) | |
tree | 99919fd7a679b1e1eba9fe4ae1d0d1ff6b5bc23e /amiga/font.c | |
parent | 15eb877a4c6b002968db7fce279d7ad093e4d121 (diff) | |
download | netsurf-394263bb2f81ce0d330058468496ecfa387ca60e.tar.gz netsurf-394263bb2f81ce0d330058468496ecfa387ca60e.tar.bz2 |
Basic plotter functions and support code for the plotters.
svn path=/trunk/netsurf/; revision=4948
Diffstat (limited to 'amiga/font.c')
-rw-r--r-- | amiga/font.c | 40 |
1 files changed, 37 insertions, 3 deletions
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 <assert.h> #include "css/css.h" #include "render/font.h" +#include "amiga/gui.h" +#include <proto/graphics.h> 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) |