[pango/markup-sizes: 2/3] markup: Allow pt for rise too




commit 9d68eaf2d7366bc448f722d7638714fba9c34460
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 8 10:26:38 2021 -0400

    markup: Allow pt for rise too

 docs/pango_markup.md            |  5 +++--
 pango/pango-markup.c            | 13 +++++++++++--
 tests/markups/fail-11.expected  |  2 +-
 tests/markups/valid-21.expected | 14 ++++++++++++++
 tests/markups/valid-21.markup   |  1 +
 tests/markups/valid-22.expected | 14 ++++++++++++++
 tests/markups/valid-22.markup   |  1 +
 7 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/docs/pango_markup.md b/docs/pango_markup.md
index 5f72dc98..408bead9 100644
--- a/docs/pango_markup.md
+++ b/docs/pango_markup.md
@@ -146,8 +146,9 @@ overline_color
   name such as 'red'. Overline support was added in Pango 1.46/
 
 rise
-: Vertical displacement, in Pango units. Can be negative for subscript, positive
-  for superscript.
+: Vertical displacement, in Pango units or in points (e.g. '5pt'). Can be
+  negative for subscript, positive for superscript.
+  Support for specifying rise in points was added in Pango 1.50.
 
 strikethrough
 : 'true' or 'false' whether to strike through the text.
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index 24de1fc6..a4bea3e5 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -1589,8 +1589,17 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
     {
       gint n = 0;
 
-      if (!span_parse_int ("rise", rise, &n, line_number, error))
-       goto error;
+      if (!parse_length (rise, &n))
+        {
+          g_set_error (error,
+                       G_MARKUP_ERROR,
+                       G_MARKUP_ERROR_INVALID_CONTENT,
+                       _("Value of 'rise' attribute on <span> tag on line %d "
+                         "could not be parsed; should be an integer, or a "
+                         "string such as '5.5pt', not '%s'"),
+                       line_number, rise);
+          goto error;
+        }
 
       add_attribute (tag, pango_attr_rise_new (n));
     }
diff --git a/tests/markups/fail-11.expected b/tests/markups/fail-11.expected
index 96cac741..4332ad5d 100644
--- a/tests/markups/fail-11.expected
+++ b/tests/markups/fail-11.expected
@@ -1 +1 @@
-ERROR: Value of 'rise' attribute on <span> tag on line 1 could not be parsed; should be an integer, not 'sky'
\ No newline at end of file
+ERROR: Value of 'rise' attribute on <span> tag on line 1 could not be parsed; should be an integer, or a 
string such as '5.5pt', not 'sky'
\ No newline at end of file
diff --git a/tests/markups/valid-21.expected b/tests/markups/valid-21.expected
new file mode 100644
index 00000000..9dc37dc1
--- /dev/null
+++ b/tests/markups/valid-21.expected
@@ -0,0 +1,14 @@
+test
+
+
+---
+
+range 0 4
+[0,4]rise=2560
+range 4 2147483647
+
+
+---
+
+[0:4] (null) Normal
+[4:2147483647] (null) Normal
diff --git a/tests/markups/valid-21.markup b/tests/markups/valid-21.markup
new file mode 100644
index 00000000..b448051b
--- /dev/null
+++ b/tests/markups/valid-21.markup
@@ -0,0 +1 @@
+<span rise="2.5pt">test</span>
diff --git a/tests/markups/valid-22.expected b/tests/markups/valid-22.expected
new file mode 100644
index 00000000..194c1960
--- /dev/null
+++ b/tests/markups/valid-22.expected
@@ -0,0 +1,14 @@
+test
+
+
+---
+
+range 0 4
+[0,4]rise=-5000
+range 4 2147483647
+
+
+---
+
+[0:4] (null) Normal
+[4:2147483647] (null) Normal
diff --git a/tests/markups/valid-22.markup b/tests/markups/valid-22.markup
new file mode 100644
index 00000000..dd828041
--- /dev/null
+++ b/tests/markups/valid-22.markup
@@ -0,0 +1 @@
+<span rise="-5000">test</span>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]