--- htmltext.c	2003-06-12 17:02:11.000000000 +0800
+++ htmltext.c.1.1	2003-06-12 17:02:54.000000000 +0800
@@ -14,7 +14,7 @@
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
-   
+                             
    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
@@ -587,10 +587,23 @@
 {
 	guint words = 1;
 
+    /*
+     *Modifed by zhancb 2003-6-4,fixing for counting Chinese text words
+     *The below is the original code
 	while ((s = strchr (s, ' '))) {
 		words ++;
 		s ++;
 	}
+    */
+    while ( s && *s )
+    {
+        if ( *s == ' ' || *s < 0 )
+            words ++ ;
+        s = g_utf8_next_char ( s );
+    }
+    /*
+     *Modified End
+     */
 
 	return words;
 }
@@ -660,7 +673,7 @@
 	gl = glyphs;
 	cl = 0;
 	for (i = 0; i < text->words; i++) {
-		while (*end && *end != ' ') {
+		while (*end && *end != ' ' && *end >= 0/*Added by zhancb,a new and condition*/) {
 			end = g_utf8_next_char (end);
 			end_offset++;
 		}			
