? iter_fix_cvs050206.diff
? pango-layout.iterfix.c
Index: pango-layout.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-layout.c,v
retrieving revision 1.131
diff -r1.131 pango-layout.c
96,97c96,97
<   /* The next cluster_start */
<   int next_cluster_start;
---
>   /* The cluster_start of next LOGICAL cluster */
>   int cluster_end;
4317a4318,4350
> next_logical_cluster_start_rtl (PangoGlyphString *gs,
> 				int               cluster_start)
> {
>   int i;
> 
>   i = cluster_start - 1;
>   while (i >=0)
>     {
>       if (gs->glyphs[i].attr.is_cluster_start)
>         return i;
>       
>       --i;
>     }
> 
>   return gs->num_glyphs;
> }
> 
> static int
> cluster_end (PangoGlyphString *gs,
> 	     int               cluster_start,
> 	     gboolean          ltr)
> {
>   if (ltr)
>     {
>       return next_cluster_start (gs , cluster_start);
>     }
>   else
>     {
>       return next_logical_cluster_start_rtl (gs , cluster_start);
>     }
> }
> 
> static int
4324c4357
<   if (iter->next_cluster_start == gs->num_glyphs)
---
>   if (iter->cluster_end == gs->num_glyphs)
4326,4330c4359
<       /* Use the left or right end of the run */
<       if (iter->ltr)
<         return iter->run->item->length;
<       else
<         return 0;
---
>       return iter->run->item->length;
4334c4363
<       return gs->log_clusters[iter->next_cluster_start];
---
>       return gs->log_clusters[iter->cluster_end];
4390,4394c4419
<   if (iter->ltr)    
<     iter->cluster_x = iter->run_logical_rect.x;
<   else
<     iter->cluster_x = iter->run_logical_rect.x +
<       iter->run_logical_rect.width;
---
>   iter->cluster_x = iter->run_logical_rect.x;
4399,4400c4424,4426
<     iter->next_cluster_start = next_cluster_start (iter->run->glyphs,
<                                                    iter->cluster_start);
---
>     iter->cluster_end = cluster_end (iter->run->glyphs,
>                                      iter->cluster_start,
>                                      iter->ltr);
4402c4428
<     iter->next_cluster_start = 0;
---
>     iter->cluster_end = 0;
4415c4441
<   iter->index = run_start_index;
---
>   iter->index = run_start_index + iter->cluster_index;
4457c4483
<   new->next_cluster_start = iter->next_cluster_start;
---
>   new->cluster_end = iter->cluster_end;
4486a4513
>   int run_start_index;
4501a4529
>   run_start_index = iter->line->start_index;
4504c4532,4535
<     iter->run = iter->run_list_link->data;
---
>     {
>       iter->run = iter->run_list_link->data;
>       run_start_index = iter->run->item->offset;
>     }
4516c4547
<   update_run (iter, 0);
---
>   update_run (iter, run_start_index);
4629c4660
<   int next_cluster_index;
---
>   int abs_cluster_end_index;
4640c4671
<   next_cluster_index = iter->run->item->offset + cluster_end_index (iter);
---
>   abs_cluster_end_index = iter->run->item->offset + cluster_end_index (iter);
4644,4656c4675,4679
<   if (iter->ltr)
<     {
<       item_end = iter->layout->text +
<         iter->run->item->offset +
<         iter->run->item->length;
<       p = g_utf8_next_char (oldp);
<     }
<   else
<     {
<       item_end = iter->layout->text + iter->run->item->offset;
<       p = g_utf8_prev_char (oldp);
<     }
< 
---
>   item_end = iter->layout->text +
>     iter->run->item->offset +
>     iter->run->item->length;
>   p = g_utf8_next_char (oldp);
>   
4658,4661c4681,4682
< 
<   /* Make sure we don't go past the next cluster index */
<   g_assert ((iter->ltr && (new_index <= next_cluster_index)) ||
<             (!iter->ltr && (new_index >= next_cluster_index)));
---
>   /* Make sure we don't go past the end-of-cluster index */
>   g_assert (new_index <= abs_cluster_end_index);
4663c4684
<   if (new_index == next_cluster_index)
---
>   if (new_index == abs_cluster_end_index)
4684a4706
>   int next_start;
4694c4716,4717
<   if (iter->next_cluster_start == gs->num_glyphs)
---
>   next_start = next_cluster_start(gs,iter->cluster_start);
>   if (next_start == gs->num_glyphs)
4698,4704c4721,4728
<       if (iter->ltr)
<         iter->cluster_x += gs->glyphs[iter->cluster_start].geometry.width;
<       else
<         iter->cluster_x -= gs->glyphs[iter->cluster_start].geometry.width;
<         
<       iter->cluster_start = iter->next_cluster_start;
<       iter->next_cluster_start = next_cluster_start (gs, iter->cluster_start);
---
>       /* AA: in the hebrew engine, the width is stored in the LAST glyph
>        * I don't know what do the other engines do:
>        * If you want to be safe, you should probably add all the glyph widths.
>        */
>       iter->cluster_x += gs->glyphs[next_start-1].geometry.width;
>       
>       iter->cluster_start = next_start;
>       iter->cluster_end = cluster_end (gs, iter->cluster_start, iter->ltr);
4723c4747
<   gint prev_run_end;
---
>   gint next_run_start;
4732c4756
<     prev_run_end = iter->run->item->offset + iter->run->item->length;
---
>     next_run_start = iter->run->item->offset + iter->run->item->length;
4747a4772
>       next_run_start = iter->run->item->offset;
4750c4775
<   update_run (iter, prev_run_end);
---
>   update_run (iter, next_run_start);
4853,4859c4878
<   if (end_index < start_index)
<     {
<       int tmp = end_index;
<       end_index = start_index;
<       start_index = tmp;
<     }
< 
---
>   /* Should not have null clusters */
4884a4904,4910
>   /* AA: Q: dividing the cluster - does it have any meaning at all?
>    *  (e.g. - when doing fixed font - do they still overlap or not?)
>    *  If yes: then visual order should still be reverse inside cluster
>    *      --> all my changes should be reviewed
>    *  If no: width & x should be either the same or go visually: in visual order x should
>    *      never decrease.
>    */
4888c4914
<     logical_rect->x = cluster_rect.x + cluster_rect.width - char_width * cluster_offset;
---
>     logical_rect->x = cluster_rect.x + cluster_rect.width - char_width * (cluster_offset + 1);
4920c4946
<                                     iter->next_cluster_start,
---
>                                     next_cluster_start(iter->run->glyphs,iter->cluster_start),/*AA:FIXME*/
