[pango/baseline-shift: 14/17] markup: Change <sup> and <sub>
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/baseline-shift: 14/17] markup: Change <sup> and <sub>
- Date: Tue, 31 Aug 2021 18:30:16 +0000 (UTC)
commit 1b73eedc69bc15941f216bff11817b825adb51d8
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Aug 29 16:37:02 2021 -0400
markup: Change <sup> and <sub>
Use the new baseline-shift and font-scale attributes
to reimplement <sup> and <sub>.
Now they take font metrics into account and nest
properly.
pango/pango-markup.c | 22 ++++------------------
tests/markups/valid-4.expected | 8 ++++----
2 files changed, 8 insertions(+), 22 deletions(-)
---
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 54c08c67..791e71fd 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -1833,8 +1833,6 @@ s_parse_func (MarkupData *md G_GNUC_UNUSED,
return TRUE;
}
-#define SUPERSUB_RISE 5000
-
static gboolean
sub_parse_func (MarkupData *md G_GNUC_UNUSED,
OpenTag *tag,
@@ -1845,14 +1843,8 @@ sub_parse_func (MarkupData *md G_GNUC_UNUSED,
{
CHECK_NO_ATTRS("sub");
- /* Shrink font, and set a negative rise */
- if (tag)
- {
- tag->scale_level_delta -= 1;
- tag->scale_level -= 1;
- }
-
- add_attribute (tag, pango_attr_rise_new (-SUPERSUB_RISE));
+ add_attribute (tag, pango_attr_font_scale_new (PANGO_FONT_SCALE_SUBSCRIPT));
+ add_attribute (tag, pango_attr_baseline_shift_new (PANGO_BASELINE_SHIFT_SUBSCRIPT));
return TRUE;
}
@@ -1867,14 +1859,8 @@ sup_parse_func (MarkupData *md G_GNUC_UNUSED,
{
CHECK_NO_ATTRS("sup");
- /* Shrink font, and set a positive rise */
- if (tag)
- {
- tag->scale_level_delta -= 1;
- tag->scale_level -= 1;
- }
-
- add_attribute (tag, pango_attr_rise_new (SUPERSUB_RISE));
+ add_attribute (tag, pango_attr_font_scale_new (PANGO_FONT_SCALE_SUPERSCRIPT));
+ add_attribute (tag, pango_attr_baseline_shift_new (PANGO_BASELINE_SHIFT_SUPERSCRIPT));
return TRUE;
}
diff --git a/tests/markups/valid-4.expected b/tests/markups/valid-4.expected
index 0391ec8e..a9e16728 100644
--- a/tests/markups/valid-4.expected
+++ b/tests/markups/valid-4.expected
@@ -18,8 +18,8 @@ range 16 29
[16,41]strikethrough=1
range 29 32
[16,41]strikethrough=1
-[29,32]scale=0.833333
-[29,32]rise=-5000
+[29,32]font-scale=2
+[29,32]baseline-shift=2
range 32 33
[16,41]strikethrough=1
range 33 38
@@ -27,8 +27,8 @@ range 33 38
[33,38]scale=0.833333
range 38 41
[16,41]strikethrough=1
-[38,41]scale=0.833333
-[38,41]rise=5000
+[38,41]font-scale=1
+[38,41]baseline-shift=1
range 41 42
range 42 45
[42,54]family=Monospace
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]