summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-04-18 20:04:31 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-04-18 20:04:31 +0000
commit799b1cfe73d7fc5676f584715b6ac6efefc6a9eb (patch)
tree48373dee44a24064ddf16c887fc860e044186d51 /pango/pango-attributes.c
parent4121f3559f75d07a04af44874264701fbd29b493 (diff)
downloadpango-799b1cfe73d7fc5676f584715b6ac6efefc6a9eb.tar.gz
Add a function pango_layout_line_get_x_ranges(), to allow handling
Mon Apr 17 12:04:20 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.[ch]: Add a function pango_layout_line_get_x_ranges(), to allow handling selections not as attributes. Which is necessary, since currently setting the background/foreground results in splitting shaped runs. Fri Apr 14 13:20:05 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.c (pango_layout_check_lines): Fix bug with indent handling. * pango/pango-layout.c (process_item): Never break a line at a non-break position, even if that position ends an item. Fri Apr 14 10:43:09 2000 Owen Taylor <otaylor@redhat.com> * pango/pangox.c (pango_x_render_layout_line): Fix a missing PANGO_SCALE factor for UNDERLINE_SINGLE. * pango/pango-layout.c (pango_layout_get_cursor_pos): New function to determine cursor positions corresponding to a particular index. Wed Apr 12 15:44:22 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-attributes.[ch]: Add PANGO_ATTR_FONT_DESC, which allows an entire font description to be specified as a single attribute, instead of as 6 separate attributes.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c94
1 files changed, 90 insertions, 4 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index f7618906..905c71c8 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -425,6 +425,62 @@ pango_attr_stretch_new (PangoStretch stretch)
return pango_attr_int_new (&klass, (int)stretch);
}
+static PangoAttribute *
+pango_attr_font_desc_copy (const PangoAttribute *attr)
+{
+ const PangoAttrFontDesc *desc_attr = (const PangoAttrFontDesc *)attr;
+
+ return pango_attr_font_desc_new (&desc_attr->desc);
+}
+
+static void
+pango_attr_font_desc_destroy (PangoAttribute *attr)
+{
+ PangoAttrFontDesc *desc_attr = (PangoAttrFontDesc *)attr;
+
+ g_free (desc_attr->desc.family_name);
+ g_free (attr);
+}
+
+static gboolean
+pango_attr_font_desc_compare (const PangoAttribute *attr1,
+ const PangoAttribute *attr2)
+{
+ const PangoAttrFontDesc *desc_attr1 = (const PangoAttrFontDesc *)attr1;
+ const PangoAttrFontDesc *desc_attr2 = (const PangoAttrFontDesc *)attr2;
+
+ return pango_font_description_compare (&desc_attr1->desc, &desc_attr2->desc);
+}
+
+/**
+ * pango_attr_font_desc_new:
+ * @desc:
+ *
+ * Create a new font description attribute. (This attribute
+ * allows setting family, style, weight, variant, stretch,
+ * and size simultaneously.)
+ *
+ * Return value:
+ **/
+PangoAttribute *
+pango_attr_font_desc_new (const PangoFontDescription *desc)
+{
+ static const PangoAttrClass klass = {
+ PANGO_ATTR_FONT_DESC,
+ pango_attr_font_desc_copy,
+ pango_attr_font_desc_destroy,
+ pango_attr_font_desc_compare
+ };
+
+ PangoAttrFontDesc *result = g_new (PangoAttrFontDesc, 1);
+ result->attr.klass = &klass;
+ result->desc = *desc;
+ result->desc.family_name = g_strdup (desc->family_name);
+
+ return (PangoAttribute *)result;
+}
+
+
/**
* pango_attr_underline_new:
* @underline: the underline style.
@@ -923,6 +979,40 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator,
switch (attr->klass->type)
{
+ case PANGO_ATTR_FONT_DESC:
+ {
+ if (!have_family)
+ {
+ have_family = TRUE;
+ current->family_name = ((PangoAttrFontDesc *)attr)->desc.family_name;
+ }
+ if (!have_style)
+ {
+ have_style = TRUE;
+ current->style = ((PangoAttrFontDesc *)attr)->desc.style;
+ }
+ if (!have_variant)
+ {
+ have_variant = TRUE;
+ current->variant = ((PangoAttrFontDesc *)attr)->desc.variant;
+ }
+ if (!have_weight)
+ {
+ have_weight = TRUE;
+ current->weight = ((PangoAttrFontDesc *)attr)->desc.weight;
+ }
+ if (!have_stretch)
+ {
+ have_stretch = TRUE;
+ current->stretch = ((PangoAttrFontDesc *)attr)->desc.stretch;
+ }
+ if (!have_size)
+ {
+ have_size = TRUE;
+ current->size = ((PangoAttrFontDesc *)attr)->desc.size;
+ }
+ }
+
case PANGO_ATTR_FAMILY:
if (!have_family)
{
@@ -989,7 +1079,3 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator,
}
}
}
-
-
-
-