summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-01-16 13:16:21 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-01-16 13:16:21 +0000
commit45720d22610c73f8570768ec69537b1c31035f41 (patch)
tree240cfdd2e1733d7f7666767ab9c4da2480d1fb22
parent3ffe3d7c4c36e262caf6c1d6ab7621960b4c9fcb (diff)
downloadpango-45720d22610c73f8570768ec69537b1c31035f41.tar.gz
Fix width calculation. Was causing ellipsization to stop at a zero-width
2007-01-16 Behdad Esfahbod <behdad@gnome.org> * pango/ellipsize.c (get_cluster_width): Fix width calculation. Was causing ellipsization to stop at a zero-width glyph that was part of a bigger cluster. * pango/ellipsize.c (remove_one_span): Skip over zero-width clusters, otherwise ellipsization will stop at a zero-width cluster. * pango/pango-glyph-item.c (_pango_glyph_item_iter_next_cluster), (_pango_glyph_item_iter_prev_cluster): Fix yet another bug with in prev_cluster that was making it not work for any interesting cluster. svn path=/branches/pango-1-14/; revision=2157
-rw-r--r--ChangeLog14
-rw-r--r--pango/ellipsize.c17
-rw-r--r--pango/pango-glyph-item.c14
3 files changed, 35 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e289a95..ae8c6e6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+ * pango/ellipsize.c (get_cluster_width): Fix width calculation.
+ Was causing ellipsization to stop at a zero-width glyph that was
+ part of a bigger cluster.
+
+ * pango/ellipsize.c (remove_one_span): Skip over zero-width clusters,
+ otherwise ellipsization will stop at a zero-width cluster.
+
+ * pango/pango-glyph-item.c (_pango_glyph_item_iter_next_cluster),
+ (_pango_glyph_item_iter_prev_cluster): Fix yet another bug with
+ in prev_cluster that was making it not work for any interesting
+ cluster.
+
+2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pango-renderer.c (pango_renderer_draw_layout_line): Fix
background rendering being off in presence of rise attributes.
diff --git a/pango/ellipsize.c b/pango/ellipsize.c
index b1523afe..675d9391 100644
--- a/pango/ellipsize.c
+++ b/pango/ellipsize.c
@@ -174,12 +174,12 @@ get_cluster_width (LineIter *iter)
if (run_iter->start_glyph < run_iter->end_glyph) /* LTR */
{
for (i = run_iter->start_glyph; i < run_iter->end_glyph; i++)
- width += glyphs->glyphs[run_iter->start_glyph].geometry.width;
+ width += glyphs->glyphs[i].geometry.width;
}
else /* RTL */
{
for (i = run_iter->start_glyph; i > run_iter->end_glyph; i--)
- width += glyphs->glyphs[run_iter->start_glyph].geometry.width;
+ width += glyphs->glyphs[i].geometry.width;
}
return width;
@@ -564,6 +564,7 @@ remove_one_span (EllipsizeState *state)
LineIter new_gap_end_iter;
int new_gap_start_x;
int new_gap_end_x;
+ int width;
/* Find one span backwards and forward from the gap
*/
@@ -573,9 +574,11 @@ remove_one_span (EllipsizeState *state)
{
if (!line_iter_prev_cluster (state, &new_gap_start_iter))
break;
- new_gap_start_x -= get_cluster_width (&new_gap_start_iter);
+ width = get_cluster_width (&new_gap_start_iter);
+ new_gap_start_x -= width;
}
- while (!starts_at_ellipsization_boundary (state, &new_gap_start_iter));
+ while (!starts_at_ellipsization_boundary (state, &new_gap_start_iter) ||
+ width == 0);
new_gap_end_iter = state->gap_end_iter;
new_gap_end_x = state->gap_end_x;
@@ -583,9 +586,11 @@ remove_one_span (EllipsizeState *state)
{
if (!line_iter_next_cluster (state, &new_gap_end_iter))
break;
- new_gap_end_x += get_cluster_width (&new_gap_end_iter);
+ width = get_cluster_width (&new_gap_end_iter);
+ new_gap_end_x += width;
}
- while (!ends_at_ellipsization_boundary (state, &new_gap_end_iter));
+ while (!ends_at_ellipsization_boundary (state, &new_gap_end_iter) ||
+ width == 0);
if (state->gap_end_x == new_gap_end_x && state->gap_start_x == new_gap_start_x)
return FALSE;
diff --git a/pango/pango-glyph-item.c b/pango/pango-glyph-item.c
index 6ca256c9..0030cda8 100644
--- a/pango/pango-glyph-item.c
+++ b/pango/pango-glyph-item.c
@@ -163,6 +163,7 @@ _pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter)
{
int glyph_index = iter->end_glyph;
PangoGlyphString *glyphs = iter->glyph_item->glyphs;
+ int cluster;
PangoItem *item = iter->glyph_item->item;
if (LTR (iter->glyph_item))
@@ -182,6 +183,7 @@ _pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter)
if (LTR (iter->glyph_item))
{
+ cluster = glyphs->log_clusters[glyph_index + 1];
while (TRUE)
{
glyph_index++;
@@ -193,7 +195,7 @@ _pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter)
break;
}
- if (item->offset + glyphs->log_clusters[glyph_index] != iter->start_index)
+ if (glyphs->log_clusters[glyph_index] != cluster)
{
iter->end_index = item->offset + glyphs->log_clusters[glyph_index];
iter->end_char += g_utf8_strlen (iter->text + iter->start_index,
@@ -204,6 +206,7 @@ _pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter)
}
else /* RTL */
{
+ cluster = glyphs->log_clusters[glyph_index - 1];
while (TRUE)
{
glyph_index--;
@@ -215,7 +218,7 @@ _pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter)
break;
}
- if (item->offset + glyphs->log_clusters[glyph_index] != iter->start_index)
+ if (glyphs->log_clusters[glyph_index] != cluster)
{
iter->end_index = item->offset + glyphs->log_clusters[glyph_index];
iter->end_char += g_utf8_strlen (iter->text + iter->start_index,
@@ -243,6 +246,7 @@ _pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter)
{
int glyph_index = iter->start_glyph;
PangoGlyphString *glyphs = iter->glyph_item->glyphs;
+ int cluster;
PangoItem *item = iter->glyph_item->item;
if (LTR (iter->glyph_item))
@@ -263,6 +267,7 @@ _pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter)
if (LTR (iter->glyph_item))
{
+ cluster = glyphs->log_clusters[glyph_index - 1];
while (TRUE)
{
glyph_index--;
@@ -274,7 +279,7 @@ _pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter)
break;
}
- if (item->offset + glyphs->log_clusters[glyph_index] != iter->end_index)
+ if (glyphs->log_clusters[glyph_index] != cluster)
{
iter->start_index = item->offset + glyphs->log_clusters[glyph_index];
iter->start_char -= g_utf8_strlen (iter->text + iter->start_index,
@@ -285,6 +290,7 @@ _pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter)
}
else /* RTL */
{
+ cluster = glyphs->log_clusters[glyph_index + 1];
while (TRUE)
{
glyph_index++;
@@ -296,7 +302,7 @@ _pango_glyph_item_iter_prev_cluster (PangoGlyphItemIter *iter)
break;
}
- if (item->offset + glyphs->log_clusters[glyph_index] != iter->start_index)
+ if (glyphs->log_clusters[glyph_index] != cluster)
{
iter->start_index = item->offset + glyphs->log_clusters[glyph_index];
iter->start_char -= g_utf8_strlen (iter->text + iter->start_index,