From 13cd9d7de8d07326abc7ed081aa65a106e495161 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 14 Jun 2007 12:58:57 +0000 Subject: Handle positioning for ligatures like fi and fl better. Pango treats these as one cluster so the width of the cluster is spread amongst the bytes. --- gtk/PlatGTK.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'gtk') diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index a38137684..3cdfeb195 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1383,8 +1383,11 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi pango_layout_iter_get_cluster_extents(iter, NULL, &pos); int position = PANGO_PIXELS(pos.x); int curIndex = pango_layout_iter_get_index(iter); + int places = curIndex - i; + int distance = position - positions[i-1]; while (i < curIndex) { - positions[i++] = position; + positions[i] = position - (curIndex - 1 - i) * distance / places; + i++; } } while (i < lenPositions) @@ -1436,12 +1439,19 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi utfForm = UTF8FromLatin1(s, len); } pango_layout_set_text(layout, utfForm, len); - int i = 0; 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)) { pango_layout_iter_get_cluster_extents(iter, NULL, &pos); - positions[i++] = PANGO_PIXELS(pos.x); + int position = PANGO_PIXELS(pos.x); + int curIndex = pango_layout_iter_get_index(iter); + int places = curIndex - i; + int distance = position - positions[i-1]; + while (i < curIndex) { + positions[i] = position - (curIndex - 1 - i) * distance / places; + i++; + } } while (i < lenPositions) positions[i++] = PANGO_PIXELS(pos.x + pos.width); -- cgit v1.2.3