From fdae6ceea23bac44f86fc271612227ea53de2fef Mon Sep 17 00:00:00 2001 From: Yong Sun Date: Wed, 4 Feb 2004 05:12:47 +0000 Subject: Fix a bug in evolution/calendar/gui/print.c: bound_text(). It does not 2004-02-04 Yong Sun * gui/print.c: Fix a bug in evolution/calendar/gui/print.c: bound_text(). It does not break lines with the correct boundary of UTF-8 characters. So, for non-latin locales, it will cause printing issues. svn path=/trunk/; revision=24600 --- calendar/gui/print.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'calendar/gui/print.c') diff --git a/calendar/gui/print.c b/calendar/gui/print.c index f83cb473b5..3c32ef1448 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -743,11 +743,15 @@ bound_text(GnomePrintContext *pc, GnomeFont *font, const char *text, *o++=c; if (c==' ') wordstart = o; - width+=gnome_font_get_glyph_width(font, gnome_font_lookup_default (font, c)); - if (width>maxwidth) - dump=1; - else - dump=0; + + dump=0; + if (g_utf8_validate (p, strlen(p), NULL)) { + width+=gnome_font_get_glyph_width(font, gnome_font_lookup_default (font, c)); + if (width>maxwidth) { + o--; + dump=1; + } + } } if (dump) { if (wordstart==outbuffer) @@ -772,8 +776,9 @@ bound_text(GnomePrintContext *pc, GnomeFont *font, const char *text, maxwidth -= indent; first=0; } + } else { + p++; } - p++; } if (dump==0) { *o=0; @@ -782,6 +787,7 @@ bound_text(GnomePrintContext *pc, GnomeFont *font, const char *text, top -= gnome_font_get_size (font); } g_free(outbuffer); + return top; } -- cgit v1.2.3