diff options
Diffstat (limited to 'amiga/font.c')
-rw-r--r-- | amiga/font.c | 41 |
1 files changed, 21 insertions, 20 deletions
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; } |