diff options
author | nyamatongwe <unknown> | 2005-08-04 04:36:39 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2005-08-04 04:36:39 +0000 |
commit | f633204e0e8f22846d384d00a1c480ae85c4bf8b (patch) | |
tree | b792659037ca5e633bedc621f438d3ab09771c95 | |
parent | fb19206276a514402c07587a30dd5b8d599b7fd9 (diff) | |
download | scintilla-mirror-f633204e0e8f22846d384d00a1c480ae85c4bf8b.tar.gz |
Patch, mostly from Naba, to make work with Pango 1.8.
-rw-r--r-- | gtk/PlatGTK.cxx | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index f3d672774..bf3504f8b 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1258,6 +1258,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi if (font_.GetID()) { int totalWidth = 0; #ifdef USE_PANGO + const int lenPositions = len; if (PFont(font_)->pfd) { if (len == 1) { int width = PFont(font_)->CharWidth(*s, et); @@ -1271,17 +1272,21 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi if (et == UTF8) { // Simple and direct as UTF-8 is native Pango encoding pango_layout_set_text(layout, s, len); - PangoLayoutIter *iter = pango_layout_get_iter (layout); + PangoLayoutIter *iter = pango_layout_get_iter(layout); + pango_layout_iter_get_cluster_extents(iter, NULL, &pos); int i = 0; - while (pango_layout_iter_next_cluster (iter)) { + while (pango_layout_iter_next_cluster(iter)) { pango_layout_iter_get_cluster_extents(iter, NULL, &pos); int position = PANGO_PIXELS(pos.x); - int curIndex = pango_layout_iter_get_index (iter); + int curIndex = pango_layout_iter_get_index(iter); while (i < curIndex) { positions[i++] = position; } } - pango_layout_iter_free (iter); + while (i < lenPositions) + positions[i++] = PANGO_PIXELS(pos.x + pos.width); + pango_layout_iter_free(iter); + PLATFORM_ASSERT(i == lenPositions); } else { int positionsCalculated = 0; if (et == dbcs) { @@ -1295,11 +1300,12 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi pango_layout_set_text(layout, utfForm, strlen(utfForm)); int i = 0; int utfIndex = 0; - PangoLayoutIter *iter = pango_layout_get_iter (layout); - while (pango_layout_iter_next_cluster (iter)) { + PangoLayoutIter *iter = pango_layout_get_iter(layout); + pango_layout_iter_get_cluster_extents(iter, NULL, &pos); + while (pango_layout_iter_next_cluster(iter)) { pango_layout_iter_get_cluster_extents (iter, NULL, &pos); int position = PANGO_PIXELS(pos.x); - int utfIndexNext = pango_layout_iter_get_index (iter); + int utfIndexNext = pango_layout_iter_get_index(iter); while (utfIndex < utfIndexNext) { size_t lenChar = MultiByteLenFromIconv(convMeasure, s+i, len-i); //size_t lenChar = mblen(s+i, MB_CUR_MAX); @@ -1310,8 +1316,11 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi utfIndex += UTF8CharLength(utfForm+utfIndex); } } - pango_layout_iter_free (iter); + while (i < lenPositions) + positions[i++] = PANGO_PIXELS(pos.x + pos.width); + pango_layout_iter_free(iter); delete []utfForm; + PLATFORM_ASSERT(i == lenPositions); } } if (positionsCalculated < 1 ) { @@ -1324,17 +1333,21 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi } pango_layout_set_text(layout, utfForm, len); int i = 0; - PangoLayoutIter *iter = pango_layout_get_iter (layout); - while (pango_layout_iter_next_cluster (iter)) { + PangoLayoutIter *iter = pango_layout_get_iter(layout); + pango_layout_iter_get_cluster_extents(iter, NULL, &pos); + while (pango_layout_iter_next_cluster(iter)) { pango_layout_iter_get_cluster_extents(iter, NULL, &pos); positions[i++] = PANGO_PIXELS(pos.x); } + while (i < lenPositions) + positions[i++] = PANGO_PIXELS(pos.x + pos.width); pango_layout_iter_free(iter); if (useGFree) { g_free(utfForm); } else { delete []utfForm; } + PLATFORM_ASSERT(i == lenPositions); } } if (len == 1) { |