diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-08-09 03:04:21 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-08-09 03:04:21 +0000 |
commit | c4d138179443b49d817830c78ddcd1459cf5505f (patch) | |
tree | 105703add2c026aeff6d297d244bc6d9e2c579d7 /pango/pango-attributes.c | |
parent | f437641bcc412d7e7ac2f706487bbbdeaeddc87e (diff) | |
parent | 336dca6530d9dc41b101018d7f4af4a27e70445d (diff) | |
download | pango-c4d138179443b49d817830c78ddcd1459cf5505f.tar.gz |
Merge branch 'line-height-attribute' into 'main'
Implement css-like line-height
See merge request GNOME/pango!390
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r-- | pango/pango-attributes.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 1a4a9443..fdb37f56 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -1341,6 +1341,58 @@ pango_attr_overline_color_new (guint16 red, return pango_attr_color_new (&klass, red, green, blue); } +/** + * pango_attr_line_height_new: + * @factor: the scaling factor to apply to the logical height + * + * Modify the height of logical line extents by a factor. + * + * This affects the values returned by + * [method@Pango.LayoutLine.get_extents], + * [method@Pango.LayoutLine.get_pixel_extents] and + * [method@Pango.LayoutIter.get_line_extents]. + * + * + * Since: 1.50 + */ +PangoAttribute * +pango_attr_line_height_new (double factor) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_LINE_HEIGHT, + pango_attr_float_copy, + pango_attr_float_destroy, + pango_attr_float_equal + }; + + return pango_attr_float_new (&klass, factor); +} + +/** + * pango_attr_line_height_new_absolute: + * @height: the line height, in %PANGO_SCALE-ths of a point + * + * Override the height of logical line extents to be @height. + * + * This affects the values returned by + * [method@Pango.LayoutLine.get_extents], + * [method@Pango.LayoutLine.get_pixel_extents] and + * [method@Pango.LayoutIter.get_line_extents]. + * + * Since: 1.50 + */ +PangoAttribute * +pango_attr_line_height_new_absolute (int height) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_ABSOLUTE_LINE_HEIGHT, + pango_attr_int_copy, + pango_attr_int_destroy, + pango_attr_int_equal + }; + + return pango_attr_int_new (&klass, height); +} /* * Attribute List */ @@ -2559,6 +2611,7 @@ pango_attribute_as_float (PangoAttribute *attr) switch (attr->klass->type) { case PANGO_ATTR_SCALE: + case PANGO_ATTR_LINE_HEIGHT: return (PangoAttrFloat *)attr; default: |