diff options
author | Havoc Pennington <hp@redhat.com> | 2000-07-06 23:32:42 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-07-06 23:32:42 +0000 |
commit | 420062f86db398b4df038f42e01e3db5cd656a7d (patch) | |
tree | 73369cfff3ffafa006e2909e07c8ad48e0f8bca5 | |
parent | 3d95e7ed152e045e311f855a8028746fc9ab38be (diff) | |
download | pango-420062f86db398b4df038f42e01e3db5cd656a7d.tar.gz |
Implement this function, to get logical attributes without a
2000-07-06 Havoc Pennington <hp@redhat.com>
* pango/break.c (pango_get_log_attrs): Implement this function, to
get logical attributes without a PangoAnalysis.
(pango_break): Fix bug in word stop location
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 6 | ||||
-rw-r--r-- | pango/break.c | 100 | ||||
-rw-r--r-- | pango/pango.h | 6 |
9 files changed, 147 insertions, 1 deletions
@@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index 1972554e..653f08ae 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 1972554e..653f08ae 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index 1972554e..653f08ae 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 1972554e..653f08ae 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 1972554e..653f08ae 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 1972554e..653f08ae 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,9 @@ +2000-07-06 Havoc Pennington <hp@redhat.com> + + * pango/break.c (pango_get_log_attrs): Implement this function, to + get logical attributes without a PangoAnalysis. + (pango_break): Fix bug in word stop location + Thu Jul 6 15:24:38 2000 Owen Taylor <otaylor@redhat.com> * Released 0.12 diff --git a/pango/break.c b/pango/break.c index 93ffecf2..0f9d3dfe 100644 --- a/pango/break.c +++ b/pango/break.c @@ -20,6 +20,7 @@ */ #include "pango.h" +#include "pango-modules.h" /** * pango_break: @@ -51,9 +52,106 @@ void pango_break (const gchar *text, attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == '\n' || wc == 0x200b) ? 1 : 0; attrs[i].is_break = i == 0 || attrs[i-1].is_white || attrs[i].is_white; attrs[i].is_char_stop = 1; - attrs[i].is_word_stop = (i == 0) || attrs[i-1].is_white; + attrs[i].is_word_stop = ((i == 0) || attrs[i-1].is_white) && !attrs[i].is_white; i++; cur = g_utf8_next_char (cur); } } + +/** + * pango_get_log_attrs: + * @text: text to process + * @length: length in bytes of @text + * @level: embedding level, or -1 if unknown + * @language: language code + * @log_attrs: array with one PangoLogAttr per character in @text, to be filled in + * + * Computes a PangoLogAttr for each character in @text + */ +void +pango_get_log_attrs (const char *text, + int length, + int level, + const char *language, + PangoLogAttr *log_attrs) +{ + int n_chars; + PangoMap *lang_map; + int chars_broken; + const char *pos; + const char *end; + PangoEngineLang* range_engine; + const char *range_start; + int chars_in_range; + static guint engine_type_id = 0; + static guint render_type_id = 0; + PangoAnalysis analysis = { NULL, NULL, NULL, (guint8)level }; + + g_return_if_fail (length == 0 || text != NULL); + g_return_if_fail (log_attrs != NULL); + + if (length == 0) + return; + + if (engine_type_id == 0) + { + engine_type_id = g_quark_from_static_string (PANGO_ENGINE_TYPE_LANG); + render_type_id = g_quark_from_static_string (PANGO_RENDER_TYPE_NONE); + } + + n_chars = g_utf8_strlen (text, length); + + lang_map = pango_find_map (language, engine_type_id, render_type_id); + + range_start = text; + range_engine = (PangoEngineLang*) pango_map_get_engine (lang_map, + g_utf8_get_char (text)); + analysis.lang_engine = range_engine; + chars_broken = 0; + chars_in_range = 1; + + end = text + length; + pos = g_utf8_next_char (text); + + while (pos != end) + { + analysis.lang_engine = + (PangoEngineLang*) pango_map_get_engine (lang_map, + g_utf8_get_char (pos)); + + if (range_engine != analysis.lang_engine) + { + /* Engine has changed; do the breaking for the current range, + * then start a new range. + */ + pango_break (range_start, + pos - range_start, + &analysis, + log_attrs + chars_broken); + + chars_broken += chars_in_range; + + range_start = pos; + range_engine = analysis.lang_engine; + chars_in_range = 1; + } + else + { + chars_in_range += 1; + } + + pos = g_utf8_next_char (pos); + } + + g_assert (chars_in_range > 0); + g_assert (range_start != end); + g_assert (pos == end); + g_assert (range_engine == analysis.lang_engine); + + pango_break (range_start, + end - range_start, + &analysis, + log_attrs + chars_broken); +} + diff --git a/pango/pango.h b/pango/pango.h index 5d083b9f..e0652fd0 100644 --- a/pango/pango.h +++ b/pango/pango.h @@ -57,6 +57,12 @@ void pango_break (const gchar *text, PangoAnalysis *analysis, PangoLogAttr *attrs); +void pango_get_log_attrs (const char *text, + int length, + int level, + const char *language, + PangoLogAttr *log_attrs); + /* Turn a string of characters into a string of glyphs */ void pango_shape (const gchar *text, |