From 10a9f0e03046a82e7d361e5a28e5de46a9811866 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 5 Sep 2009 11:33:05 +0000 Subject: Simplify and fix some long-standing highlight/layout issues svn path=/trunk/netsurf/; revision=9538 --- amiga/font.c | 67 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 23 deletions(-) (limited to 'amiga/font.c') diff --git a/amiga/font.c b/amiga/font.c index 440cd02b2..4c84d1d3f 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -97,6 +97,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, size_t len,utf8len; uint8 *utf8; uint32 co = 0; + int utf16charlen; len = utf8_bounded_length(string, length); if(utf8_to_enc(string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false; @@ -108,6 +109,14 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, for(i=0;iolf_EEngine, OT_GlyphCode,*utf16, TAG_END) == OTERR_Success) @@ -116,10 +125,6 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, OT_GlyphMap8Bit,&glyph, TAG_END) == 0) { - if(utf8_from_enc((char *)utf16,"UTF-16",2,(char **)&utf8) != UTF8_CONVERT_OK) return false; - utf8len = utf8_char_byte_length(utf8); - free(utf8); - if(xglm_X1) { i = len+1; @@ -137,10 +142,7 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle, TAG_END); } } - if (*utf16 < 0xD800 || 0xDFFF < *utf16) - utf16++; - else - utf16 += 2; + utf16 += utf16charlen; } *char_offset = co; if(co>=length) *actual_x = tx; @@ -172,13 +174,15 @@ bool nsfont_split(const plot_font_style_t *fstyle, { struct TextExtent extent; ULONG co; - char *charp; + char *ostr = string; struct TextFont *tfont; uint16 *utf16 = NULL,*outf16 = NULL; struct OutlineFont *ofont; struct GlyphMap *glyph; uint32 tx=0,i=0; size_t len; + int utf8len, utf8clen = 0; + bool found = false; len = utf8_bounded_length(string, length); if(utf8_to_enc((char *)string,"UTF-16",length,(char **)&utf16) != UTF8_CONVERT_OK) return false; @@ -197,37 +201,54 @@ bool nsfont_split(const plot_font_style_t *fstyle, OT_GlyphMap8Bit,&glyph, TAG_END) == 0) { - if(*utf16 == 0x0020) + if(x < (tx + glyph->glm_X1)) { - *actual_x = tx; - co = i; + i = length+1; } - - if(xglm_X1) + else { - i = length+1; + if(*string == ' ') //*utf16 == 0x0020) + { + *actual_x = tx; + *char_offset = utf8clen; + found = true; + } + + tx+= glyph->glm_X1; } - tx+= glyph->glm_X1; - EReleaseInfo(&ofont->olf_EEngine, OT_GlyphMap8Bit,glyph, TAG_END); } } + if (*utf16 < 0xD800 || 0xDFFF < *utf16) - utf16++; + utf16 += 1; else utf16 += 2; + + utf8len = utf8_char_byte_length(string); + string += utf8len; + utf8clen += utf8len; } - charp = (char *)(string+co); - while(((*charp != ' ')) && (charp > string)) +/* + while(((*string != ' ')) && (string > ostr)) { - charp--; - co--; + * todo: calc size of preceding character * + utf8len = 1; + string -= utf8len; + co -= utf8len; } - *char_offset = co; +*/ + + if(found == false) + { + *char_offset = utf8clen; + *actual_x = tx; + } + free(outf16); return true; -- cgit v1.2.3