summaryrefslogtreecommitdiff
path: root/pango/pango-attributes.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-08-29 00:10:03 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-08-31 14:29:56 -0400
commit303b4fb73eb8848d18abbda4d151461bd86f1000 (patch)
tree44024e2ec8933eef1a7a3d62ffc2d35264104634 /pango/pango-attributes.c
parente382a65301847bb432c1bf3f9774ef48e1ec4734 (diff)
downloadpango-303b4fb73eb8848d18abbda4d151461bd86f1000.tar.gz
Implement baseline shifts
Add a new baseline-shift attribute, which is similar to rise, but accumulates. In addition, it supports font- relative values such as superscript and subscript. We implement support for this by computing baseline shifts for run during line post-processing, and storing them in the runs. The renderer now takes these shifts into account when rendering layout lines.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r--pango/pango-attributes.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 326234d2..8507c963 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -924,6 +924,30 @@ pango_attr_rise_new (int rise)
}
/**
+ * pango_attr_baseline_shift_new:
+ * @shift: either a `PangoBaselineShift` enumeration value or an absolute value (> 1024)
+ * in Pango units, relative to the baseline of the previous run.
+ * Positive values displace the text upwards.
+ *
+ * Create a new baseline displacement attribute.
+ *
+ * Return value: (transfer full): the newly allocated
+ * `PangoAttribute`, which should be freed with
+ * [method@Pango.Attribute.destroy]
+ */
+PangoAttribute *
+pango_attr_baseline_shift_new (int rise)
+{
+ static const PangoAttrClass klass = {
+ PANGO_ATTR_BASELINE_SHIFT,
+ pango_attr_int_copy,
+ pango_attr_int_destroy,
+ pango_attr_int_equal
+ };
+
+ return pango_attr_int_new (&klass, (int)rise);
+}
+/**
* pango_attr_scale_new:
* @scale_factor: factor to scale the font
*
@@ -1533,6 +1557,7 @@ pango_attribute_as_int (PangoAttribute *attr)
case PANGO_ATTR_TEXT_TRANSFORM:
case PANGO_ATTR_WORD:
case PANGO_ATTR_SENTENCE:
+ case PANGO_ATTR_BASELINE_SHIFT:
return (PangoAttrInt *)attr;
default: