diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 9 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 9 | ||||
-rw-r--r-- | TODO | 5 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | modules/basic/basic-x.c | 2 | ||||
-rw-r--r-- | modules/basic/basic.c | 2 | ||||
-rw-r--r-- | pango/pango-layout.c | 159 | ||||
-rw-r--r-- | pango/pango-layout.h | 4 | ||||
-rw-r--r-- | pango/utils.c | 4 |
14 files changed, 223 insertions, 20 deletions
@@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index f592c6c4..7a85abff 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index f592c6c4..7a85abff 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index f592c6c4..7a85abff 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index f592c6c4..7a85abff 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index f592c6c4..7a85abff 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index f592c6c4..7a85abff 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,12 @@ +Thu Mar 30 16:49:06 2000 Owen Taylor <otaylor@redhat.com> + + * modules/basic/basic.c pango/utils.c (find_converter): Use + "UTF-8" with the dash as the charset name for utf-8. + (Change suggested by Adrian Havill <havill@turbolinux.co.jp>) + + * pango/pango-layout.[ch]: Add function to get logical attributes + of the text string. + Mon Mar 13 11:47:53 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c pango/pangox.c (pango_x_render_layout): Handle right @@ -85,6 +85,11 @@ Fonts General ======= +* unicode_next_utf8() is extensively used on strings which are not + guaranteed to be NULL terminated. This is a BUG. Once I agree + with Tom Tromey on a change to libunicode to make the operation + more efficient, these need to be gone through one-by-one. + * Remove the extraneous font argument from the script_shape virtual function in ShapeEngine. diff --git a/configure.in b/configure.in index 30064c02..540ad8cb 100644 --- a/configure.in +++ b/configure.in @@ -52,11 +52,11 @@ UNICODE_LIBS="`unicode-config --libs`" AC_SUBST(UNICODE_LIBS) AC_SUBST(UNICODE_CFLAGS) -AC_CHECK_FUNCS(flockfile) - AC_CHECK_LIB(unicode, unicode_type, :, AC_MSG_ERROR([*** libunicode not found.]), $UNICODE_LIBS) +AC_CHECK_FUNCS(flockfile) + AC_CHECK_PROG(gtkdoc, gtkdoc-scan, yes, no) AM_CONDITIONAL(HAVE_GTK_DOC, test x$gtkdoc = xyes) diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c index 5e524f72..8f3c7f9e 100644 --- a/modules/basic/basic-x.c +++ b/modules/basic/basic-x.c @@ -299,7 +299,7 @@ find_converter (CharCache *cache, const char *id) iconv_t cd = g_hash_table_lookup (cache->converters, id); if (!cd) { - cd = iconv_open (id, "utf8"); + cd = iconv_open (id, "UTF-8"); g_hash_table_insert (cache->converters, g_strdup(id), (gpointer)cd); } diff --git a/modules/basic/basic.c b/modules/basic/basic.c index 5e524f72..8f3c7f9e 100644 --- a/modules/basic/basic.c +++ b/modules/basic/basic.c @@ -299,7 +299,7 @@ find_converter (CharCache *cache, const char *id) iconv_t cd = g_hash_table_lookup (cache->converters, id); if (!cd) { - cd = iconv_open (id, "utf8"); + cd = iconv_open (id, "UTF-8"); g_hash_table_insert (cache->converters, g_strdup(id), (gpointer)cd); } diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 8330edfe..245aa906 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -42,6 +42,9 @@ struct _PangoLayout guint justify : 1; guint alignment : 2; + gint n_chars; /* Total number of characters in layout */ + PangoLogAttr *log_attrs; /* Logical attributes for layout's text */ + GSList *lines; }; @@ -92,6 +95,7 @@ pango_layout_new (PangoContext *context) layout->alignment = PANGO_ALIGN_LEFT; layout->justify = FALSE; + layout->log_attrs = NULL; layout->lines = NULL; return layout; @@ -323,15 +327,42 @@ pango_layout_set_text (PangoLayout *layout, if (layout->text) g_free (layout->text); - layout->length = length; - if (length > 0) { - layout->text = g_malloc (length); + int n_chars = unicode_strlen (text, length); + unicode_char_t junk; + char *p = text; + int i; + + /* FIXME: Do better validation */ + + for (i=0; i<n_chars; i++) + { + p = unicode_get_utf8 (p, &junk); + if (!p) + { + g_warning ("Invalid UTF8 string passed to pango_layout_set_text()"); + return; + } + } + + /* NULL-terminate the text, since we currently use unicode_next_utf8() + * in quite a few places, and for convenience. + */ + + layout->text = g_malloc (length + 1); memcpy (layout->text, text, length); + layout->text[length] = '\0'; + + layout->n_chars = n_chars; } else - layout->text = NULL; + { + layout->text = NULL; + layout->n_chars = 0; + } + + layout->length = length; pango_layout_clear_lines (layout); } @@ -352,6 +383,38 @@ pango_layout_context_changed (PangoLayout *layout) } /** + * pango_layout_get_log_attrs: + * @layout: a #PangoLayout + * @attrs: location to store a pointer to an array of logical attributes + * This value must be freed with g_free(). + * @n_attrs: location to store the number of the attributes in the + * array. (The stored value will be equal to the total number + * of characters in the layout.) + * + * Retrieve an array of logical attributes for each character in + * the layout. + **/ +void +pango_layout_get_log_attrs (PangoLayout *layout, + PangoLogAttr **attrs, + gint *n_attrs) +{ + g_return_if_fail (layout != NULL); + + pango_layout_check_lines (layout); + + if (attrs) + { + *attrs = g_new (PangoLogAttr, layout->n_chars); + memcpy (*attrs, layout->log_attrs, sizeof(PangoLogAttr) * layout->n_chars); + } + + if (n_attrs) + *n_attrs = layout->n_chars; +} + + +/** * pango_layout_get_line_count: * @layout: #PangoLayout * @@ -785,6 +848,12 @@ pango_layout_clear_lines (PangoLayout *layout) g_slist_free (layout->lines); layout->lines = NULL; + + /* This could be handled separately, since we don't need to + * recompute log_attrs on a width change, but this is easiest + */ + g_free (layout->log_attrs); + layout->log_attrs = NULL; } } @@ -808,6 +877,7 @@ static gboolean process_item (PangoLayoutLine *line, PangoItem *item, const char *text, + PangoLogAttr *log_attrs, int *remaining_width) { PangoGlyphString *glyphs = pango_glyph_string_new (); @@ -840,10 +910,8 @@ process_item (PangoLayoutLine *line, int num_chars = item->num_chars; int new_width; - PangoLogAttr *log_attrs = g_new (PangoLogAttr, item->num_chars); PangoGlyphUnit *log_widths = g_new (PangoGlyphUnit, item->num_chars); - pango_break (text + item->offset, item->length, &item->analysis, log_attrs); pango_glyph_string_get_logical_widths (glyphs, text + item->offset, item->length, item->analysis.level, log_widths); new_width = 0; @@ -856,7 +924,6 @@ process_item (PangoLayoutLine *line, break; } - g_free (log_attrs); g_free (log_widths); if (num_chars != 0) /* Succesfully broke the item */ @@ -908,32 +975,83 @@ process_item (PangoLayoutLine *line, } static void +get_para_log_attrs (const char *text, + GList *items, + PangoLogAttr *log_attrs) +{ + int offset = 0; + int index = 0; + + while (items) + { + PangoItem tmp_item = *(PangoItem *)items->data; + + /* Accumulate all the consecutive items that match in language + * characteristics, ignoring font, style tags, etc. + */ + while (items->next) + { + PangoItem *next_item = items->next->data; + + /* FIXME: Handle language tags */ + if (next_item->analysis.level != tmp_item.analysis.level || + (next_item->analysis.lang_engine != tmp_item.analysis.lang_engine && + (!next_item->analysis.lang_engine || !tmp_item.analysis.lang_engine || + strcmp (next_item->analysis.lang_engine->engine.id, + tmp_item.analysis.lang_engine->engine.id) != 0))) + break; + else + { + tmp_item.length += next_item->length; + tmp_item.num_chars += next_item->num_chars; + } + + items = items->next; + } + + pango_break (text + index, tmp_item.length, &tmp_item.analysis, log_attrs + offset); + + offset += tmp_item.num_chars; + index += tmp_item.length; + + items = items->next; + } +} + +static void pango_layout_check_lines (PangoLayout *layout) { GList *items, *tmp_list; const char *start; gboolean done = FALSE; + int para_chars, start_offset; PangoLayoutLine *line; int remaining_width; if (layout->lines) return; + + g_assert (!layout->log_attrs); + + layout->log_attrs = g_new (PangoLogAttr, layout->n_chars); + start_offset = 0; start = layout->text; do { const char *end = start; + para_chars = 0; while (end != layout->text + layout->length && *end != '\n') - end++; + { + end = unicode_next_utf8 (end); + para_chars++; + } if (end == layout->text + layout->length) done = TRUE; - line = pango_layout_line_new (layout); - remaining_width = (layout->indent >= 0) ? layout->width - layout->indent : layout->indent; - /* FIXME, should we force people to set the attrs? */ if (layout->attrs) items = pango_itemize (layout->context, start, end - start, layout->attrs); @@ -943,15 +1061,19 @@ pango_layout_check_lines (PangoLayout *layout) items = pango_itemize (layout->context, start, end - start, attrs); pango_attr_list_unref (attrs); } - + + get_para_log_attrs (start, items, layout->log_attrs + start_offset); + + line = pango_layout_line_new (layout); + remaining_width = (layout->indent >= 0) ? layout->width - layout->indent : layout->indent; + tmp_list = items; - while (tmp_list) { PangoItem *item = tmp_list->data; gboolean fits; - fits = process_item (line, item, start, &remaining_width); + fits = process_item (line, item, start, layout->log_attrs + start_offset, &remaining_width); if (fits) tmp_list = tmp_list->next; @@ -968,6 +1090,8 @@ pango_layout_check_lines (PangoLayout *layout) line = pango_layout_line_new (layout); remaining_width = (layout->indent >= 0) ? layout->width : layout->indent + layout->indent; } + + start_offset += item->num_chars; } line->runs = g_slist_reverse (line->runs); @@ -979,6 +1103,13 @@ pango_layout_check_lines (PangoLayout *layout) if (!done) { + /* Handle newline */ + layout->log_attrs[start_offset].is_break = TRUE; + layout->log_attrs[start_offset].is_white = TRUE; + layout->log_attrs[start_offset].is_char_stop = TRUE; + layout->log_attrs[start_offset].is_word_stop = TRUE; + start_offset += 1; + start = end + 1; } } diff --git a/pango/pango-layout.h b/pango/pango-layout.h index c7713aa1..c9a2f432 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -79,6 +79,10 @@ PangoAlignment pango_layout_get_alignment (PangoLayout *layout); void pango_layout_context_changed (PangoLayout *layout); +void pango_layout_get_log_attrs (PangoLayout *layout, + PangoLogAttr **attrs, + gint *n_attrs); + void pango_layout_index_to_pos (PangoLayout *layout, int index, PangoRectangle *pos); diff --git a/pango/utils.c b/pango/utils.c index 7eacff35..b9795ffb 100644 --- a/pango/utils.c +++ b/pango/utils.c @@ -123,10 +123,10 @@ _pango_utf8_to_ucs2 (const char *str, int len) gint count; - cd = iconv_open (UCS2_CHARSET, "UTF8"); + cd = iconv_open (UCS2_CHARSET, "UTF-8"); if (cd == (iconv_t)-1) - g_error ("No converter from UTF8 to " UCS2_CHARSET); + g_error ("No converter from UTF-8 to " UCS2_CHARSET); if (len < 0) len = strlen (str); |