summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-09 20:28:35 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2008-08-09 20:28:35 +0000
commit289196c6babb2c1913a3bec9138fe2d49b9b820e (patch)
tree578b9dca2a6f7a8a2330802047bd33462de80578 /amiga
parent105bfddae927e5fed409bea95ce4e0d8c7503331 (diff)
downloadnetsurf-289196c6babb2c1913a3bec9138fe2d49b9b820e.tar.gz
netsurf-289196c6babb2c1913a3bec9138fe2d49b9b820e.tar.bz2
Functions now return correct values for proper text formatting.
svn path=/trunk/netsurf/; revision=4983
Diffstat (limited to 'amiga')
-rw-r--r--amiga/font.c41
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;
}