--- pango/break.c.orig	2014-08-14 15:55:31.017785259 +0200
+++ pango/break.c	2014-08-14 22:37:39.261433279 +0200
@@ -485,7 +485,7 @@
 		     gint           length,
 		     PangoAnalysis *analysis G_GNUC_UNUSED,
 		     PangoLogAttr  *attrs,
-		     int            attrs_len G_GNUC_UNUSED)
+		     int            attrs_len)
 {
   /* The rationale for all this is in section 5.15 of the Unicode 3.0 book,
    * the line breaking stuff is also in TR14 on unicode.org
@@ -542,7 +542,6 @@
   gint prev_WB_i = -1;
 
   WordType current_word_type = WordNone;
-  gunichar last_word_letter = 0;
   gunichar base_character = 0;
 
   SentenceState sentence_state = STATE_SENTENCE_OUTSIDE;
@@ -555,6 +554,8 @@
   gboolean almost_done = FALSE;
   gboolean done = FALSE;
 
+  gint possible_word_start = 0;
+ 
   g_return_if_fail (length == 0 || text != NULL);
   g_return_if_fail (attrs != NULL);
 
@@ -1113,93 +1114,6 @@
       else
 	prev_was_break_space = TRUE;
 
-      /* ---- Word breaks ---- */
-
-      /* default to not a word start/end */
-      attrs[i].is_word_start = FALSE;
-      attrs[i].is_word_end = FALSE;
-
-      if (current_word_type != WordNone)
-	{
-	  /* Check for a word end */
-	  switch ((int) type)
-	    {
-	    case G_UNICODE_SPACING_MARK:
-	    case G_UNICODE_ENCLOSING_MARK:
-	    case G_UNICODE_NON_SPACING_MARK:
-	    case G_UNICODE_FORMAT:
-	      /* nothing, we just eat these up as part of the word */
-	      break;
-
-	    case G_UNICODE_LOWERCASE_LETTER:
-	    case G_UNICODE_MODIFIER_LETTER:
-	    case G_UNICODE_OTHER_LETTER:
-	    case G_UNICODE_TITLECASE_LETTER:
-	    case G_UNICODE_UPPERCASE_LETTER:
-	      if (current_word_type == WordLetters)
-		{
-		  /* Japanese special cases for ending the word */
-		  if (JAPANESE (last_word_letter) ||
-		      JAPANESE (wc))
-		    {
-		      if ((HIRAGANA (last_word_letter) &&
-			   !HIRAGANA (wc)) ||
-			  (KATAKANA (last_word_letter) &&
-			   !(KATAKANA (wc) || HIRAGANA (wc))) ||
-			  (KANJI (last_word_letter) &&
-			   !(HIRAGANA (wc) || KANJI (wc))) ||
-			  (JAPANESE (last_word_letter) &&
-			   !JAPANESE (wc)) ||
-			  (!JAPANESE (last_word_letter) &&
-			   JAPANESE (wc)))
-			attrs[i].is_word_end = TRUE;
-		    }
-		}
-	      last_word_letter = wc;
-	      break;
-
-	    case G_UNICODE_DECIMAL_NUMBER:
-	    case G_UNICODE_LETTER_NUMBER:
-	    case G_UNICODE_OTHER_NUMBER:
-	      last_word_letter = wc;
-	      break;
-
-	    default:
-	      /* Punctuation, control/format chars, etc. all end a word. */
-	      attrs[i].is_word_end = TRUE;
-	      current_word_type = WordNone;
-	      break;
-	    }
-	}
-      else
-	{
-	  /* Check for a word start */
-	  switch ((int) type)
-	    {
-	    case G_UNICODE_LOWERCASE_LETTER:
-	    case G_UNICODE_MODIFIER_LETTER:
-	    case G_UNICODE_OTHER_LETTER:
-	    case G_UNICODE_TITLECASE_LETTER:
-	    case G_UNICODE_UPPERCASE_LETTER:
-	      current_word_type = WordLetters;
-	      last_word_letter = wc;
-	      attrs[i].is_word_start = TRUE;
-	      break;
-
-	    case G_UNICODE_DECIMAL_NUMBER:
-	    case G_UNICODE_LETTER_NUMBER:
-	    case G_UNICODE_OTHER_NUMBER:
-	      current_word_type = WordNumbers;
-	      last_word_letter = wc;
-	      attrs[i].is_word_start = TRUE;
-	      break;
-
-	    default:
-	      /* No word here */
-	      break;
-	    }
-	}
-
       /* ---- Sentence breaks ---- */
 
       /* The Unicode spec specifies sentence breakpoints, so that a piece of
@@ -1640,6 +1554,44 @@
   attrs[i].is_line_break = TRUE;  /* Rule LB3 */
   attrs[0].is_line_break = FALSE; /* Rule LB2 */
 
+  /* ---- Word breaks ---- */
+
+  /* Calculate start and end of words based on word boundaries.  If
+     there is any alphanumeric character between two word boundaries,
+     consider such boundaries to be the start and end of a word. */
+
+  current_word_type = WordNone;
+  
+  for (i=0; i < attrs_len; i++) {
+
+    gunichar wc;
+
+    attrs[i].is_word_start = FALSE;
+    attrs[i].is_word_end = FALSE;
+
+    if (attrs[i].is_word_boundary) {
+
+      if (current_word_type != WordNone) {
+    	/* we are at the end of a word */
+    	attrs[i].is_word_end = TRUE;
+    	attrs[possible_word_start].is_word_start = TRUE;
+      }
+
+      possible_word_start = i;
+      current_word_type = WordNone;
+    }
+
+    if (i < (attrs_len-1) && current_word_type == WordNone) {
+      /* check whether current character is a word constituent */
+
+      wc = g_utf8_get_char(g_utf8_offset_to_pointer(text, i));
+
+      if (g_unichar_isalnum(wc)) {
+    	current_word_type = WordLetters;
+      }
+    }
+  }
+
 }
 
 static gboolean
