diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-08-07 10:37:07 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-08-08 21:35:55 -0400 |
commit | 623134f48ad998e1392839f7346c780228ddac45 (patch) | |
tree | 606d44e9f51b5a692b69e183999253e96080f06c /pango/pango-attributes.c | |
parent | ed13e662d1a327671fc9f1a3ec7d71c4bbfe1280 (diff) | |
download | pango-623134f48ad998e1392839f7346c780228ddac45.tar.gz |
Add line-height attributes
Add attributes for line-height, in a relative and
absolute variant.
This will be used to grow the logical extents of
runs in a way that is compatible with CSS semantics.
In markup, we support a new line_height attribute
that will be interpreted as absolute if it is an
integer > 1024, and as a relative factor otherwise.
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: |