From 289196c6babb2c1913a3bec9138fe2d49b9b820e Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 9 Aug 2008 20:28:35 +0000 Subject: Functions now return correct values for proper text formatting. svn path=/trunk/netsurf/; revision=4983 --- amiga/font.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'amiga/font.c') diff --git a/amiga/font.c b/amiga/font.c index a6c3b4e1e..e780612a0 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -45,13 +45,7 @@ bool nsfont_width(const struct css_style *style, const char *string, size_t length, int *width) { -// ULONG w; - -printf("nsfont_width\n"); - *width = TextLength(currp,string,length); - -// *width = length*10; return true; } @@ -72,13 +66,12 @@ bool nsfont_position_in_string(const struct css_style *style, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) { - assert(style); - assert(string); + struct TextExtent extent; + + *char_offset = TextFit(currp,string,length, + &extent,NULL,1,x,32767); - *char_offset = (x + 5) / 10; - if (length < *char_offset) - *char_offset = length; - *actual_x = *char_offset * 10; + *actual_x = extent.te_Extent.MaxX; return true; } @@ -104,14 +97,22 @@ bool nsfont_split(const struct css_style *style, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) { - assert(style); - assert(string); + struct TextExtent extent; + ULONG co; + char *charp; + + co = TextFit(currp,string,length, + &extent,NULL,1,x,32767); + + charp = string+co; + while((*charp != ' ') && (charp >= string)) + { + charp--; + co--; + } + + *char_offset = co; + *actual_x = TextLength(currp,string,co); - *char_offset = x / 10; - if (length < *char_offset) - *char_offset = length; - while (*char_offset && string[*char_offset] != ' ') - (*char_offset)--; - *actual_x = *char_offset * 10; return true; } -- cgit v1.2.3