mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-12 04:24:22 +03:00
Ensure that actual_x is set when string fits inside available_width.
This commit is contained in:
parent
918aa9d266
commit
91d05fc0f1
53
amiga/font.c
53
amiga/font.c
@ -245,11 +245,9 @@ bool nsfont_split(const plot_font_style_t *fstyle,
|
||||
FIXED kern = 0;
|
||||
int utf16charlen = 0;
|
||||
struct OutlineFont *ofont, *ufont = NULL;
|
||||
uint32 tx=0,i=0;
|
||||
size_t len;
|
||||
uint32 tx=0;
|
||||
int utf8_pos = 0;
|
||||
int32 tempx = 0;
|
||||
size_t coffset = 0;
|
||||
ULONG emwidth = (ULONG)NSA_FONT_EMWIDTH(fstyle->size);
|
||||
|
||||
if(utf8_to_enc((char *)string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false;
|
||||
@ -269,52 +267,47 @@ bool nsfont_split(const plot_font_style_t *fstyle,
|
||||
|
||||
tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
|
||||
|
||||
if(tempx == 0)
|
||||
{
|
||||
if (tempx == 0) {
|
||||
if (ufont == NULL)
|
||||
{
|
||||
ufont = ami_open_outline_font(fstyle, *utf16);
|
||||
}
|
||||
|
||||
if (ufont)
|
||||
{
|
||||
tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
|
||||
tempx = ami_font_width_glyph(ufont, *utf16,
|
||||
utf16next, emwidth);
|
||||
}
|
||||
/*
|
||||
if(tempx == 0)
|
||||
{
|
||||
tempx = ami_font_width_glyph(ofont, 0xfffd, utf16next, emwidth);
|
||||
|
||||
/* Check whether we have a space */
|
||||
if (*(string + utf8_pos) == ' ') {
|
||||
/* Got a space */
|
||||
*actual_x = tx;
|
||||
*char_offset = utf8_pos;
|
||||
|
||||
if (x < tx) {
|
||||
/* Beyond available width,
|
||||
* so don't look further */
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
tx += tempx;
|
||||
|
||||
if ((x < tx) && (coffset != 0)) {
|
||||
/* Reached available width, and a space has been found; split there. */
|
||||
break;
|
||||
|
||||
} else if (*(string + utf8_pos) == ' ') {
|
||||
*actual_x = tx;
|
||||
coffset = utf8_pos;
|
||||
|
||||
if (x < tx) {
|
||||
/* Out of space, so don't look further */
|
||||
break;
|
||||
}
|
||||
if ((x < tx) && (*char_offset != 0)) {
|
||||
/* Reached available width, and a space was found;
|
||||
* split there. */
|
||||
return true;
|
||||
}
|
||||
|
||||
utf16 += utf16charlen;
|
||||
utf8_pos = utf8_next(string, length, utf8_pos);
|
||||
}
|
||||
|
||||
free(outf16);
|
||||
|
||||
if(coffset == 0) {
|
||||
/* No spaces to split at, or everything fits */
|
||||
assert(*char_offset == 0 || x >= tx);
|
||||
|
||||
*char_offset = length;
|
||||
*actual_x = tx;
|
||||
} else {
|
||||
*char_offset = coffset;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user