diff options
author | Havoc Pennington <hp@redhat.com> | 2001-01-23 21:41:26 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-01-23 21:41:26 +0000 |
commit | 672500d6a122f7b546d6fb795fe0e5cd03d9f244 (patch) | |
tree | b13abb41b4a195aeb1e955603ca883785a6094af /pango | |
parent | b2e1bc0147a5a91fd477ab23ab8a64be0bb94be4 (diff) | |
download | pango-672500d6a122f7b546d6fb795fe0e5cd03d9f244.tar.gz |
New function
2001-01-23 Havoc Pennington <hp@redhat.com>
* pango/pango-layout.c (pango_layout_copy): New function
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-layout.c | 53 | ||||
-rw-r--r-- | pango/pango-layout.h | 1 |
2 files changed, 53 insertions, 1 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 068077cb..30abc2fe 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -99,6 +99,10 @@ struct _PangoLayout { GObject parent_instance; + /* If you add fields to PangoLayout, be sure to update both + * the _copy function + */ + PangoContext *context; PangoAttrList *attrs; PangoFontDescription *font_desc; @@ -266,6 +270,50 @@ pango_layout_new (PangoContext *context) } /** + * pango_layout_copy: + * @src: a #PangoLayout + * + * Does a deep copy-by-value of the @src layout. The attribute list, + * tab array, and text from the original layout are all copied by + * value. + * + * Return value: a new #PangoLayout identical to @src + **/ +PangoLayout* +pango_layout_copy (PangoLayout *src) +{ + PangoLayout *layout; + + g_return_val_if_fail (PANGO_IS_LAYOUT (src), NULL); + + layout = pango_layout_new (src->context); + + if (src->attrs) + layout->attrs = pango_attr_list_copy (src->attrs); + + if (src->font_desc) + layout->font_desc = pango_font_description_copy (src->font_desc); + + layout->text = g_strdup (src->text); + layout->length = src->length; + layout->width = src->width; + layout->indent = src->indent; + layout->spacing = src->spacing; + layout->justify = src->justify; + layout->alignment = src->alignment; + layout->n_chars = src->n_chars; + layout->tab_width = src->tab_width; + + if (src->tabs) + layout->tabs = pango_tab_array_copy (src->tabs); + layout->wrap = src->wrap; + + /* log_attrs, lines fields are updated by check_lines */ + + return layout; +} + +/** * pango_layout_get_context: * @layout: a #PangoLayout * @@ -3675,7 +3723,10 @@ pango_layout_iter_get_index (PangoLayoutIter *iter) * pango_layout_iter_get_run: * @iter: a #PangoLayoutIter * - * Gets the current run. + * Gets the current run. When iterating by run, at the end of each + * line, there's a position with a %NULL run, so this function can return + * %NULL. The %NULL run at the end of each line ensures that all lines have + * at least one run, even lines consisting of only a newline. * * Return value: the current run **/ diff --git a/pango/pango-layout.h b/pango/pango-layout.h index 6cef7cf4..b20e95a2 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -75,6 +75,7 @@ struct _PangoLayoutRun GType pango_layout_get_type (void) G_GNUC_CONST; PangoLayout *pango_layout_new (PangoContext *context); +PangoLayout *pango_layout_copy (PangoLayout *src); PangoContext *pango_layout_get_context (PangoLayout *layout); |