Hi,

The attached patch fixes a bug where pango layout is incorrectly
iterated (also added a bound checks for array indexes), which breaks
rendering in pango 1.8 (cvs).

Related bug report:
http://bugzilla.gnome.org/show_bug.cgi?id=311846

Regards,
-Naba

Index: PlatGTK.cxx
===================================================================
RCS file: /cvs/gnome/anjuta/scintilla/PlatGTK.cxx,v
retrieving revision 1.24
diff -u -r1.24 PlatGTK.cxx
--- PlatGTK.cxx	28 Jul 2005 12:04:06 -0000	1.24
+++ PlatGTK.cxx	1 Aug 2005 05:27:11 -0000
@@ -1273,14 +1273,15 @@
 				pango_layout_set_text(layout, s, len);
 				PangoLayoutIter *iter = pango_layout_get_iter (layout);
 				int i = 0;
-				while (pango_layout_iter_next_cluster (iter)) {
+				do {
 					pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-					int position = PANGO_PIXELS(pos.x);
+					int position = PANGO_PIXELS(pos.x + pos.width);
 					int curIndex = pango_layout_iter_get_index (iter);
-					while (i < curIndex) {
+					while (i <= curIndex && i < len) {
 						positions[i++] = position;
 					}
-				}
+				} while (pango_layout_iter_next_cluster (iter));
+
 				pango_layout_iter_free (iter);
 			} else {
 				int positionsCalculated = 0;
@@ -1296,20 +1297,21 @@
 						int i = 0;
 						int utfIndex = 0;
 						PangoLayoutIter *iter = pango_layout_get_iter (layout);
-						while (pango_layout_iter_next_cluster (iter)) {
+						do {
 							pango_layout_iter_get_cluster_extents (iter, NULL, &pos);
-							int position = PANGO_PIXELS(pos.x);
+							int position = PANGO_PIXELS(pos.x + pos.width);
 							int utfIndexNext = pango_layout_iter_get_index (iter);
-							while (utfIndex < utfIndexNext) {
+							while (utfIndex <= utfIndexNext) {
 								size_t lenChar = MultiByteLenFromIconv(convMeasure, s+i, len-i);
 								//size_t lenChar = mblen(s+i, MB_CUR_MAX);
 								while (lenChar--) {
-									positions[i++] = position;
+									if (i < len)
+										positions[i++] = position;
 									positionsCalculated++;
 								}
 								utfIndex += UTF8CharLength(utfForm+utfIndex);
 							}
-						}
+						} while (pango_layout_iter_next_cluster (iter));
 						pango_layout_iter_free (iter);
 						delete []utfForm;
 					}
@@ -1325,10 +1327,11 @@
 					pango_layout_set_text(layout, utfForm, len);
 					int i = 0;
 					PangoLayoutIter *iter = pango_layout_get_iter (layout);
-					while (pango_layout_iter_next_cluster (iter)) {
+					do {
 						pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
-						positions[i++] = PANGO_PIXELS(pos.x);
-					}
+						if (i < len)
+							positions[i++] = PANGO_PIXELS(pos.x + pos.width);
+					} while (pango_layout_iter_next_cluster (iter));
 					pango_layout_iter_free(iter);
 					if (useGFree) {
 						g_free(utfForm);
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to