diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 12 | ||||
-rw-r--r-- | docs/tmpl/main.sgml | 3 | ||||
-rw-r--r-- | docs/tmpl/win32-fonts.sgml | 10 | ||||
-rw-r--r-- | modules/hebrew/hebrew-x.c | 14 | ||||
-rw-r--r-- | pango/break.c | 69 | ||||
-rw-r--r-- | pango/pango-break.h | 13 | ||||
-rw-r--r-- | pango/pango-engine.h | 3 | ||||
-rw-r--r-- | pango/pango-layout.c | 5 |
14 files changed, 161 insertions, 40 deletions
@@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index 5123fde2..7fe1083b 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 5123fde2..7fe1083b 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index 5123fde2..7fe1083b 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 5123fde2..7fe1083b 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 5123fde2..7fe1083b 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 5123fde2..7fe1083b 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,15 @@ +2001-10-03 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_break) + (pango_default_break) (pango_get_log_attrs): require one more + log attr in the buffer passed in, to account for the end position + (pango_default_break): allow length of -1 + + * pango/pango-engine.h (struct _PangoEngineLang): change + script_break virtual function to match pango_break + + * pango/pango-layout.c (get_items_log_attrs): update pango_break usage + 2001-10-03 Sven Neumann <sven@gimp.org> * pango/fonts.c (pango_font_description_to_string): don't include diff --git a/docs/tmpl/main.sgml b/docs/tmpl/main.sgml index 1e0950f0..3685b6b6 100644 --- a/docs/tmpl/main.sgml +++ b/docs/tmpl/main.sgml @@ -314,6 +314,7 @@ for text. @length: @analysis: @attrs: +@attrs_len: <!-- ##### FUNCTION pango_get_log_attrs ##### --> @@ -326,6 +327,7 @@ for text. @level: @language: @log_attrs: +@attrs_len: <!-- ##### FUNCTION pango_find_paragraph_boundary ##### --> @@ -348,6 +350,7 @@ for text. @length: @analysis: @attrs: +@attrs_len: <!-- ##### STRUCT PangoLogAttr ##### --> diff --git a/docs/tmpl/win32-fonts.sgml b/docs/tmpl/win32-fonts.sgml index 2df9f614..25070e07 100644 --- a/docs/tmpl/win32-fonts.sgml +++ b/docs/tmpl/win32-fonts.sgml @@ -72,16 +72,6 @@ Win32 Fonts and Rendering @Returns: -<!-- ##### FUNCTION pango_win32_font_get_coverage ##### --> -<para> - -</para> - -@font: -@lang: -@Returns: - - <!-- ##### FUNCTION pango_win32_font_get_glyph_index ##### --> <para> diff --git a/modules/hebrew/hebrew-x.c b/modules/hebrew/hebrew-x.c index 26f16d5b..8d47df13 100644 --- a/modules/hebrew/hebrew-x.c +++ b/modules/hebrew/hebrew-x.c @@ -672,11 +672,11 @@ swap_range (PangoGlyphString *glyphs, int start, int end) } static void -hebrew_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) +hebrew_engine_shape (PangoFont *font, + const char *text, + gint length, + PangoAnalysis *analysis, + PangoGlyphString *glyphs) { HebrewFontInfo *font_info; const char *p; @@ -720,8 +720,8 @@ hebrew_engine_shape (PangoFont *font, } static PangoCoverage * -hebrew_engine_get_coverage (PangoFont *font, - const char *lang) +hebrew_engine_get_coverage (PangoFont *font, + const char *lang) { PangoCoverage *result = pango_coverage_new (); diff --git a/pango/break.c b/pango/break.c index de898895..342a94a8 100644 --- a/pango/break.c +++ b/pango/break.c @@ -364,7 +364,7 @@ typedef enum /** * pango_default_break: * @text: text to break - * @length: length of text in bytes + * @length: length of text in bytes (or -1 is allowed if text is nul-terminated) * @analysis: a #PangoAnalysis for the text * @attrs: logical attributes to fill in * @@ -381,8 +381,9 @@ void pango_default_break (const gchar *text, gint length, PangoAnalysis *analysis, - PangoLogAttr *attrs) -{ + PangoLogAttr *attrs, + int attrs_len) +{ /* The rationale for all this is in section 5.15 of the Unicode 3.0 book */ /* This is a default break implementation that should work for nearly all @@ -393,8 +394,8 @@ pango_default_break (const gchar *text, * before we start, and then never assign FALSE to anything */ - const gchar *next = text; - const gchar *end = text + length; + const gchar *next; + const gchar *end; gint i = 0; gunichar prev_wc; gunichar next_wc; @@ -413,6 +414,12 @@ pango_default_break (const gchar *text, g_return_if_fail (text != NULL); g_return_if_fail (attrs != NULL); + + if (length < 0) + length = strlen (text); + + next = text; + end = text + length; if (next == end) return; @@ -433,12 +440,27 @@ pango_default_break (const gchar *text, GUnicodeBreakType break_type; BreakOpportunity break_op; + if (i >= attrs_len) + { + g_warning ("pango_default_break(): the array of PangoLogAttr passed in must have at least N+1 elements, if there are N characters in the text being broken"); + return; + } + wc = next_wc; next = g_utf8_next_char (next); - if (next >= end) - next_wc = 0; + if (next == end) + { + /* This is how we fill in the last element (end position) of the + * attr array - assume there's a newline off the end of @text. + */ + next_wc = '\n'; + } + else if (next > end) + { + next_wc = 0; + } else { next_wc = g_utf8_get_char (next); @@ -1259,7 +1281,8 @@ void pango_break (const gchar *text, gint length, PangoAnalysis *analysis, - PangoLogAttr *attrs) + PangoLogAttr *attrs, + int attrs_len) { g_return_if_fail (text != NULL); g_return_if_fail (analysis != NULL); @@ -1270,9 +1293,9 @@ pango_break (const gchar *text, if (analysis->lang_engine && analysis->lang_engine->script_break) - (* analysis->lang_engine->script_break) (text, length, analysis, attrs); + (* analysis->lang_engine->script_break) (text, length, analysis, attrs, attrs_len); else - pango_default_break (text, length, analysis, attrs); + pango_default_break (text, length, analysis, attrs, attrs_len); } /** @@ -1377,16 +1400,24 @@ pango_find_paragraph_boundary (const gchar *text, * @length: length in bytes of @text * @level: embedding level, or -1 if unknown * @language: language tag - * @log_attrs: array with one PangoLogAttr per character in @text, to be filled in + * @log_attrs: array with one #PangoLogAttr per character in @text, plus one extra, to be filled in + * @attrs_len: length of @log_attrs array * - * Computes a PangoLogAttr for each character in @text + * Computes a PangoLogAttr for each character in @text. The @log_attrs + * array must have one #PangoLogAttr for each position in @text; if + * @text contains N characters, it has N+1 positions, including the + * last position at the end of the text. @text should be an entire + * paragraph; logical attributes can't be computed without context + * (for example you need to see spaces on either side of a word to know the + * word is a word). */ void pango_get_log_attrs (const char *text, int length, int level, PangoLanguage *language, - PangoLogAttr *log_attrs) + PangoLogAttr *log_attrs, + int attrs_len) { int n_chars; PangoMap *lang_map; @@ -1419,6 +1450,12 @@ pango_get_log_attrs (const char *text, n_chars = g_utf8_strlen (text, length); + if (attrs_len < (n_chars + 1)) + { + g_warning ("pango_get_log_attrs(): length of PangoLogAttr array must be at least the number of chars in the text plus one more for the end position"); + return; + } + lang_map = pango_find_map (language, engine_type_id, render_type_id); range_start = text; @@ -1449,7 +1486,8 @@ pango_get_log_attrs (const char *text, pango_break (range_start, pos - range_start, &analysis, - log_attrs + chars_broken); + log_attrs + chars_broken, + attrs_len - chars_broken); chars_broken += chars_in_range; @@ -1473,6 +1511,7 @@ pango_get_log_attrs (const char *text, pango_break (range_start, end - range_start, &analysis, - log_attrs + chars_broken); + log_attrs + chars_broken, + attrs_len - chars_broken); } diff --git a/pango/pango-break.h b/pango/pango-break.h index b8b692f6..3662009b 100644 --- a/pango/pango-break.h +++ b/pango/pango-break.h @@ -70,9 +70,10 @@ struct _PangoLogAttr * of Unicode text. */ void pango_break (const gchar *text, - gint length, + int length, PangoAnalysis *analysis, - PangoLogAttr *attrs); + PangoLogAttr *attrs, + int attrs_len); void pango_find_paragraph_boundary (const gchar *text, gint length, @@ -83,7 +84,8 @@ void pango_get_log_attrs (const char *text, int length, int level, PangoLanguage *language, - PangoLogAttr *log_attrs); + PangoLogAttr *log_attrs, + int attrs_len); #ifdef PANGO_ENABLE_ENGINE @@ -93,9 +95,10 @@ void pango_get_log_attrs (const char *text, * from a language engine override. */ void pango_default_break (const gchar *text, - gint length, + int length, PangoAnalysis *analysis, - PangoLogAttr *attrs); + PangoLogAttr *attrs, + int attrs_len); #endif /* PANGO_ENABLE_ENGINE */ diff --git a/pango/pango-engine.h b/pango/pango-engine.h index d19367ee..1c33b9df 100644 --- a/pango/pango-engine.h +++ b/pango/pango-engine.h @@ -71,7 +71,8 @@ struct _PangoEngineLang void (*script_break) (const char *text, int len, PangoAnalysis *analysis, - PangoLogAttr *attrs); + PangoLogAttr *attrs, + int attrs_len); }; struct _PangoEngineShape diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 22df08be..97b594d7 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -2723,7 +2723,8 @@ get_items_log_attrs (const char *text, if (items->next == NULL) tmp_item.length += para_delimiter_len; - pango_break (text + index, tmp_item.length, &tmp_item.analysis, log_attrs + offset); + pango_break (text + index, tmp_item.length, &tmp_item.analysis, + log_attrs + offset, tmp_item.num_chars + 1); offset += tmp_item.num_chars; index += tmp_item.length; @@ -2786,7 +2787,7 @@ pango_layout_check_lines (PangoLayout *layout) attrs = pango_layout_get_effective_attributes (layout); iter = pango_attr_list_get_iterator (attrs); - layout->log_attrs = g_new (PangoLogAttr, layout->n_chars); + layout->log_attrs = g_new (PangoLogAttr, layout->n_chars + 1); start_offset = 0; start = layout->text; |