summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-05-29 15:55:57 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-05-29 15:55:57 +0000
commitf138d945460f2c6e287e098d0bfe04ed20d57f18 (patch)
tree9a6ff9442643056cea66a11b21267aa5bcc8833e /pango
parent45a1d90a3a453950f74bada5c5337554cb596062 (diff)
downloadpango-f138d945460f2c6e287e098d0bfe04ed20d57f18.tar.gz
Fix bug in MRU list code.
Mon May 29 11:14:34 2000 Owen Taylor <otaylor@redhat.com> * pango/pangox-fontcache.c (pango_x_font_cache_load): Fix bug in MRU list code. * pango/pango-layout.c (pango_layout_check_lines): Fix infinite loop in the case where the first item doesn't fit, but whitespace follows that must go onto the same line. * examples/viewer-qt.h: Minor changes so it compiles with Qt-2.0. (Though the utf8 codec in Qt-2.0 seems to be slightly buggy.)
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-layout.c41
-rw-r--r--pango/pangox-fontcache.c4
2 files changed, 27 insertions, 18 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index c0bcb43a..0953d9a3 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1470,11 +1470,19 @@ shape_tab (PangoLayoutLine *line,
}
}
-static gboolean
+typedef enum
+{
+ BREAK_NONE_FIT,
+ BREAK_SOME_FIT,
+ BREAK_ALL_FIT,
+} BreakResult;
+
+static BreakResult
process_item (PangoLayoutLine *line,
PangoItem *item,
const char *text,
PangoLogAttr *log_attrs,
+ gboolean no_break_at_start,
gboolean no_break_at_end,
int *remaining_width)
{
@@ -1483,18 +1491,15 @@ process_item (PangoLayoutLine *line,
int length;
int i;
- if (*remaining_width == 0)
- return FALSE;
-
if (text[item->offset] == '\t')
shape_tab (line, glyphs);
else
pango_shape (text + item->offset, item->length, &item->analysis, glyphs);
- if (*remaining_width < 0)
+ if (*remaining_width < 0) /* Wrapping off */
{
insert_run (line, item, glyphs);
- return TRUE;
+ return BREAK_ALL_FIT;
}
width =0;
@@ -1506,7 +1511,7 @@ process_item (PangoLayoutLine *line,
*remaining_width -= width;
insert_run (line, item, glyphs);
- return TRUE;
+ return BREAK_ALL_FIT;
}
else
{
@@ -1544,21 +1549,21 @@ process_item (PangoLayoutLine *line,
*remaining_width -= width;
insert_run (line, new_item, glyphs);
- return FALSE;
+ return BREAK_SOME_FIT;
}
else
{
- if (!line->runs) /* Only item, insert it anyways */
+ if (no_break_at_start) /* We must insert something */
{
*remaining_width = 0;
insert_run (line, item, glyphs);
- return TRUE;
+ return BREAK_ALL_FIT;
}
else
{
pango_glyph_string_free (glyphs);
- return FALSE;
+ return BREAK_NONE_FIT;
}
}
}
@@ -1670,15 +1675,17 @@ pango_layout_check_lines (PangoLayout *layout)
while (tmp_list)
{
PangoItem *item = tmp_list->data;
- gboolean fits;
+ BreakResult result;
int old_num_chars = item->num_chars;
- fits = process_item (line, item, start,
- layout->log_attrs + start_offset, current_cant_end,
- &remaining_width);
+ result = process_item (line, item, start,
+ layout->log_attrs + start_offset,
+ (line->runs == NULL) || last_cant_end,
+ current_cant_end,
+ &remaining_width);
current_cant_end = FALSE;
- if (fits)
+ if (result == BREAK_ALL_FIT)
{
tmp_list = tmp_list->next;
start_offset += old_num_chars;
@@ -1705,7 +1712,7 @@ pango_layout_check_lines (PangoLayout *layout)
* we need to back up and break the last item.
*/
- if (last_cant_end && old_num_chars - item->num_chars == 0)
+ if (last_cant_end && result == BREAK_NONE_FIT)
{
GSList *tmp_node;
diff --git a/pango/pangox-fontcache.c b/pango/pangox-fontcache.c
index b7d7a7fa..929d3302 100644
--- a/pango/pangox-fontcache.c
+++ b/pango/pangox-fontcache.c
@@ -211,8 +211,10 @@ pango_x_font_cache_load (PangoXFontCache *cache,
}
else
cache->mru_count++;
-
+
cache->mru = g_list_prepend (cache->mru, entry);
+ if (!cache->mru_tail)
+ cache->mru_tail = cache->mru;
entry->mru = cache->mru;
}