Improved text reflow more

svn path=/trunk/netsurf/; revision=5208
This commit is contained in:
Chris Young 2008-08-26 18:03:07 +00:00
parent e11fe86d73
commit c7da20b4c1
1 changed files with 31 additions and 12 deletions

View File

@ -51,19 +51,23 @@ bool nsfont_width(const struct css_style *style,
int *width) int *width)
{ {
struct TextFont *tfont = ami_open_font(style); struct TextFont *tfont = ami_open_font(style);
/*
char *buffer; char *buffer;
utf8_to_local_encoding(string,length,&buffer); utf8_to_local_encoding(string,length,&buffer);
if(buffer) if(buffer)
{ {
*width = TextLength(currp,buffer,strlen(buffer)); */
*width = TextLength(currp,string,length); //buffer,strlen(buffer));
/*
} }
else else
{ {
*width=0; *width=0;
} }
*/
ami_close_font(tfont); ami_close_font(tfont);
ami_utf8_free(buffer); // ami_utf8_free(buffer);
return true; return true;
} }
@ -89,10 +93,18 @@ bool nsfont_position_in_string(const struct css_style *style,
char *buffer; char *buffer;
utf8_to_local_encoding(string,length,&buffer); utf8_to_local_encoding(string,length,&buffer);
*char_offset = TextFit(currp,buffer,strlen(buffer), if(buffer)
&extent,NULL,1,x,32767); {
*char_offset = TextFit(currp,buffer,strlen(buffer),
&extent,NULL,1,x,32767);
*actual_x = extent.te_Extent.MaxX; *actual_x = extent.te_Extent.MaxX;
}
else
{
*char_offset = 0;
*actual_x = 0;
}
ami_close_font(tfont); ami_close_font(tfont);
ami_utf8_free(buffer); ami_utf8_free(buffer);
@ -125,24 +137,31 @@ bool nsfont_split(const struct css_style *style,
ULONG co; ULONG co;
char *charp; char *charp;
struct TextFont *tfont = ami_open_font(style); struct TextFont *tfont = ami_open_font(style);
char *buffer; // char *buffer;
utf8_to_local_encoding(string,length,&buffer); // utf8_to_local_encoding(string,length,&buffer);
co = TextFit(currp,buffer,strlen(buffer), co = TextFit(currp,string,length,
&extent,NULL,1,x,32767); &extent,NULL,1,x,32767);
charp = buffer+co; charp = string+co;
while((*charp != ' ') && (charp >= buffer)) while(((*charp != ' ')) && (charp > string))
{ {
charp--; charp--;
co--; co--;
} }
*char_offset = co; *char_offset = co;
*actual_x = TextLength(currp,buffer,co); if(string && co)
{
*actual_x = TextLength(currp,string,co);
}
else
{
*actual_x = 0;
}
ami_close_font(tfont); ami_close_font(tfont);
ami_utf8_free(buffer); // ami_utf8_free(buffer);
return true; return true;
} }