diff options
author | Havoc Pennington <hp@pobox.com> | 2000-11-01 06:46:29 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2000-11-01 06:46:29 +0000 |
commit | b00a32cc4f7b8783d673f31502b4ef3555486995 (patch) | |
tree | 2a035c680e76bdfa121585577de26a4796e46345 /pango/pango-attributes.c | |
parent | 717a0b958c4616753798250985558cab328a6837 (diff) | |
download | pango-b00a32cc4f7b8783d673f31502b4ef3555486995.tar.gz |
Add a new attribute for scaling a font; also required adding
2000-11-01 Havoc Pennington <hp@pobox.com>
* pango/pango-attributes.c (pango_attr_scale_new): Add a new
attribute for scaling a font; also required adding PangoAttrFloat.
(pango_attr_iterator_get_font): Add PANGO_ATTR_SCALE handling.
* pango/pango-utils.c (pango_parse_stretch): Take a plain string
not a GString
(pango_parse_weight): ditto
(pango_parse_variant): ditto
(pango_parse_style): ditto
* pango/pangox-fontmap.c (pango_x_font_map_read_alias_file): pass
GString::str instead of the GString itself to pango_parse_*
* pango/pangoft2-fontmap.c (pango_ft2_insert_face): ditto
* pango/pangowin32-fontmap.c
(pango_win32_font_map_read_alias_file): ditto
* pango/pango-layout.c (get_tab_pos): adapt to new pango_itemize()
signature
(pango_layout_check_lines): Raise attr list copy/creation out of
the loop over paragraphs. Adapt to pango_itemize() changes.
* pango/pango-context.c (pango_itemize): pass in a starting
index and a cached iterator
(add_engines): Easy optimization, pass in
n_chars instead of recomputing it. Also, pass on the start
index and cached iterator.
* docs/pango-sections.txt: Add new stuff
docs/pango_markup.sgml: Docs on markup format
* pango/pango-layout.c (pango_layout_get_attributes): New function
to retrieve the AttrList from a layout
(pango_layout_set_markup): Set layout from markup
(pango_layout_set_markup_with_accel): Set layout from markup
including accelerator parsing.
* pango/pango-attributes.h (pango_parse_markup): New function to
convert a tag string to an attribute list
* pango/pango-markup.c (pango_parse_markup): implement
* docs/Makefile.am, docs/pango-docs.sgml, docs/pango-sections.txt,
docs/pango_markup.sgml: oooooh, documentation for the above patch!
* docs/tmpl/pango-unused.sgml: Remove from CVS; just causes
problems, and was full of checked-in conflict markers.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r-- | pango/pango-attributes.c | 93 |
1 files changed, 82 insertions, 11 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 9a640239..f241ff09 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -39,13 +39,16 @@ struct _PangoAttrIterator }; static PangoAttribute *pango_attr_color_new (const PangoAttrClass *klass, - guint16 red, - guint16 green, - guint16 blue); + guint16 red, + guint16 green, + guint16 blue); static PangoAttribute *pango_attr_string_new (const PangoAttrClass *klass, - const char *str); + const char *str); static PangoAttribute *pango_attr_int_new (const PangoAttrClass *klass, - int value); + int value); +static PangoAttribute *pango_attr_float_new (const PangoAttrClass *klass, + double value); + /** * pango_attr_type_register: @@ -328,6 +331,41 @@ pango_attr_int_new (const PangoAttrClass *klass, return (PangoAttribute *)result; } +static PangoAttribute * +pango_attr_float_copy (const PangoAttribute *attr) +{ + const PangoAttrFloat *float_attr = (PangoAttrFloat *)attr; + + return pango_attr_float_new (attr->klass, float_attr->value); +} + +static void +pango_attr_float_destroy (PangoAttribute *attr) +{ + g_free (attr); +} + +static gboolean +pango_attr_float_compare (const PangoAttribute *attr1, + const PangoAttribute *attr2) +{ + const PangoAttrFloat *float_attr1 = (const PangoAttrFloat *)attr1; + const PangoAttrFloat *float_attr2 = (const PangoAttrFloat *)attr2; + + return (float_attr1->value == float_attr2->value); +} + +static PangoAttribute* +pango_attr_float_new (const PangoAttrClass *klass, + double value) +{ + PangoAttrFloat *result = g_new (PangoAttrFloat, 1); + result->attr.klass = klass; + result->value = value; + + return (PangoAttribute *)result; +} + /** * pango_attr_size_new: * @size: the font size, in 1000ths of a point. @@ -554,6 +592,28 @@ pango_attr_rise_new (int rise) return pango_attr_int_new (&klass, (int)rise); } +/** + * pango_attr_scale_new: + * @scale_factor: factor to scale the font + * + * Create a new font size scale attribute. The base font for the + * affected text will have its size multiplied by @scale_factor. + * + * Return value: the new #PangoAttribute. + **/ +PangoAttribute* +pango_attr_scale_new (double scale_factor) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_SCALE, + pango_attr_float_copy, + pango_attr_float_destroy, + pango_attr_float_compare + }; + + return pango_attr_float_new (&klass, scale_factor); +} + static PangoAttribute * pango_attr_shape_copy (const PangoAttribute *attr) { @@ -636,7 +696,7 @@ pango_attr_list_new (void) list->ref_count = 1; list->attributes = NULL; list->attributes_tail = NULL; - + return list; } @@ -731,7 +791,7 @@ pango_attr_list_insert_internal (PangoAttrList *list, { GSList *tmp_list, *prev, *link; gint start_index = attr->start_index; - + if (!list->attributes) { list->attributes = g_slist_prepend (NULL, attr); @@ -839,7 +899,7 @@ pango_attr_list_change (PangoAttrList *list, gint end_index = attr->end_index; g_return_if_fail (list != NULL); - + tmp_list = list->attributes; prev = NULL; while (1) @@ -1289,7 +1349,9 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, gboolean have_size = FALSE; g_return_if_fail (iterator != NULL); - + g_return_if_fail (base != NULL); + g_return_if_fail (current != NULL); + *current = *base; if (extra_attrs) @@ -1335,8 +1397,9 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, have_size = TRUE; current->size = ((PangoAttrFontDesc *)attr)->desc.size; } - } - + } + break; + case PANGO_ATTR_FAMILY: if (!have_family) { @@ -1379,6 +1442,14 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, current->size = ((PangoAttrInt *)attr)->value; } break; + case PANGO_ATTR_SCALE: + if (!have_size) + { + have_size = TRUE; + current->size = ((PangoAttrFloat *)attr)->value * base->size; + } + break; + default: if (extra_attrs) { |