summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-05-03 05:00:32 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-05-03 05:00:32 +0000
commit93610eabadc93133ade1a533f013ba3e84f5e9a1 (patch)
tree09da99d8611aeb4b2faef3fb92a5ec3292eefc96
parente6136047e66154d041626fe40d6a3720142c6203 (diff)
downloadpango-93610eabadc93133ade1a533f013ba3e84f5e9a1.tar.gz
When breaking item to fit it into current line, go from the beginning,
2007-05-03 Behdad Esfahbod <behdad@gnome.org> * pango/pango-layout.c (process_item): When breaking item to fit it into current line, go from the beginning, adding char at a time until it doesn't fit anymore instead of removing chars from the end. The difference is a O(n) as opposed to O(n^2) algorithm were n is the number of lines in the paragraph (assuming constant chars per line). svn path=/trunk/; revision=2257
-rw-r--r--ChangeLog8
-rw-r--r--pango/pango-layout.c13
2 files changed, 15 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index e986ffaf..5b8336ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2007-05-03 Behdad Esfahbod <behdad@gnome.org>
+ * pango/pango-layout.c (process_item): When breaking item to fit it
+ into current line, go from the beginning, adding char at a time until
+ it doesn't fit anymore instead of removing chars from the end. The
+ difference is a O(n) as opposed to O(n^2) algorithm were n is the
+ number of lines in the paragraph (assuming constant chars per line).
+
+2007-05-03 Behdad Esfahbod <behdad@gnome.org>
+
* pango-view/viewer-render.c (output_body), (do_output): Save
one layout rendering per view. Down to two from three now.
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 7ba34642..5e94d498 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3218,11 +3218,13 @@ process_item (PangoLayout *layout,
retry_break:
- /* Shorten the item by one line break
+ /* See how much of the item we can stuff in the line
*/
- while (--num_chars >= 0)
+ width = 0;
+ for (num_chars = 0; num_chars < item->num_chars; num_chars++)
{
- width -= state->log_widths[state->log_widths_offset + num_chars];
+ if (width > state->remaining_width)
+ break;
/* If there are no previous runs we have to take care to grab at least one char. */
if (can_break_at (layout, state->start_offset + num_chars, retrying_with_char_breaks) &&
@@ -3230,10 +3232,9 @@ process_item (PangoLayout *layout,
{
break_num_chars = num_chars;
break_width = width;
-
- if (width <= state->remaining_width || (num_chars == 1 && !line->runs))
- break;
}
+
+ width += state->log_widths[state->log_widths_offset + num_chars];
}
if (layout->wrap == PANGO_WRAP_WORD_CHAR && force_fit && break_width > state->remaining_width && !retrying_with_char_breaks)