diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-04-05 00:31:59 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-04-05 00:31:59 +0000 |
commit | 613302136667231bcefd772b419369516eb3bf45 (patch) | |
tree | 919ed907f3ca69f79210d0778c65df8bec97d4d0 /pango/pango-context.c | |
parent | 52f2e805bf993f711d09ba6fe4972c7f7ee33eae (diff) | |
download | pango-613302136667231bcefd772b419369516eb3bf45.tar.gz |
Add user data to PangoContext
Tue Apr 4 20:13:06 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-context.h: Add user data to PangoContext
* pango/pangox.[ch] examples/viewer.c: Rework system for create GC's
so that the necessary information is stored on the PangoContext
instead of being passed to layout_render()
* pango/utils.[ch] pango/pango-context.c: fribidi-0.1.9
wants UCS-4 not UCS2; switch accordingly.
* pango/fonts.c pango/pango-font.h pango/pangox.c: Add functions
to get overall font metrics, possibly per-language. (Right now,
just font ascent, descent.) The implementation of this for
X is horribly complex.
Diffstat (limited to 'pango/pango-context.c')
-rw-r--r-- | pango/pango-context.c | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c index 95c5bab2..c768c7d5 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -35,6 +35,7 @@ struct _PangoContext PangoFontDescription *font_desc; GSList *font_maps; + GData *data; }; static void add_engines (PangoContext *context, @@ -63,6 +64,7 @@ pango_context_new (void) result->base_dir = PANGO_DIRECTION_LTR; result->lang = NULL; result->font_maps = NULL; + result->data = NULL; desc.family_name = "serif"; desc.style = PANGO_STYLE_NORMAL; @@ -454,6 +456,44 @@ pango_context_get_base_dir (PangoContext *context) } /** + * pango_context_set_data: + * @context: a #PangoContext + * @key: the string key that identifies the data + * @data: the data to store + * @destroy_func: the function to free @data when it is no longer needed (may be %NULL) + * + * Adds user data to a #PangoContext. + **/ +void +pango_context_set_data (PangoContext *context, + const char *key, + gpointer data, + GDestroyNotify destroy_func) +{ + g_return_if_fail (context != NULL); + + g_datalist_set_data_full (&context->data, key, data, destroy_func); +} + +/** + * pango_context_get_data: + * @context: a #PangoContext + * @key: the string key that identifies the data + * + * Retrieves user data from a #PangoContext + * + * Return value: the data, if @key was found, or %NULL. + **/ +gpointer +pango_context_get_data (PangoContext *context, + const char *key) +{ + g_return_val_if_fail (context != NULL, NULL); + + return g_datalist_get_data (&context->data, key); +} + +/** * pango_itemize: * @context: a structure holding information that affects the itemization process. @@ -474,10 +514,9 @@ pango_itemize (PangoContext *context, PangoAttrList *attrs) { GUChar4 *text_ucs4; - gint n_chars; + int n_chars, i; guint8 *embedding_levels; FriBidiCharType base_dir; - gint i; PangoItem *item; const char *p; const char *next; @@ -502,7 +541,7 @@ pango_itemize (PangoContext *context, if (length == 0) return NULL; - + /* First, apply the bidirectional algorithm to break * the text into directional runs. */ @@ -513,6 +552,9 @@ pango_itemize (PangoContext *context, n_chars = unicode_strlen (text, length); embedding_levels = g_new (guint8, n_chars); + fribidi_log2vis_get_embedding_levels (text_ucs4, n_chars, &base_dir, + embedding_levels); + /* Storing these as ranges would be a lot more efficient, * but also more complicated... we take the simple * approach for now. @@ -522,9 +564,6 @@ pango_itemize (PangoContext *context, fonts = g_new0 (PangoFont *, n_chars); extra_attr_lists = g_new0 (GSList *, n_chars); - fribidi_log2vis_get_embedding_levels (text_ucs4, n_chars, &base_dir, - embedding_levels); - /* Now, fill in the appropriate shapers, language engines and fonts for * each character. */ |