summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-17 05:39:08 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-11-17 05:39:08 +0000
commit1d800b3f743d493b3568ca07cfd43c0399edb783 (patch)
treef6f852586f3ed5de18abd4f56cd0325fa0e3d079
parent9278c4f0c59b550f9d4ff10219d8e6242baa081f (diff)
parentb892330253904191c47e5319b0ffdc705961b609 (diff)
downloadpango-1d800b3f743d493b3568ca07cfd43c0399edb783.tar.gz
Merge branch 'serialize-attrs-and-tabs' into 'main'
Add pango_attr_list_to/from_string See merge request GNOME/pango!512
-rw-r--r--pango/pango-attributes.c543
-rw-r--r--pango/pango-attributes.h5
-rw-r--r--pango/pango-tabs.c102
-rw-r--r--pango/pango-tabs.h4
-rw-r--r--tests/itemize/one.expected14
-rw-r--r--tests/itemize/two.expected14
-rw-r--r--tests/layouts/valid-1.expected14
-rw-r--r--tests/layouts/valid-10.expected2
-rw-r--r--tests/layouts/valid-11.expected24
-rw-r--r--tests/layouts/valid-13.expected6
-rw-r--r--tests/layouts/valid-14.expected2
-rw-r--r--tests/layouts/valid-15.expected2
-rw-r--r--tests/layouts/valid-16.expected2
-rw-r--r--tests/layouts/valid-18.expected8
-rw-r--r--tests/layouts/valid-2.expected6
-rw-r--r--tests/layouts/valid-20.expected12
-rw-r--r--tests/layouts/valid-22.expected130
-rw-r--r--tests/layouts/valid-5.expected10
-rw-r--r--tests/layouts/valid-7.expected10
-rw-r--r--tests/layouts/valid-9.expected12
-rw-r--r--tests/markups/valid-1.expected6
-rw-r--r--tests/markups/valid-10.expected22
-rw-r--r--tests/markups/valid-11.expected68
-rw-r--r--tests/markups/valid-12.expected10
-rw-r--r--tests/markups/valid-13.expected2
-rw-r--r--tests/markups/valid-14.expected4
-rw-r--r--tests/markups/valid-16.expected12
-rw-r--r--tests/markups/valid-17.expected2
-rw-r--r--tests/markups/valid-18.expected22
-rw-r--r--tests/markups/valid-19.expected10
-rw-r--r--tests/markups/valid-2.expected6
-rw-r--r--tests/markups/valid-20.expected2
-rw-r--r--tests/markups/valid-21.expected2
-rw-r--r--tests/markups/valid-22.expected2
-rw-r--r--tests/markups/valid-23.expected6
-rw-r--r--tests/markups/valid-24.expected4
-rw-r--r--tests/markups/valid-3.expected24
-rw-r--r--tests/markups/valid-4.expected38
-rw-r--r--tests/markups/valid-5.expected8
-rw-r--r--tests/markups/valid-6.expected14
-rw-r--r--tests/markups/valid-7.expected4
-rw-r--r--tests/markups/valid-8.expected64
-rw-r--r--tests/markups/valid-9.expected2
-rw-r--r--tests/meson.build1
-rw-r--r--tests/test-common.c296
-rw-r--r--tests/test-common.h6
-rw-r--r--tests/testattributes.c647
-rw-r--r--tests/testserialize.c134
48 files changed, 1435 insertions, 905 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index c929a3d5..13468963 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -2524,6 +2524,549 @@ pango_attr_list_filter (PangoAttrList *list,
return new;
}
+/* {{{ PangoAttrList serialization */
+
+/* We serialize attribute lists to strings. The format
+ * is a comma-separated list of the attributes in the order
+ * in which they are in the list, with each attribute having
+ * this format:
+ *
+ * START END NICK VALUE
+ *
+ * Values that can contain a comma, such as font descriptions
+ * are quoted with "".
+ */
+
+static const char *
+get_attr_type_nick (PangoAttrType attr_type)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ enum_class = g_type_class_ref (pango_attr_type_get_type ());
+ enum_value = g_enum_get_value (enum_class, attr_type);
+ g_type_class_unref (enum_class);
+
+ return enum_value->value_nick;
+}
+
+static GType
+get_attr_value_type (PangoAttrType type)
+{
+ switch ((int)type)
+ {
+ case PANGO_ATTR_STYLE: return PANGO_TYPE_STYLE;
+ case PANGO_ATTR_WEIGHT: return PANGO_TYPE_WEIGHT;
+ case PANGO_ATTR_VARIANT: return PANGO_TYPE_VARIANT;
+ case PANGO_ATTR_STRETCH: return PANGO_TYPE_STRETCH;
+ case PANGO_ATTR_GRAVITY: return PANGO_TYPE_GRAVITY;
+ case PANGO_ATTR_GRAVITY_HINT: return PANGO_TYPE_GRAVITY_HINT;
+ case PANGO_ATTR_UNDERLINE: return PANGO_TYPE_UNDERLINE;
+ case PANGO_ATTR_OVERLINE: return PANGO_TYPE_OVERLINE;
+ case PANGO_ATTR_BASELINE_SHIFT: return PANGO_TYPE_BASELINE_SHIFT;
+ case PANGO_ATTR_FONT_SCALE: return PANGO_TYPE_FONT_SCALE;
+ case PANGO_ATTR_TEXT_TRANSFORM: return PANGO_TYPE_TEXT_TRANSFORM;
+ default: return G_TYPE_INVALID;
+ }
+}
+
+static void
+append_enum_value (GString *str,
+ GType type,
+ int value)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ enum_class = g_type_class_ref (type);
+ enum_value = g_enum_get_value (enum_class, value);
+ g_type_class_unref (enum_class);
+
+ if (enum_value)
+ g_string_append_printf (str, " %s", enum_value->value_nick);
+ else
+ g_string_append_printf (str, " %d", value);
+}
+
+static void
+attr_print (GString *str,
+ PangoAttribute *attr)
+{
+ PangoAttrString *string;
+ PangoAttrLanguage *lang;
+ PangoAttrInt *integer;
+ PangoAttrFloat *flt;
+ PangoAttrFontDesc *font;
+ PangoAttrColor *color;
+ PangoAttrShape *shape;
+ PangoAttrSize *size;
+ PangoAttrFontFeatures *features;
+
+ g_string_append_printf (str, "%u %u ", attr->start_index, attr->end_index);
+
+ g_string_append (str, get_attr_type_nick (attr->klass->type));
+
+ if (attr->klass->type == PANGO_ATTR_WEIGHT ||
+ attr->klass->type == PANGO_ATTR_STYLE ||
+ attr->klass->type == PANGO_ATTR_STRETCH ||
+ attr->klass->type == PANGO_ATTR_VARIANT ||
+ attr->klass->type == PANGO_ATTR_GRAVITY ||
+ attr->klass->type == PANGO_ATTR_GRAVITY_HINT ||
+ attr->klass->type == PANGO_ATTR_UNDERLINE ||
+ attr->klass->type == PANGO_ATTR_OVERLINE ||
+ attr->klass->type == PANGO_ATTR_BASELINE_SHIFT ||
+ attr->klass->type == PANGO_ATTR_FONT_SCALE ||
+ attr->klass->type == PANGO_ATTR_TEXT_TRANSFORM)
+ append_enum_value (str, get_attr_value_type (attr->klass->type), ((PangoAttrInt *)attr)->value);
+ else if (attr->klass->type == PANGO_ATTR_STRIKETHROUGH ||
+ attr->klass->type == PANGO_ATTR_ALLOW_BREAKS ||
+ attr->klass->type == PANGO_ATTR_INSERT_HYPHENS ||
+ attr->klass->type == PANGO_ATTR_FALLBACK)
+ g_string_append (str, ((PangoAttrInt *)attr)->value ? " true" : " false");
+ else if ((string = pango_attribute_as_string (attr)) != NULL)
+ g_string_append_printf (str, " %s", string->value);
+ else if ((lang = pango_attribute_as_language (attr)) != NULL)
+ g_string_append_printf (str, " %s", pango_language_to_string (lang->value));
+ else if ((integer = pango_attribute_as_int (attr)) != NULL)
+ g_string_append_printf (str, " %d", integer->value);
+ else if ((flt = pango_attribute_as_float (attr)) != NULL)
+ {
+ char buf[20];
+ g_ascii_formatd (buf, 20, " %f", flt->value);
+ g_string_append_printf (str, " %s", buf);
+ }
+ else if ((font = pango_attribute_as_font_desc (attr)) != NULL)
+ {
+ char *s = pango_font_description_to_string (font->desc);
+ g_string_append_printf (str, " \"%s\"", s);
+ g_free (s);
+ }
+ else if ((color = pango_attribute_as_color (attr)) != NULL)
+ {
+ char *s = pango_color_to_string (&color->color);
+ g_string_append_printf (str, " %s", s);
+ g_free (s);
+ }
+ else if ((shape = pango_attribute_as_shape (attr)) != NULL)
+ g_string_append (str, "shape"); /* FIXME */
+ else if ((size = pango_attribute_as_size (attr)) != NULL)
+ g_string_append_printf (str, " %d", size->size);
+ else if ((features = pango_attribute_as_font_features (attr)) != NULL)
+ g_string_append_printf (str, " \"%s\"", features->features);
+ else
+ g_assert_not_reached ();
+}
+
+/**
+ * pango_attr_list_to_string:
+ * @list: a `PangoAttrList`
+ *
+ * Serializes a `PangoAttrList` to a string.
+ *
+ * No guarantees are made about the format of the string,
+ * it may change between Pango versions.
+ *
+ * The intended use of this function is testing and
+ * debugging. The format is not meant as a permanent
+ * storage format.
+ *
+ * Returns: (transfer full): a newly allocated string
+ * Since: 1.50
+ */
+char *
+pango_attr_list_to_string (PangoAttrList *list)
+{
+ GString *s;
+
+ s = g_string_new ("");
+
+ if (list->attributes)
+ for (int i = 0; i < list->attributes->len; i++)
+ {
+ PangoAttribute *attr = g_ptr_array_index (list->attributes, i);
+
+ if (i > 0)
+ g_string_append (s, "\n");
+ attr_print (s, attr);
+ }
+
+ return g_string_free (s, FALSE);
+}
+
+static PangoAttrType
+get_attr_type_by_nick (const char *nick,
+ int len)
+{
+ GEnumClass *enum_class;
+
+ enum_class = g_type_class_ref (pango_attr_type_get_type ());
+ for (GEnumValue *ev = enum_class->values; ev->value_name; ev++)
+ {
+ if (ev->value_nick && strncmp (ev->value_nick, nick, len) == 0)
+ {
+ g_type_class_unref (enum_class);
+ return (PangoAttrType) ev->value;
+ }
+ }
+
+ g_type_class_unref (enum_class);
+ return PANGO_ATTR_INVALID;
+}
+
+static int
+get_attr_value (PangoAttrType type,
+ const char *str,
+ int len)
+{
+ GEnumClass *enum_class;
+ char *endp;
+ int value;
+
+ enum_class = g_type_class_ref (get_attr_value_type (type));
+ for (GEnumValue *ev = enum_class->values; ev->value_name; ev++)
+ {
+ if (ev->value_nick && strncmp (ev->value_nick, str, len) == 0)
+ {
+ g_type_class_unref (enum_class);
+ return ev->value;
+ }
+ }
+ g_type_class_unref (enum_class);
+
+ value = g_ascii_strtoll (str, &endp, 10);
+ if (endp - str == len)
+ return value;
+
+ return -1;
+}
+
+static gboolean
+is_valid_end_char (char c)
+{
+ return c == ',' || c == '\n' || c == '\0';
+}
+
+/**
+ * pango_attr_list_from_string:
+ * @text: a string
+ *
+ * Deserializes a `PangoAttrList` from a string.
+ *
+ * This is the counterpart to [func@Pango.AttrList.to_string].
+ * See that functions for details about the format.
+ *
+ * Returns: (transfer full) (nullable): a new `PangoAttrList`
+ * Since: 1.50
+ */
+PangoAttrList *
+pango_attr_list_from_string (const char *text)
+{
+ PangoAttrList *list;
+ const char *p;
+
+ g_return_val_if_fail (text != NULL, NULL);
+
+ list = pango_attr_list_new ();
+
+ if (*text == '\0')
+ return list;
+
+ list->attributes = g_ptr_array_new ();
+
+ p = text + strspn (text, " \t\n");
+ while (*p)
+ {
+ char *endp;
+ gint64 start_index;
+ gint64 end_index;
+ char *str;
+ PangoAttrType attr_type;
+ PangoAttribute *attr;
+ PangoLanguage *lang;
+ gint64 integer;
+ PangoFontDescription *desc;
+ PangoColor color;
+ double num;
+
+ start_index = g_ascii_strtoll (p, &endp, 10);
+ if (*endp != ' ')
+ goto fail;
+
+ p = endp + strspn (endp, " ");
+ if (!*p)
+ goto fail;
+
+ end_index = g_ascii_strtoll (p, &endp, 10);
+ if (*endp != ' ')
+ goto fail;
+
+ p = endp + strspn (endp, " ");
+
+ endp = (char *)strpbrk (p, " ");
+ attr_type = get_attr_type_by_nick (p, endp - p);
+
+ p = endp + strspn (endp, " ");
+ if (*p == '\0')
+ goto fail;
+
+#define INT_ATTR(name,type) \
+ integer = g_ascii_strtoll (p, &endp, 10); \
+ if (!is_valid_end_char (*endp)) goto fail; \
+ attr = pango_attr_##name##_new ((type)integer);
+
+#define BOOLEAN_ATTR(name,type) \
+ if (strncmp (p, "true", strlen ("true")) == 0) \
+ { \
+ integer = 1; \
+ endp = (char *)(p + strlen ("true")); \
+ } \
+ else if (strncmp (p, "false", strlen ("false")) == 0) \
+ { \
+ integer = 0; \
+ endp = (char *)(p + strlen ("false")); \
+ } \
+ else \
+ integer = g_ascii_strtoll (p, &endp, 10); \
+ if (!is_valid_end_char (*endp)) goto fail; \
+ attr = pango_attr_##name##_new ((type)integer);
+
+#define ENUM_ATTR(name, type, min, max) \
+ endp = (char *)p + strcspn (p, ",\n"); \
+ integer = get_attr_value (attr_type, p, endp - p); \
+ attr = pango_attr_##name##_new ((type) CLAMP (integer, min, max));
+
+#define FLOAT_ATTR(name) \
+ num = g_ascii_strtod (p, &endp); \
+ if (!is_valid_end_char (*endp)) goto fail; \
+ attr = pango_attr_##name##_new ((float)num);
+
+#define COLOR_ATTR(name) \
+ endp = (char *)p + strcspn (p, ",\n"); \
+ if (!is_valid_end_char (*endp)) goto fail; \
+ str = g_strndup (p, endp - p); \
+ if (!pango_color_parse (&color, str)) \
+ { \
+ g_free (str); \
+ goto fail; \
+ } \
+ attr = pango_attr_##name##_new (color.red, color.green, color.blue); \
+ g_free (str);
+
+ switch (attr_type)
+ {
+ case PANGO_ATTR_INVALID:
+ pango_attr_list_unref (list);
+ return NULL;
+
+ case PANGO_ATTR_LANGUAGE:
+ endp = (char *)p + strcspn (p, ",\n");
+ if (!is_valid_end_char (*endp)) goto fail;
+ str = g_strndup (p, endp - p);
+ lang = pango_language_from_string (str);
+ attr = pango_attr_language_new (lang);
+ g_free (str);
+ break;
+
+ case PANGO_ATTR_FAMILY:
+ endp = (char *)p + strcspn (p, ",\n");
+ if (!is_valid_end_char (*endp)) goto fail;
+ str = g_strndup (p, endp - p);
+ attr = pango_attr_family_new (str);
+ g_free (str);
+ break;
+
+ case PANGO_ATTR_STYLE:
+ ENUM_ATTR(style, PangoStyle, PANGO_STYLE_NORMAL, PANGO_STYLE_ITALIC);
+ break;
+
+ case PANGO_ATTR_WEIGHT:
+ ENUM_ATTR(weight, PangoWeight, PANGO_WEIGHT_THIN, PANGO_WEIGHT_ULTRAHEAVY);
+ break;
+
+ case PANGO_ATTR_VARIANT:
+ ENUM_ATTR(variant, PangoVariant, PANGO_VARIANT_NORMAL, PANGO_VARIANT_TITLE_CAPS);
+ break;
+
+ case PANGO_ATTR_STRETCH:
+ ENUM_ATTR(stretch, PangoStretch, PANGO_STRETCH_ULTRA_CONDENSED, PANGO_STRETCH_ULTRA_EXPANDED);
+ break;
+
+ case PANGO_ATTR_SIZE:
+ INT_ATTR(size, int);
+ break;
+
+ case PANGO_ATTR_FONT_DESC:
+ p++;
+ endp = strchr (p, '"');
+ if (!endp) goto fail;
+ str = g_strndup (p, endp - p);
+ desc = pango_font_description_from_string (str);
+ attr = pango_attr_font_desc_new (desc);
+ pango_font_description_free (desc);
+ g_free (str);
+ endp++;
+ if (!is_valid_end_char (*endp)) goto fail;
+ break;
+
+ case PANGO_ATTR_FOREGROUND:
+ COLOR_ATTR(foreground);
+ break;
+
+ case PANGO_ATTR_BACKGROUND:
+ COLOR_ATTR(background);
+ break;
+
+ case PANGO_ATTR_UNDERLINE:
+ ENUM_ATTR(underline, PangoUnderline, PANGO_UNDERLINE_NONE, PANGO_UNDERLINE_ERROR_LINE);
+ break;
+
+ case PANGO_ATTR_STRIKETHROUGH:
+ BOOLEAN_ATTR(strikethrough, gboolean);
+ break;
+
+ case PANGO_ATTR_RISE:
+ INT_ATTR(rise, int);
+ break;
+
+ case PANGO_ATTR_SHAPE:
+ endp = (char *)strpbrk (p, ",\n");
+ p = endp + strspn (endp, " ");
+ continue; /* FIXME */
+
+ case PANGO_ATTR_SCALE:
+ FLOAT_ATTR(scale);
+ break;
+
+ case PANGO_ATTR_FALLBACK:
+ BOOLEAN_ATTR(fallback, gboolean);
+ break;
+
+ case PANGO_ATTR_LETTER_SPACING:
+ INT_ATTR(letter_spacing, int);
+ break;
+
+ case PANGO_ATTR_UNDERLINE_COLOR:
+ COLOR_ATTR(underline_color);
+ break;
+
+ case PANGO_ATTR_STRIKETHROUGH_COLOR:
+ COLOR_ATTR(strikethrough_color);
+ break;
+
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ integer = g_ascii_strtoll (p, &endp, 10);
+ if (!is_valid_end_char (*endp)) goto fail;
+ attr = pango_attr_size_new_absolute (integer);
+ break;
+
+ case PANGO_ATTR_GRAVITY:
+ ENUM_ATTR(gravity, PangoGravity, PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_WEST);
+ break;
+
+ case PANGO_ATTR_FONT_FEATURES:
+ p++;
+ endp = strchr (p, '"');
+ if (!endp) goto fail;
+ str = g_strndup (p, endp - p);
+ attr = pango_attr_font_features_new (str);
+ g_free (str);
+ endp++;
+ if (!is_valid_end_char (*endp)) goto fail;
+ break;
+
+ case PANGO_ATTR_GRAVITY_HINT:
+ ENUM_ATTR(gravity_hint, PangoGravityHint, PANGO_GRAVITY_HINT_NATURAL, PANGO_GRAVITY_HINT_LINE);
+ break;
+
+ case PANGO_ATTR_FOREGROUND_ALPHA:
+ INT_ATTR(foreground_alpha, int);
+ break;
+
+ case PANGO_ATTR_BACKGROUND_ALPHA:
+ INT_ATTR(background_alpha, int);
+ break;
+
+ case PANGO_ATTR_ALLOW_BREAKS:
+ BOOLEAN_ATTR(allow_breaks, gboolean);
+ break;
+
+ case PANGO_ATTR_SHOW:
+ INT_ATTR(show, PangoShowFlags);
+ break;
+
+ case PANGO_ATTR_INSERT_HYPHENS:
+ BOOLEAN_ATTR(insert_hyphens, gboolean);
+ break;
+
+ case PANGO_ATTR_OVERLINE:
+ ENUM_ATTR(overline, PangoOverline, PANGO_OVERLINE_NONE, PANGO_OVERLINE_SINGLE);
+ break;
+
+ case PANGO_ATTR_OVERLINE_COLOR:
+ COLOR_ATTR(overline_color);
+ break;
+
+ case PANGO_ATTR_LINE_HEIGHT:
+ FLOAT_ATTR(line_height);
+ break;
+
+ case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
+ integer = g_ascii_strtoll (p, &endp, 10);
+ if (!is_valid_end_char (*endp)) goto fail;
+ attr = pango_attr_line_height_new_absolute (integer);
+ break;
+
+ case PANGO_ATTR_TEXT_TRANSFORM:
+ ENUM_ATTR(text_transform, PangoTextTransform, PANGO_TEXT_TRANSFORM_NONE, PANGO_TEXT_TRANSFORM_CAPITALIZE);
+ break;
+
+ case PANGO_ATTR_WORD:
+ integer = g_ascii_strtoll (p, &endp, 10);
+ if (!is_valid_end_char (*endp)) goto fail;
+ attr = pango_attr_word_new ();
+ break;
+
+ case PANGO_ATTR_SENTENCE:
+ integer = g_ascii_strtoll (p, &endp, 10);
+ if (!is_valid_end_char (*endp)) goto fail;
+ attr = pango_attr_sentence_new ();
+ break;
+
+ case PANGO_ATTR_BASELINE_SHIFT:
+ ENUM_ATTR(baseline_shift, PangoBaselineShift, 0, G_MAXINT);
+ break;
+
+ case PANGO_ATTR_FONT_SCALE:
+ ENUM_ATTR(font_scale, PangoFontScale, PANGO_FONT_SCALE_NONE, PANGO_FONT_SCALE_SMALL_CAPS);
+ break;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ attr->start_index = (guint)start_index;
+ attr->end_index = (guint)end_index;
+ g_ptr_array_add (list->attributes, attr);
+
+ p = endp;
+ if (*p)
+ {
+ if (*p == ',')
+ p++;
+ p += strspn (p, " \n");
+ }
+ }
+
+ goto success;
+
+fail:
+ pango_attr_list_unref (list);
+ list = NULL;
+
+success:
+ return list;
+}
+
/* }}} */
/* {{{ Attribute Iterator */
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index 018417d5..5ea6bd9e 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -707,6 +707,11 @@ PANGO_AVAILABLE_IN_1_46
gboolean pango_attr_list_equal (PangoAttrList *list,
PangoAttrList *other_list);
+PANGO_AVAILABLE_IN_1_50
+char * pango_attr_list_to_string (PangoAttrList *list);
+PANGO_AVAILABLE_IN_1_50
+PangoAttrList * pango_attr_list_from_string (const char *text);
+
PANGO_AVAILABLE_IN_1_44
GType pango_attr_iterator_get_type (void) G_GNUC_CONST;
diff --git a/pango/pango-tabs.c b/pango/pango-tabs.c
index 28027454..c126ec91 100644
--- a/pango/pango-tabs.c
+++ b/pango/pango-tabs.c
@@ -371,3 +371,105 @@ pango_tab_array_get_positions_in_pixels (PangoTabArray *tab_array)
return tab_array->positions_in_pixels;
}
+
+/**
+ * pango_tab_array_to_string:
+ * @tab_array: a `PangoTabArray`
+ *
+ * Serializes a `PangoTabArray` to a string.
+ *
+ * No guarantees are made about the format of the string,
+ * it may change between Pango versions.
+ *
+ * The intended use of this function is testing and
+ * debugging. The format is not meant as a permanent
+ * storage format.
+ *
+ * Returns: (transfer full): a newly allocated string
+ * Since: 1.50
+ */
+char *
+pango_tab_array_to_string (PangoTabArray *tab_array)
+{
+ GString *s;
+
+ s = g_string_new ("");
+
+ for (int i = 0; i < tab_array->size; i++)
+ {
+ if (i > 0)
+ g_string_append_c (s, ' ');
+ g_string_append_printf (s, "%d", tab_array->tabs[i].location);
+ if (tab_array->positions_in_pixels)
+ g_string_append (s, "px");
+ }
+
+ return g_string_free (s, FALSE);
+}
+
+static const char *
+skip_whitespace (const char *p)
+{
+ while (g_ascii_isspace (*p))
+ p++;
+ return p;
+}
+
+/**
+ * pango_tab_array_from_string:
+ * @text: a string
+ *
+ * Deserializes a `PangoTabArray` from a string.
+ *
+ * This is the counterpart to [func@Pango.TabArray.to_string].
+ * See that functions for details about the format.
+ *
+ * Returns: (transfer full) (nullable): a new `PangoTabArray`
+ * Since: 1.50
+ */
+PangoTabArray *
+pango_tab_array_from_string (const char *text)
+{
+ PangoTabArray *array;
+ gboolean pixels;
+ const char *p;
+ int i;
+
+ pixels = strstr (text, "px") != NULL;
+
+ array = pango_tab_array_new (0, pixels);
+
+ p = skip_whitespace (text);
+
+ i = 0;
+ while (*p)
+ {
+ char *endp;
+ gint64 pos;
+
+ pos = g_ascii_strtoll (p, &endp, 10);
+ if (pos < 0 ||
+ (pixels && *endp != 'p') ||
+ (!pixels && !g_ascii_isspace (*endp) && *endp != '\0')) goto fail;
+
+ pango_tab_array_set_tab (array, i, PANGO_TAB_LEFT, pos);
+ i++;
+
+ p = (const char *)endp;
+ if (pixels)
+ {
+ if (p[0] != 'p' || p[1] != 'x') goto fail;
+ p += 2;
+ }
+ p = skip_whitespace (p);
+ }
+
+ goto success;
+
+fail:
+ pango_tab_array_free (array);
+ array = NULL;
+
+success:
+ return array;
+}
diff --git a/pango/pango-tabs.h b/pango/pango-tabs.h
index 893132ed..e8ce1b97 100644
--- a/pango/pango-tabs.h
+++ b/pango/pango-tabs.h
@@ -87,6 +87,10 @@ void pango_tab_array_get_tabs (PangoTabArray *tab_array,
PANGO_AVAILABLE_IN_ALL
gboolean pango_tab_array_get_positions_in_pixels (PangoTabArray *tab_array);
+PANGO_AVAILABLE_IN_1_50
+char * pango_tab_array_to_string (PangoTabArray *tab_array);
+PANGO_AVAILABLE_IN_1_50
+PangoTabArray * pango_tab_array_from_string (const char *text);
G_END_DECLS
diff --git a/tests/itemize/one.expected b/tests/itemize/one.expected
index aacf60d1..7f5103e1 100644
--- a/tests/itemize/one.expected
+++ b/tests/itemize/one.expected
@@ -1,9 +1,9 @@
<span font="Cantarell 11" fallback="false">a b
c</span>
-Items: a b |[0x2028] |c
-Chars: 3(0) |1(3) |1(4)
-Font: Cantarell 11 |Cantarell 11 |Cantarell 11
-Script: latin |latin |latin
-Lang: en-us |en-us |en-us
-Bidi: 0 |0 |0
-Attrs: [0,7]fallback=0|[0,7]fallback=0|[0,7]fallback=0
+Items: a b |[0x2028] |c
+Chars: 3(0) |1(3) |1(4)
+Font: Cantarell 11 |Cantarell 11 |Cantarell 11
+Script: latin |latin |latin
+Lang: en-us |en-us |en-us
+Bidi: 0 |0 |0
+Attrs: 0 7 fallback false|0 7 fallback false|0 7 fallback false
diff --git a/tests/itemize/two.expected b/tests/itemize/two.expected
index 5abb97b9..f2062a30 100644
--- a/tests/itemize/two.expected
+++ b/tests/itemize/two.expected
@@ -1,9 +1,9 @@
<span font="Cantarell 11">one <span font_features="tnum=0">tw<u>o</u> <span font_features="dlig=1">two</span> </span>th<b>r</b>ee</span>
-Items: one two two th |r |ee
-Chars: 14(0) |1(14) |2(15)
-Font: Cantarell 11 |Cantarell Bold 11|Cantarell 11
-Script: latin |latin |latin
-Lang: en-us |en-us |en-us
-Bidi: 0 |0 |0
-Attrs: [8,11]font-features=dlig=1,[6,7]underline=1,[4,12]font-features=tnum=0| |
+Items: one two two th |r |ee
+Chars: 14(0) |1(14) |2(15)
+Font: Cantarell 11 |Cantarell Bold 11|Cantarell 11
+Script: latin |latin |latin
+Lang: en-us |en-us |en-us
+Bidi: 0 |0 |0
+Attrs: 8 11 font-features "dlig=1",6 7 underline single,4 12 font-features "tnum=0"| |
diff --git a/tests/layouts/valid-1.expected b/tests/layouts/valid-1.expected
index 411c7560..96bbed57 100644
--- a/tests/layouts/valid-1.expected
+++ b/tests/layouts/valid-1.expected
@@ -11,8 +11,8 @@ width: 225280
range 0 22
range 22 41
-[22,41]foreground=#00000000ffff
-[22,41]underline=1
+22 41 foreground #00000000ffff
+22 41 underline single
range 41 2147483647
--- directions
@@ -33,11 +33,11 @@ i=2, index=49, paragraph-start=1, dir=ltr ''
i=1, index=0, chars=22, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'This is a test of the '
i=2, index=22, chars=11, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'automatic e'
-[22,41]foreground=#00000000ffff
-[22,41]underline=1
+22 41 foreground #00000000ffff
+22 41 underline single
i=3, index=33, chars=15, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'mergency brake!'
-[0,2147483647]fallback=0
-[22,41]foreground=#00000000ffff
-[22,41]underline=1
+0 2147483647 fallback false
+22 41 foreground #00000000ffff
+22 41 underline single
i=4, index=48, no run, line end
i=5, index=49, no run, line end
diff --git a/tests/layouts/valid-10.expected b/tests/layouts/valid-10.expected
index 137024b7..6eb02946 100644
--- a/tests/layouts/valid-10.expected
+++ b/tests/layouts/valid-10.expected
@@ -32,6 +32,6 @@ i=2, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=he
i=3, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
i=4, index=15, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γ'
i=5, index=17, chars=7, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'ειά σας'
-[0,2147483647]fallback=0
+0 2147483647 fallback false
i=6, index=30, no run, line end
i=7, index=31, no run, line end
diff --git a/tests/layouts/valid-11.expected b/tests/layouts/valid-11.expected
index a1fafc31..c22daf87 100644
--- a/tests/layouts/valid-11.expected
+++ b/tests/layouts/valid-11.expected
@@ -10,16 +10,16 @@ width: 225280
--- attributes
range 0 6
-[0,6]underline=2
-[0,6]overline=1
+0 6 underline double
+0 6 overline single
range 6 7
range 7 10
-[7,10]underline=3
-[7,10]strikethrough=1
+7 10 underline low
+7 10 strikethrough true
range 10 11
range 11 16
-[11,16]underline=4
-[11,16]rise=1024
+11 16 underline error
+11 16 rise 1024
range 16 2147483647
--- directions
@@ -39,15 +39,15 @@ i=2, index=17, paragraph-start=1, dir=ltr ''
--- runs
i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'double'
-[0,6]underline=2
-[0,6]overline=1
+0 6 underline double
+0 6 overline single
i=2, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
i=3, index=7, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'low'
-[7,10]underline=3
-[7,10]strikethrough=1
+7 10 underline low
+7 10 strikethrough true
i=4, index=10, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
i=5, index=11, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'error'
-[11,16]rise=1024
-[11,16]underline=4
+11 16 rise 1024
+11 16 underline error
i=6, index=16, no run, line end
i=7, index=17, no run, line end
diff --git a/tests/layouts/valid-13.expected b/tests/layouts/valid-13.expected
index 3064610d..cc435a88 100644
--- a/tests/layouts/valid-13.expected
+++ b/tests/layouts/valid-13.expected
@@ -26,10 +26,10 @@ i=1, index=0, paragraph-start=1, dir=ltr 'a b c d
e f
--- runs
i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'a b c d'
-[0,-1]show=2
+0 4294967295 show 2
i=2, index=25, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
'
-[0,-1]show=2
+0 4294967295 show 2
i=3, index=28, chars=24, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e f g h
'
-[0,-1]show=2
+0 4294967295 show 2
i=4, index=52, no run, line end
diff --git a/tests/layouts/valid-14.expected b/tests/layouts/valid-14.expected
index 5f15fa9f..89172781 100644
--- a/tests/layouts/valid-14.expected
+++ b/tests/layouts/valid-14.expected
@@ -28,7 +28,7 @@ i=2, index=38, paragraph-start=1, dir=ltr ''
--- runs
i=1, index=0, chars=1, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, '你'
-[0,2147483647]fallback=1
+0 2147483647 fallback true
i=2, index=3, chars=2, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, '好 '
i=3, index=7, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
i=4, index=19, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
diff --git a/tests/layouts/valid-15.expected b/tests/layouts/valid-15.expected
index 2711dfd8..f029482a 100644
--- a/tests/layouts/valid-15.expected
+++ b/tests/layouts/valid-15.expected
@@ -32,5 +32,5 @@ i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=la
i=2, index=25, no run, line end
i=3, index=25, chars=20, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'long enough to wrap '
i=4, index=45, chars=53, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'due to height limitations. It might, or it might not.'
-[0,2147483647]fallback=0
+0 2147483647 fallback false
i=5, index=98, no run, line end
diff --git a/tests/layouts/valid-16.expected b/tests/layouts/valid-16.expected
index 7ae3ae62..01af96cf 100644
--- a/tests/layouts/valid-16.expected
+++ b/tests/layouts/valid-16.expected
@@ -32,6 +32,6 @@ i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=la
i=2, index=25, no run, line end
i=3, index=25, chars=20, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'long enough to wrap '
i=4, index=45, chars=53, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'due to height limitations. It might, or it might not.'
-[0,2147483647]fallback=0
+0 2147483647 fallback false
i=5, index=98, no run, line end
i=6, index=99, no run, line end
diff --git a/tests/layouts/valid-18.expected b/tests/layouts/valid-18.expected
index 614321b3..ea6aabeb 100644
--- a/tests/layouts/valid-18.expected
+++ b/tests/layouts/valid-18.expected
@@ -9,7 +9,7 @@ lines: 3
--- attributes
range 0 57
-[0,57]show=7
+0 57 show 7
range 57 2147483647
--- directions
@@ -30,11 +30,11 @@ i=3, index=58, paragraph-start=1, dir=ltr ''
--- runs
i=1, index=0, chars=16, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'some line breaks'
-[0,57]show=7
+0 57 show 7
i=2, index=16, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
'
-[0,57]show=7
+0 57 show 7
i=3, index=19, no run, line end
i=4, index=19, chars=32, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'and mis­ce­llaneous ignora‌bles'
-[0,57]show=7
+0 57 show 7
i=5, index=57, no run, line end
i=6, index=58, no run, line end
diff --git a/tests/layouts/valid-2.expected b/tests/layouts/valid-2.expected
index b71f5da3..76c4f453 100644
--- a/tests/layouts/valid-2.expected
+++ b/tests/layouts/valid-2.expected
@@ -10,10 +10,10 @@ lines: 2
range 0 9
range 9 13
-[9,13]style=2
+9 13 style italic
range 13 20
range 20 25
-[20,25]underline=1
+20 25 underline single
range 25 2147483647
--- directions
@@ -36,7 +36,7 @@ i=1, index=0, chars=9, level=0, gravity=south, flags=0, font=OMITTED, script=lat
i=2, index=9, chars=4, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'blue'
i=3, index=13, chars=7, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' drink '
i=4, index=20, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'after'
-[20,25]underline=1
+20 25 underline single
i=5, index=25, chars=7, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' dinner'
i=6, index=32, no run, line end
i=7, index=33, no run, line end
diff --git a/tests/layouts/valid-20.expected b/tests/layouts/valid-20.expected
index 6939260b..e3a68815 100644
--- a/tests/layouts/valid-20.expected
+++ b/tests/layouts/valid-20.expected
@@ -9,10 +9,10 @@ lines: 2
--- attributes
range 0 3
-[0,3]gravity=1
-[0,3]gravity-hint=1
+0 3 gravity east
+0 3 gravity-hint strong
range 3 6
-[3,6]gravity=0
+3 6 gravity south
range 6 2147483647
--- directions
@@ -32,9 +32,9 @@ i=2, index=7, paragraph-start=1, dir=ltr ''
--- runs
i=1, index=0, chars=3, level=0, gravity=east, flags=0, font=OMITTED, script=latin, language=en-us, 'abc'
-[0,3]gravity=1
-[0,3]gravity-hint=1
+0 3 gravity east
+0 3 gravity-hint strong
i=2, index=3, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'def'
-[3,6]gravity=0
+3 6 gravity south
i=3, index=6, no run, line end
i=4, index=7, no run, line end
diff --git a/tests/layouts/valid-22.expected b/tests/layouts/valid-22.expected
index 69c09b04..8bbd3620 100644
--- a/tests/layouts/valid-22.expected
+++ b/tests/layouts/valid-22.expected
@@ -10,45 +10,45 @@ lines: 2
range 0 1
range 1 2
-[1,2]font-desc=Italic
-[1,2]font-scale=2
-[1,2]baseline-shift=2
+1 2 font-desc "Italic"
+1 2 font-scale subscript
+1 2 baseline-shift subscript
range 2 6
range 6 7
-[6,11]font-scale=1
-[6,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
range 7 8
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
range 8 9
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
-[8,11]font-scale=1
-[8,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
+8 11 font-scale superscript
+8 11 baseline-shift superscript
range 9 10
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
-[8,11]font-scale=1
-[8,11]baseline-shift=1
-[9,11]font-scale=1
-[9,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
+8 11 font-scale superscript
+8 11 baseline-shift superscript
+9 11 font-scale superscript
+9 11 baseline-shift superscript
range 10 11
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
-[8,11]font-scale=1
-[8,11]baseline-shift=1
-[9,11]font-scale=1
-[9,11]baseline-shift=1
-[10,11]font-scale=1
-[10,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
+8 11 font-scale superscript
+8 11 baseline-shift superscript
+9 11 font-scale superscript
+9 11 baseline-shift superscript
+10 11 font-scale superscript
+10 11 baseline-shift superscript
range 11 2147483647
--- directions
@@ -69,43 +69,43 @@ i=2, index=12, paragraph-start=1, dir=ltr ''
i=1, index=0, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e'
i=2, index=1, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '0'
-[1,2]font-scale=2
-[1,2]baseline-shift=2
+1 2 font-scale subscript
+1 2 baseline-shift subscript
i=3, index=2, chars=4, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' = o'
i=4, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'o'
-[6,11]font-scale=1
-[6,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
i=5, index=7, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'o'
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
i=6, index=8, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '.'
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
-[8,11]font-scale=1
-[8,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
+8 11 font-scale superscript
+8 11 baseline-shift superscript
i=7, index=9, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '.'
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
-[8,11]font-scale=1
-[8,11]baseline-shift=1
-[9,11]font-scale=1
-[9,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
+8 11 font-scale superscript
+8 11 baseline-shift superscript
+9 11 font-scale superscript
+9 11 baseline-shift superscript
i=8, index=10, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '.'
-[6,11]font-scale=1
-[6,11]baseline-shift=1
-[7,11]font-scale=1
-[7,11]baseline-shift=1
-[8,11]font-scale=1
-[8,11]baseline-shift=1
-[9,11]font-scale=1
-[9,11]baseline-shift=1
-[10,11]font-scale=1
-[10,11]baseline-shift=1
+6 11 font-scale superscript
+6 11 baseline-shift superscript
+7 11 font-scale superscript
+7 11 baseline-shift superscript
+8 11 font-scale superscript
+8 11 baseline-shift superscript
+9 11 font-scale superscript
+9 11 baseline-shift superscript
+10 11 font-scale superscript
+10 11 baseline-shift superscript
i=9, index=11, no run, line end
i=10, index=12, no run, line end
diff --git a/tests/layouts/valid-5.expected b/tests/layouts/valid-5.expected
index 82f413c9..20627955 100644
--- a/tests/layouts/valid-5.expected
+++ b/tests/layouts/valid-5.expected
@@ -12,7 +12,7 @@ width: 194560
range 0 21
range 21 31
-[21,31]font-features=tnum=1
+21 31 font-features "tnum=1"
range 31 2147483647
--- directions
@@ -38,16 +38,16 @@ i=7, index=125, paragraph-start=1, dir=ltr ''
--- runs
i=1, index=0, chars=21, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'A test with multiple '
-[21,31]font-features=tnum=1
+21 31 font-features "tnum=1"
i=2, index=21, no run, line end
i=3, index=21, chars=23, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'paragraphs and with no-'
-[21,31]font-features=tnum=1
+21 31 font-features "tnum=1"
i=4, index=44, no run, line end
i=5, index=44, chars=30, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'break attributes, which might '
-[21,31]font-features=tnum=1
+21 31 font-features "tnum=1"
i=6, index=74, no run, line end
i=7, index=74, chars=16, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'trigger a crash.'
-[21,31]font-features=tnum=1
+21 31 font-features "tnum=1"
i=8, index=90, no run, line end
i=9, index=91, chars=26, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'If it doesn't the fix has '
i=10, index=117, no run, line end
diff --git a/tests/layouts/valid-7.expected b/tests/layouts/valid-7.expected
index 7560a9cc..13595a75 100644
--- a/tests/layouts/valid-7.expected
+++ b/tests/layouts/valid-7.expected
@@ -12,8 +12,8 @@ indent: 51200
range 0 22
range 22 41
-[22,41]foreground=#00000000ffff
-[22,41]underline=1
+22 41 foreground #00000000ffff
+22 41 underline single
range 41 2147483647
--- directions
@@ -34,10 +34,10 @@ i=2, index=49, paragraph-start=1, dir=ltr ''
i=1, index=0, chars=12, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'This is a te'
i=2, index=12, chars=26, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'st of the automatic emerge'
-[0,2147483647]fallback=0
+0 2147483647 fallback false
i=3, index=38, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'ncy'
-[22,41]foreground=#00000000ffff
-[22,41]underline=1
+22 41 foreground #00000000ffff
+22 41 underline single
i=4, index=41, chars=7, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' brake!'
i=5, index=48, no run, line end
i=6, index=49, no run, line end
diff --git a/tests/layouts/valid-9.expected b/tests/layouts/valid-9.expected
index d1388f62..5cbbf8fc 100644
--- a/tests/layouts/valid-9.expected
+++ b/tests/layouts/valid-9.expected
@@ -10,7 +10,7 @@ width: 102400
--- attributes
range 0 30
-[0,30]letter-spacing=8888
+0 30 letter-spacing 8888
range 30 2147483647
--- directions
@@ -33,17 +33,17 @@ i=5, index=31, paragraph-start=1, dir=ltr ''
--- runs
i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
-[0,30]letter-spacing=8888
+0 30 letter-spacing 8888
i=2, index=6, no run, line end
i=3, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
-[0,30]letter-spacing=8888
+0 30 letter-spacing 8888
i=4, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
-[0,30]letter-spacing=8888
+0 30 letter-spacing 8888
i=5, index=15, no run, line end
i=6, index=15, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά '
-[0,30]letter-spacing=8888
+0 30 letter-spacing 8888
i=7, index=24, no run, line end
i=8, index=24, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'σας'
-[0,30]letter-spacing=8888
+0 30 letter-spacing 8888
i=9, index=30, no run, line end
i=10, index=31, no run, line end
diff --git a/tests/markups/valid-1.expected b/tests/markups/valid-1.expected
index 6ad9a22a..be01bfaf 100644
--- a/tests/markups/valid-1.expected
+++ b/tests/markups/valid-1.expected
@@ -4,11 +4,11 @@ Blue text is cool!
---
range 0 9
-[0,9]scale=1.440000
-[0,9]foreground=#00000000ffff
+0 9 scale 1.440000
+0 9 foreground #00000000ffff
range 9 13
range 13 17
-[13,17]style=2
+13 17 style italic
range 17 2147483647
diff --git a/tests/markups/valid-10.expected b/tests/markups/valid-10.expected
index 28f53835..24f3f8e3 100644
--- a/tests/markups/valid-10.expected
+++ b/tests/markups/valid-10.expected
@@ -4,17 +4,17 @@ Lots of attrs
---
range 0 13
-[0,13]font-desc=Sans Italic 12 @wdth=100,wght=200
-[0,13]foreground=#0000ffff0000
-[0,13]background=#f0f0f0f0f0f0
-[0,13]underline=2
-[0,13]underline-color=#ffff00000000
-[0,13]gravity=0
-[0,13]gravity-hint=1
-[0,13]strikethrough=1
-[0,13]strikethrough-color=#00000000ffff
-[0,13]fallback=0
-[0,13]language=de
+0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
+0 13 foreground #0000ffff0000
+0 13 background #f0f0f0f0f0f0
+0 13 underline double
+0 13 underline-color #ffff00000000
+0 13 gravity south
+0 13 gravity-hint strong
+0 13 strikethrough true
+0 13 strikethrough-color #00000000ffff
+0 13 fallback false
+0 13 language de
range 13 2147483647
diff --git a/tests/markups/valid-11.expected b/tests/markups/valid-11.expected
index 797ef399..2a551850 100644
--- a/tests/markups/valid-11.expected
+++ b/tests/markups/valid-11.expected
@@ -4,42 +4,42 @@ Lots of attrs
---
range 0 5
-[0,13]font-desc=Sans Italic 12 @wdth=100,wght=200
-[0,13]foreground=#0000ffff0000
-[0,13]background=#f0f0f0f0f0f0
-[0,13]underline=2
-[0,13]underline-color=#ffff00000000
-[0,13]gravity=0
-[0,13]gravity-hint=1
-[0,13]strikethrough=1
-[0,13]strikethrough-color=#00000000ffff
-[0,13]fallback=0
-[0,13]language=de
+0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
+0 13 foreground #0000ffff0000
+0 13 background #f0f0f0f0f0f0
+0 13 underline double
+0 13 underline-color #ffff00000000
+0 13 gravity south
+0 13 gravity-hint strong
+0 13 strikethrough true
+0 13 strikethrough-color #00000000ffff
+0 13 fallback false
+0 13 language de
range 5 7
-[0,13]font-desc=Sans Italic 12 @wdth=100,wght=200
-[0,13]foreground=#0000ffff0000
-[0,13]background=#f0f0f0f0f0f0
-[0,13]underline=2
-[0,13]underline-color=#ffff00000000
-[0,13]gravity=0
-[0,13]gravity-hint=1
-[0,13]strikethrough=1
-[0,13]strikethrough-color=#00000000ffff
-[0,13]fallback=0
-[0,13]language=de
-[5,7]font-desc=Bold
+0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
+0 13 foreground #0000ffff0000
+0 13 background #f0f0f0f0f0f0
+0 13 underline double
+0 13 underline-color #ffff00000000
+0 13 gravity south
+0 13 gravity-hint strong
+0 13 strikethrough true
+0 13 strikethrough-color #00000000ffff
+0 13 fallback false
+0 13 language de
+5 7 font-desc "Bold"
range 7 13
-[0,13]font-desc=Sans Italic 12 @wdth=100,wght=200
-[0,13]foreground=#0000ffff0000
-[0,13]background=#f0f0f0f0f0f0
-[0,13]underline=2
-[0,13]underline-color=#ffff00000000
-[0,13]gravity=0
-[0,13]gravity-hint=1
-[0,13]strikethrough=1
-[0,13]strikethrough-color=#00000000ffff
-[0,13]fallback=0
-[0,13]language=de
+0 13 font-desc "Sans Italic 12 @wdth=100,wght=200"
+0 13 foreground #0000ffff0000
+0 13 background #f0f0f0f0f0f0
+0 13 underline double
+0 13 underline-color #ffff00000000
+0 13 gravity south
+0 13 gravity-hint strong
+0 13 strikethrough true
+0 13 strikethrough-color #00000000ffff
+0 13 fallback false
+0 13 language de
range 13 2147483647
diff --git a/tests/markups/valid-12.expected b/tests/markups/valid-12.expected
index b6587ee8..45bbc10c 100644
--- a/tests/markups/valid-12.expected
+++ b/tests/markups/valid-12.expected
@@ -8,19 +8,19 @@ error-line
---
range 0 8
-[0,8]overline=1
+0 8 overline single
range 8 9
range 9 23
-[9,23]overline-color=#ffff00000000
+9 23 overline-color #ffff00000000
range 23 24
range 24 35
-[24,35]underline=5
+24 35 underline single-line
range 35 36
range 36 47
-[36,47]underline=6
+36 47 underline double-line
range 47 48
range 48 58
-[48,58]underline=7
+48 58 underline error-line
range 58 2147483647
diff --git a/tests/markups/valid-13.expected b/tests/markups/valid-13.expected
index c63a71c4..c573dd3d 100644
--- a/tests/markups/valid-13.expected
+++ b/tests/markups/valid-13.expected
@@ -5,7 +5,7 @@ abc def
range 0 4
range 4 5
-[4,5]underline=3
+4 5 underline low
range 5 2147483647
diff --git a/tests/markups/valid-14.expected b/tests/markups/valid-14.expected
index 4aa87977..580f9166 100644
--- a/tests/markups/valid-14.expected
+++ b/tests/markups/valid-14.expected
@@ -4,10 +4,10 @@ abc def _x_
---
range 0 1
-[0,1]underline=3
+0 1 underline low
range 1 4
range 4 5
-[4,5]underline=3
+4 5 underline low
range 5 2147483647
diff --git a/tests/markups/valid-16.expected b/tests/markups/valid-16.expected
index c8b000a8..a8a0dcd2 100644
--- a/tests/markups/valid-16.expected
+++ b/tests/markups/valid-16.expected
@@ -4,16 +4,16 @@ larger and smaller and smaller now with base
---
range 0 11
-[0,44]scale=1.200000
+0 44 scale 1.200000
range 11 19
-[11,30]scale=1.000000
+11 30 scale 1.000000
range 19 30
-[19,30]scale=0.833333
+19 30 scale 0.833333
range 30 31
-[0,44]scale=1.200000
+0 44 scale 1.200000
range 31 44
-[0,44]scale=1.200000
-[31,44]size=15360
+0 44 scale 1.200000
+31 44 size 15360
range 44 2147483647
diff --git a/tests/markups/valid-17.expected b/tests/markups/valid-17.expected
index 8b9ce039..7614fde3 100644
--- a/tests/markups/valid-17.expected
+++ b/tests/markups/valid-17.expected
@@ -4,7 +4,7 @@ test
---
range 0 4
-[0,4]show=3
+0 4 show 3
range 4 2147483647
diff --git a/tests/markups/valid-18.expected b/tests/markups/valid-18.expected
index 6f372b15..78731074 100644
--- a/tests/markups/valid-18.expected
+++ b/tests/markups/valid-18.expected
@@ -4,17 +4,17 @@ Lots of attrs
---
range 0 13
-[0,13]font-desc=Sans Italic 12
-[0,13]foreground=#0000ffff0000
-[0,13]background=#f0f0f0f0f0f0
-[0,13]underline=2
-[0,13]underline-color=#ffff00000000
-[0,13]gravity=0
-[0,13]gravity-hint=1
-[0,13]strikethrough=1
-[0,13]strikethrough-color=#00000000ffff
-[0,13]fallback=0
-[0,13]language=de
+0 13 font-desc "Sans Italic 12"
+0 13 foreground #0000ffff0000
+0 13 background #f0f0f0f0f0f0
+0 13 underline double
+0 13 underline-color #ffff00000000
+0 13 gravity south
+0 13 gravity-hint strong
+0 13 strikethrough true
+0 13 strikethrough-color #00000000ffff
+0 13 fallback false
+0 13 language de
range 13 2147483647
diff --git a/tests/markups/valid-19.expected b/tests/markups/valid-19.expected
index ea561c9d..5b84133f 100644
--- a/tests/markups/valid-19.expected
+++ b/tests/markups/valid-19.expected
@@ -4,11 +4,11 @@ test
---
range 0 4
-[0,4]family=Times
-[0,4]weight=700
-[0,4]foreground=#ffff00000000
-[0,4]letter-spacing=1024
-[0,4]insert-hyphens=1
+0 4 family Times
+0 4 weight bold
+0 4 foreground #ffff00000000
+0 4 letter-spacing 1024
+0 4 insert-hyphens true
range 4 2147483647
diff --git a/tests/markups/valid-2.expected b/tests/markups/valid-2.expected
index c372666a..63da62d4 100644
--- a/tests/markups/valid-2.expected
+++ b/tests/markups/valid-2.expected
@@ -4,11 +4,11 @@ Blue text is cool!
---
range 0 9
-[0,9]scale=1.728000
-[0,9]foreground=#00000000ffff
+0 9 scale 1.728000
+0 9 foreground #00000000ffff
range 9 13
range 13 17
-[13,17]style=2
+13 17 style italic
range 17 2147483647
diff --git a/tests/markups/valid-20.expected b/tests/markups/valid-20.expected
index bd3ac65f..e00c9ba3 100644
--- a/tests/markups/valid-20.expected
+++ b/tests/markups/valid-20.expected
@@ -4,7 +4,7 @@ test
---
range 0 4
-[0,4]size=20480
+0 4 size 20480
range 4 2147483647
diff --git a/tests/markups/valid-21.expected b/tests/markups/valid-21.expected
index 9dc37dc1..55b9bfb1 100644
--- a/tests/markups/valid-21.expected
+++ b/tests/markups/valid-21.expected
@@ -4,7 +4,7 @@ test
---
range 0 4
-[0,4]rise=2560
+0 4 rise 2560
range 4 2147483647
diff --git a/tests/markups/valid-22.expected b/tests/markups/valid-22.expected
index 194c1960..cb4ae998 100644
--- a/tests/markups/valid-22.expected
+++ b/tests/markups/valid-22.expected
@@ -4,7 +4,7 @@ test
---
range 0 4
-[0,4]rise=-5000
+0 4 rise -5000
range 4 2147483647
diff --git a/tests/markups/valid-23.expected b/tests/markups/valid-23.expected
index 43621301..296faf0a 100644
--- a/tests/markups/valid-23.expected
+++ b/tests/markups/valid-23.expected
@@ -4,10 +4,10 @@ test test
---
range 0 5
-[0,9]font-desc=Cantarell 11
+0 9 font-desc "Cantarell 11"
range 5 9
-[0,9]font-desc=Cantarell 11
-[5,9]scale=2.000000
+0 9 font-desc "Cantarell 11"
+5 9 scale 2.000000
range 9 2147483647
diff --git a/tests/markups/valid-24.expected b/tests/markups/valid-24.expected
index 06eb6e0c..5e966bdc 100644
--- a/tests/markups/valid-24.expected
+++ b/tests/markups/valid-24.expected
@@ -4,10 +4,10 @@ straße up, up and away
---
range 0 7
-[0,7]text-transform=2
+0 7 text-transform uppercase
range 7 8
range 8 23
-[8,23]text-transform=3
+8 23 text-transform capitalize
range 23 2147483647
diff --git a/tests/markups/valid-3.expected b/tests/markups/valid-3.expected
index 3b69c218..bfc14213 100644
--- a/tests/markups/valid-3.expected
+++ b/tests/markups/valid-3.expected
@@ -4,18 +4,18 @@ Lots of attrs
---
range 0 13
-[0,13]font-desc=Sans Italic 12
-[0,13]foreground=#0000ffff0000
-[0,13]background=#f0f0f0f0f0f0
-[0,13]underline=2
-[0,13]underline-color=#ffff00000000
-[0,13]gravity=0
-[0,13]gravity-hint=1
-[0,13]strikethrough=1
-[0,13]strikethrough-color=#00000000ffff
-[0,13]fallback=0
-[0,13]language=de
-[0,13]allow-breaks=1
+0 13 font-desc "Sans Italic 12"
+0 13 foreground #0000ffff0000
+0 13 background #f0f0f0f0f0f0
+0 13 underline double
+0 13 underline-color #ffff00000000
+0 13 gravity south
+0 13 gravity-hint strong
+0 13 strikethrough true
+0 13 strikethrough-color #00000000ffff
+0 13 fallback false
+0 13 language de
+0 13 allow-breaks true
range 13 2147483647
diff --git a/tests/markups/valid-4.expected b/tests/markups/valid-4.expected
index a9e16728..615e2adc 100644
--- a/tests/markups/valid-4.expected
+++ b/tests/markups/valid-4.expected
@@ -4,37 +4,37 @@ bold big italic strikethroughsub smallsup tt underline
---
range 0 5
-[0,15]weight=700
+0 15 weight bold
range 5 8
-[0,15]weight=700
-[5,8]scale=1.200000
+0 15 weight bold
+5 8 scale 1.200000
range 8 9
-[0,15]weight=700
+0 15 weight bold
range 9 15
-[0,15]weight=700
-[9,15]style=2
+0 15 weight bold
+9 15 style italic
range 15 16
range 16 29
-[16,41]strikethrough=1
+16 41 strikethrough true
range 29 32
-[16,41]strikethrough=1
-[29,32]font-scale=2
-[29,32]baseline-shift=2
+16 41 strikethrough true
+29 32 font-scale subscript
+29 32 baseline-shift subscript
range 32 33
-[16,41]strikethrough=1
+16 41 strikethrough true
range 33 38
-[16,41]strikethrough=1
-[33,38]scale=0.833333
+16 41 strikethrough true
+33 38 scale 0.833333
range 38 41
-[16,41]strikethrough=1
-[38,41]font-scale=1
-[38,41]baseline-shift=1
+16 41 strikethrough true
+38 41 font-scale superscript
+38 41 baseline-shift superscript
range 41 42
range 42 45
-[42,54]family=Monospace
+42 54 family Monospace
range 45 54
-[42,54]family=Monospace
-[45,54]underline=1
+42 54 family Monospace
+45 54 underline single
range 54 2147483647
diff --git a/tests/markups/valid-5.expected b/tests/markups/valid-5.expected
index a26c4f71..d6e17249 100644
--- a/tests/markups/valid-5.expected
+++ b/tests/markups/valid-5.expected
@@ -7,16 +7,16 @@ Text
---
range 0 4
-[0,4]foreground=#222233334444
+0 4 foreground #222233334444
range 4 5
range 5 9
-[5,9]foreground=#222233334444
+5 9 foreground #222233334444
range 9 10
range 10 14
-[10,14]foreground=#222233334444
+10 14 foreground #222233334444
range 14 15
range 15 19
-[15,19]foreground=#222233334444
+15 19 foreground #222233334444
range 19 2147483647
diff --git a/tests/markups/valid-6.expected b/tests/markups/valid-6.expected
index 40807607..4f1920ad 100644
--- a/tests/markups/valid-6.expected
+++ b/tests/markups/valid-6.expected
@@ -7,19 +7,19 @@ Text
---
range 0 4
-[0,4]foreground=#222233334444
-[0,4]foreground-alpha=21845
+0 4 foreground #222233334444
+0 4 foreground-alpha 21845
range 4 5
range 5 9
-[5,9]foreground=#222233334444
-[5,9]foreground-alpha=21845
+5 9 foreground #222233334444
+5 9 foreground-alpha 21845
range 9 10
range 10 14
-[10,14]foreground=#222233334444
+10 14 foreground #222233334444
range 14 15
range 15 19
-[15,19]foreground=#222233334444
-[15,19]foreground-alpha=21845
+15 19 foreground #222233334444
+15 19 foreground-alpha 21845
range 19 2147483647
diff --git a/tests/markups/valid-7.expected b/tests/markups/valid-7.expected
index 0658ab27..71ba77a9 100644
--- a/tests/markups/valid-7.expected
+++ b/tests/markups/valid-7.expected
@@ -5,10 +5,10 @@ Text
---
range 0 4
-[0,4]underline-color=#222233334444
+0 4 underline-color #222233334444
range 4 5
range 5 9
-[5,9]strikethrough-color=#222233334444
+5 9 strikethrough-color #222233334444
range 9 2147483647
diff --git a/tests/markups/valid-8.expected b/tests/markups/valid-8.expected
index 79a0f01d..89310b78 100644
--- a/tests/markups/valid-8.expected
+++ b/tests/markups/valid-8.expected
@@ -12,54 +12,54 @@ Text
---
range 0 4
-[0,4]scale=0.578704
-[0,4]variant=0
-[0,4]stretch=0
-[0,4]foreground=#00000000ffff
-[0,4]foreground-alpha=65535
+0 4 scale 0.578704
+0 4 variant normal
+0 4 stretch ultra-condensed
+0 4 foreground #00000000ffff
+0 4 foreground-alpha 65535
range 4 5
range 5 9
-[5,9]scale=0.694444
-[5,9]variant=1
-[5,9]stretch=1
-[5,9]foreground=#00000000ffff
-[5,9]foreground-alpha=32767
+5 9 scale 0.694444
+5 9 variant small-caps
+5 9 stretch extra-condensed
+5 9 foreground #00000000ffff
+5 9 foreground-alpha 32767
range 9 10
range 10 14
-[10,14]scale=0.833333
-[10,14]stretch=2
-[10,14]background=#00000000ffff
-[10,14]background-alpha=1
+10 14 scale 0.833333
+10 14 stretch condensed
+10 14 background #00000000ffff
+10 14 background-alpha 1
range 14 15
range 15 19
-[15,19]scale=1.000000
-[15,19]stretch=3
-[15,19]background=#00000000ffff
-[15,19]background-alpha=21626
+15 19 scale 1.000000
+15 19 stretch semi-condensed
+15 19 background #00000000ffff
+15 19 background-alpha 21626
range 19 20
range 20 24
-[20,24]scale=1.200000
-[20,24]stretch=4
-[20,24]background=#00000000ffff
-[20,24]background-alpha=21626
+20 24 scale 1.200000
+20 24 stretch normal
+20 24 background #00000000ffff
+20 24 background-alpha 21626
range 24 25
range 25 29
-[25,29]scale=1.440000
-[25,29]stretch=5
-[25,29]background=#00000000ffff
-[25,29]background-alpha=43690
+25 29 scale 1.440000
+25 29 stretch semi-expanded
+25 29 background #00000000ffff
+25 29 background-alpha 43690
range 29 30
range 30 34
-[30,34]scale=1.728000
-[30,34]stretch=6
+30 34 scale 1.728000
+30 34 stretch expanded
range 34 35
range 35 39
-[35,39]scale=1.728000
-[35,39]stretch=7
+35 39 scale 1.728000
+35 39 stretch extra-expanded
range 39 40
range 40 44
-[40,44]scale=1.728000
-[40,44]stretch=8
+40 44 scale 1.728000
+40 44 stretch ultra-expanded
range 44 2147483647
diff --git a/tests/markups/valid-9.expected b/tests/markups/valid-9.expected
index 71c370b2..cec75f68 100644
--- a/tests/markups/valid-9.expected
+++ b/tests/markups/valid-9.expected
@@ -4,7 +4,7 @@ Blue text
---
range 0 9
-[0,9]font-features=kern 0, dlig, lnum 1, -pnum
+0 9 font-features "kern 0, dlig, lnum 1, -pnum"
range 9 2147483647
diff --git a/tests/meson.build b/tests/meson.build
index b5eda3e7..00741a14 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -53,6 +53,7 @@ if cairo_dep.found()
[ 'cxx-test', [ 'cxx-test.cpp' ], [ libpangocairo_dep, gobject_dep, harfbuzz_dep ] ],
[ 'test-harfbuzz', [ 'test-harfbuzz.c' ], [ libpangocairo_dep, gobject_dep, harfbuzz_dep ] ],
[ 'test-break', [ 'test-break.c', 'test-common.c', 'validate-log-attrs.c' ], [libpangocairo_dep, glib_dep, harfbuzz_dep ] ],
+ [ 'testserialize', [ 'testserialize.c' ], [ libpangocairo_dep ] ],
]
if host_system != 'darwin'
diff --git a/tests/test-common.c b/tests/test-common.c
index b59ca4a0..3821a450 100644
--- a/tests/test-common.c
+++ b/tests/test-common.c
@@ -104,58 +104,14 @@ file_has_prefix (const char *filename,
void
print_attribute (PangoAttribute *attr, GString *string)
{
- GEnumClass *class;
- GEnumValue *value;
- PangoAttrString *str;
- PangoAttrLanguage *lang;
- PangoAttrInt *integer;
- PangoAttrFloat *flt;
- PangoAttrFontDesc *font;
- PangoAttrColor *color;
- PangoAttrShape *shape;
- PangoAttrSize *size;
- PangoAttrFontFeatures *features;
-
- g_string_append_printf (string, "[%d,%d]", attr->start_index, attr->end_index);
-
- class = g_type_class_ref (pango_attr_type_get_type ());
- value = g_enum_get_value (class, attr->klass->type);
- g_string_append_printf (string, "%s=", value->value_nick);
- g_type_class_unref (class);
-
- if ((str = pango_attribute_as_string (attr)) != NULL)
- g_string_append (string, str->value);
- else if ((lang = pango_attribute_as_language (attr)) != NULL)
- g_string_append (string, pango_language_to_string (lang->value));
- else if ((integer = pango_attribute_as_int (attr)) != NULL)
- g_string_append_printf (string, "%d", integer->value);
- else if ((flt = pango_attribute_as_float (attr)) != NULL)
- {
- char val[20];
-
- g_ascii_formatd (val, 20, "%f", flt->value);
- g_string_append (string, val);
- }
- else if ((font = pango_attribute_as_font_desc (attr)) != NULL)
- {
- char *text = pango_font_description_to_string (font->desc);
- g_string_append (string, text);
- g_free (text);
- }
- else if ((color = pango_attribute_as_color (attr)) != NULL)
- {
- char *text = pango_color_to_string (&color->color);
- g_string_append (string, text);
- g_free (text);
- }
- else if ((shape = pango_attribute_as_shape (attr)) != NULL)
- g_string_append_printf (string, "shape");
- else if ((size = pango_attribute_as_size (attr)) != NULL)
- g_string_append_printf (string, "%d", size->size);
- else if ((features = pango_attribute_as_font_features (attr)) != NULL)
- g_string_append_printf (string, "%s", features->features);
- else
- g_assert_not_reached ();
+ PangoAttrList *l = pango_attr_list_new ();
+ char *s;
+
+ pango_attr_list_insert (l, pango_attribute_copy (attr));
+ s = pango_attr_list_to_string (l);
+ g_string_append (string, s);
+ g_free (s);
+ pango_attr_list_unref (l);
}
void
@@ -200,242 +156,6 @@ print_attributes (GSList *attrs, GString *string)
}
}
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-
-PangoAttribute *
-attribute_from_string (const char *string)
-{
- const char *s;
- char *p;
- PangoAttribute *attr;
- long long start, end;
- GEnumClass *class;
- int i;
- PangoColor color;
- int val;
-
- s = string;
- g_assert (*s == '[');
-
- s++;
- start = strtoll (s, &p, 10);
- g_assert (p > s);
- g_assert (*p == ',');
- s = p + 1;
-
- g_assert (start >= 0);
-
- end = strtoll (s, &p, 10);
- g_assert (p > s);
- g_assert (*p == ']');
- s = p + 1;
-
- if (end == -1)
- end = G_MAXUINT;
-
- g_assert (start >= 0);
- g_assert (end >= 0);
-
- class = g_type_class_ref (pango_attr_type_get_type ());
-
- for (i = 0; i < class->n_values; i++)
- {
- if (g_str_has_prefix (s, class->values[i].value_nick))
- break;
- }
-
- g_assert (i < class->n_values);
-
- s += strlen (class->values[i].value_nick);
- g_assert (*s == '=');
- s++;
-
- switch (class->values[i].value)
- {
- case PANGO_ATTR_LANGUAGE:
- attr = pango_attr_language_new (pango_language_from_string (s));
- break;
- case PANGO_ATTR_FAMILY:
- attr = pango_attr_family_new (s);
- break;
- case PANGO_ATTR_FONT_FEATURES:
- attr = pango_attr_font_features_new (s);
- break;
- case PANGO_ATTR_STYLE:
- {
- if (!pango_parse_enum (PANGO_TYPE_STYLE, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_style_new (val);
- }
- break;
- case PANGO_ATTR_WEIGHT:
- {
- if (!pango_parse_enum (PANGO_TYPE_WEIGHT, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_weight_new (val);
- }
- break;
- case PANGO_ATTR_VARIANT:
- {
- if (!pango_parse_enum (PANGO_TYPE_VARIANT, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_variant_new (val);
- }
- break;
- case PANGO_ATTR_STRETCH:
- {
- if (!pango_parse_enum (PANGO_TYPE_STRETCH, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_stretch_new (val);
- }
- break;
- case PANGO_ATTR_SIZE:
- attr = pango_attr_size_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_ABSOLUTE_SIZE:
- attr = pango_attr_size_new_absolute (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_UNDERLINE:
- {
- if (!pango_parse_enum (PANGO_TYPE_UNDERLINE, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_underline_new (val);
- }
- break;
- case PANGO_ATTR_OVERLINE:
- {
- if (!pango_parse_enum (PANGO_TYPE_OVERLINE, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_overline_new (val);
- }
- break;
- case PANGO_ATTR_STRIKETHROUGH:
- attr = pango_attr_strikethrough_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_RISE:
- attr = pango_attr_rise_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_FALLBACK:
- attr = pango_attr_fallback_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_LETTER_SPACING:
- attr = pango_attr_letter_spacing_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_GRAVITY:
- {
- if (!pango_parse_enum (PANGO_TYPE_GRAVITY, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_gravity_new (val);
- }
- break;
- case PANGO_ATTR_GRAVITY_HINT:
- {
- if (!pango_parse_enum (PANGO_TYPE_GRAVITY_HINT, s, &val, FALSE, NULL))
- val = strtol (s, &p, 10);
- attr = pango_attr_gravity_hint_new (val);
- }
- break;
- case PANGO_ATTR_FOREGROUND_ALPHA:
- attr = pango_attr_foreground_alpha_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_BACKGROUND_ALPHA:
- attr = pango_attr_background_alpha_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_ALLOW_BREAKS:
- attr = pango_attr_allow_breaks_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_INSERT_HYPHENS:
- attr = pango_attr_insert_hyphens_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_SHOW:
- attr = pango_attr_show_new (strtol (s, &p, 10));
- break;
- case PANGO_ATTR_FONT_DESC:
- {
- PangoFontDescription *desc = pango_font_description_from_string (s);
- attr = pango_attr_font_desc_new (desc);
- pango_font_description_free (desc);
- }
- break;
- case PANGO_ATTR_FOREGROUND:
- {
- pango_color_parse (&color, s);
- attr = pango_attr_foreground_new (color.red, color.green, color.blue);
- }
- break;
- case PANGO_ATTR_BACKGROUND:
- {
- pango_color_parse (&color, s);
- attr = pango_attr_background_new (color.red, color.green, color.blue);
- }
- break;
- case PANGO_ATTR_UNDERLINE_COLOR:
- {
- pango_color_parse (&color, s);
- attr = pango_attr_underline_color_new (color.red, color.green, color.blue);
- }
- break;
- case PANGO_ATTR_OVERLINE_COLOR:
- {
- pango_color_parse (&color, s);
- attr = pango_attr_overline_color_new (color.red, color.green, color.blue);
- }
- break;
- case PANGO_ATTR_STRIKETHROUGH_COLOR:
- {
- pango_color_parse (&color, s);
- attr = pango_attr_strikethrough_color_new (color.red, color.green, color.blue);
- }
- break;
- case PANGO_ATTR_SHAPE:
- {
- PangoRectangle rect = { 0, };
- attr = pango_attr_shape_new (&rect, &rect);
- }
- break;
- case PANGO_ATTR_SCALE:
- attr = pango_attr_scale_new (strtod (s, &p));
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- g_type_class_unref (class);
-
- attr->start_index = start;
- attr->end_index = end;
-
- return attr;
-}
-
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-PangoAttrList *
-attributes_from_string (const char *string)
-{
- PangoAttrList *attrs;
- char **lines;
-
- attrs = pango_attr_list_new ();
-
- lines = g_strsplit (string, "\n", 0);
- for (int i = 0; lines[i]; i++)
- {
- PangoAttribute *attr;
-
- if (lines[i][0] == '\0')
- continue;
-
- attr = attribute_from_string (lines[i]);
- g_assert (attr);
- pango_attr_list_insert (attrs, attr);
- }
- g_strfreev (lines);
-
- return attrs;
-}
-
const char *
get_script_name (GUnicodeScript s)
{
diff --git a/tests/test-common.h b/tests/test-common.h
index e3f46afe..86320236 100644
--- a/tests/test-common.h
+++ b/tests/test-common.h
@@ -19,12 +19,6 @@ void print_attributes (GSList *attrs,
void print_attr_list (PangoAttrList *attrs,
GString *string);
-PangoAttribute *
-attribute_from_string (const char *string);
-
-PangoAttrList *
-attributes_from_string (const char *string);
-
const char *get_script_name (GUnicodeScript s);
diff --git a/tests/testattributes.c b/tests/testattributes.c
index b9dcc1b3..cd70edc8 100644
--- a/tests/testattributes.c
+++ b/tests/testattributes.c
@@ -20,7 +20,6 @@
*/
#include <pango/pango.h>
-#include "test-common.h"
static void
test_copy (PangoAttribute *attr)
@@ -217,17 +216,25 @@ static void
assert_attributes (GSList *attrs,
const char *expected)
{
- GString *s;
+ PangoAttrList *list2;
+ GSList *attrs2, *l, *l2;
- s = g_string_new ("");
- print_attributes (attrs, s);
- if (strcmp (s->str, expected) != 0)
+ list2 = pango_attr_list_from_string (expected);
+ attrs2 = pango_attr_list_get_attributes (list2);
+
+ if (g_slist_length (attrs) != g_slist_length (attrs2))
+ g_assert_not_reached ();
+
+ for (l = attrs, l2 = attrs2; l; l = l->next, l2 = l2->next)
{
- g_print ("-----\nattribute list mismatch\nexpected:\n%s\n-----\nreceived:\n%s\n-----\n",
- expected, s->str);
- g_assert_not_reached ();
+ PangoAttribute *a = l->data;
+ PangoAttribute *a2 = l2->data;
+ if (!pango_attribute_equal (a, a2))
+ g_assert_not_reached ();
}
- g_string_free (s, TRUE);
+
+ g_slist_free_full (attrs2, (GDestroyNotify)pango_attribute_destroy);
+ pango_attr_list_unref (list2);
}
static void
@@ -236,15 +243,13 @@ assert_attr_list (PangoAttrList *list,
{
PangoAttrList *list2;
- list2 = attributes_from_string (expected);
+ list2 = pango_attr_list_from_string (expected);
if (!pango_attr_list_equal (list, list2))
{
- GString *s = g_string_new ("");
-
- print_attr_list (list, s);
- g_print ("-----\nattribute list mismatch\nexpected:\n%s-----\nreceived:\n%s-----\n",
- expected, s->str);
- g_string_free (s, TRUE);
+ char *s = pango_attr_list_to_string (list);
+ g_print ("-----\nattribute list mismatch\nexpected:\n%s\n-----\nreceived:\n%s\n-----\n",
+ expected, s);
+ g_free (s);
g_assert_not_reached ();
}
@@ -262,6 +267,25 @@ assert_attr_iterator (PangoAttrIterator *iter,
g_slist_free_full (attrs, (GDestroyNotify)pango_attribute_destroy);
}
+static PangoAttribute *
+attribute_from_string (const char *str)
+{
+ PangoAttrList *list;
+ GSList *attrs;
+ PangoAttribute *attr;
+
+ list = pango_attr_list_from_string (str);
+ attrs = pango_attr_list_get_attributes (list);
+ g_assert_true (attrs->next == NULL);
+
+ attr = attrs->data;
+
+ g_slist_free (attrs);
+ pango_attr_list_unref (list);
+
+ return attr;
+}
+
static void
test_list (void)
{
@@ -277,33 +301,33 @@ test_list (void)
attr = pango_attr_size_new (30);
pango_attr_list_insert (list, attr);
- list2 = attributes_from_string ("[0,-1]size=10\n"
- "[0,-1]size=20\n"
- "[0,-1]size=30\n");
+ list2 = pango_attr_list_from_string ("0 -1 size 10\n"
+ "0 -1 size 20\n"
+ "0 -1 size 30\n");
g_assert_true (pango_attr_list_equal (list, list2));
pango_attr_list_unref (list2);
- assert_attr_list (list, "[0,-1]size=10\n"
- "[0,-1]size=20\n"
- "[0,-1]size=30\n");
+ assert_attr_list (list, "0 -1 size 10\n"
+ "0 -1 size 20\n"
+ "0 -1 size 30");
pango_attr_list_unref (list);
list = pango_attr_list_new ();
/* test that insertion respects start_index */
- attr = attribute_from_string ("[0,-1]size=10");
+ attr = attribute_from_string ("0 -1 size 10");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,20]size=20");
+ attr = attribute_from_string ("10 20 size 20");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[0,-1]size=30");
+ attr = attribute_from_string ("0 -1 size 30");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,40]size=40");
+ attr = attribute_from_string (" 10 40 size 40");
pango_attr_list_insert_before (list, attr);
- assert_attr_list (list, "[0,-1]size=10\n"
- "[0,-1]size=30\n"
- "[10,40]size=40\n"
- "[10,20]size=20\n");
+ assert_attr_list (list, "0 -1 size 10\n"
+ "0 -1 size 30\n"
+ "10 40 size 40\n"
+ "10 20 size 20");
pango_attr_list_unref (list);
}
@@ -313,48 +337,48 @@ test_list_change (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,10]size=10\n"
- "[0,30]weight=700\n"
- "[20,30]size=20\n");
+ list = pango_attr_list_from_string (" 0 10 size 10\n"
+ " 0 30 weight 700\n"
+ " 20 30 size 20\n");
/* no-op */
- attr = attribute_from_string ("[10,10]variant=small-caps");
+ attr = attribute_from_string ("10 10 variant small-caps");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]size=10\n"
- "[0,30]weight=700\n"
- "[20,30]size=20\n");
+ assert_attr_list (list, "0 10 size 10\n"
+ "0 30 weight bold\n"
+ "20 30 size 20");
/* simple insertion with pango_attr_list_change */
- attr = attribute_from_string ("[10,20]variant=small-caps");
+ attr = attribute_from_string ("10 20 variant small-caps");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]size=10\n"
- "[0,30]weight=700\n"
- "[10,20]variant=1\n"
- "[20,30]size=20\n");
+ assert_attr_list (list, "0 10 size 10\n"
+ "0 30 weight bold\n"
+ "10 20 variant small-caps\n"
+ "20 30 size 20");
/* insertion with splitting */
- attr = attribute_from_string ("[15,20]weight=light");
+ attr = attribute_from_string ("15 20 weight light");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]size=10\n"
- "[0,15]weight=700\n"
- "[10,20]variant=1\n"
- "[15,20]weight=300\n"
- "[20,30]size=20\n"
- "[20,30]weight=700\n");
+ assert_attr_list (list, "0 10 size 10\n"
+ "0 15 weight bold\n"
+ "10 20 variant small-caps\n"
+ "15 20 weight light\n"
+ "20 30 size 20\n"
+ "20 30 weight bold");
/* insertion with joining */
- attr = attribute_from_string ("[5,20]size=20");
+ attr = attribute_from_string ("5 20 size 20");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,5]size=10\n"
- "[0,15]weight=700\n"
- "[5,30]size=20\n"
- "[10,20]variant=1\n"
- "[15,20]weight=300\n"
- "[20,30]weight=700\n");
+ assert_attr_list (list, "0 5 size 10\n"
+ "0 15 weight bold\n"
+ "5 30 size 20\n"
+ "10 20 variant small-caps\n"
+ "15 20 weight light\n"
+ "20 30 weight bold");
pango_attr_list_unref (list);
}
@@ -366,15 +390,15 @@ test_list_change2 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]style=italic\n"
- "[3,4]style=normal\n"
- "[4,18]style=italic\n");
+ list = pango_attr_list_from_string ("0 3 style italic\n"
+ "3 4 style normal\n"
+ "4 18 style italic\n");
/* insertion with joining */
- attr = attribute_from_string ("[0,18]style=normal");
+ attr = attribute_from_string ("0 18 style normal");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,18]style=normal\n");
+ assert_attr_list (list, "0 18 style normal");
pango_attr_list_unref (list);
}
@@ -385,17 +409,17 @@ test_list_change3 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]style=italic\n"
- "[3,4]style=normal\n"
- "[4,18]style=italic\n");
+ list = pango_attr_list_from_string ("0 3 style italic\n"
+ "3 4 style normal\n"
+ "4 18 style italic\n");
/* insertion with joining */
- attr = attribute_from_string ("[1,1]style=normal");
+ attr = attribute_from_string ("1 1 style normal");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]style=italic\n"
- "[3,4]style=normal\n"
- "[4,18]style=italic\n");
+ assert_attr_list (list, "0 3 style italic\n"
+ "3 4 style normal\n"
+ "4 18 style italic");
pango_attr_list_unref (list);
}
@@ -409,10 +433,10 @@ test_list_change4 (void)
list = pango_attr_list_new ();
/* insertion with joining */
- attr = attribute_from_string ("[0,10]style=normal");
+ attr = attribute_from_string ("0 10 style normal");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]style=normal");
+ assert_attr_list (list, "0 10 style normal");
pango_attr_list_unref (list);
}
@@ -423,20 +447,23 @@ test_list_change5 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n");
/* insertion with joining */
- attr = attribute_from_string ("[5,15]style=italic");
+ attr = attribute_from_string ("5 15 style italic");
+ g_assert (attr->start_index == 5);
+ g_assert (attr->end_index == 15);
+ g_assert (((PangoAttrInt *)attr)->value == PANGO_STYLE_ITALIC);
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[5,15]style=italic\n"
- "[15,20]style=normal\n"
- "[15,18]fallback=false");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 4 style normal\n"
+ "5 15 style italic\n"
+ "15 20 style normal\n"
+ "15 18 fallback false");
pango_attr_list_unref (list);
}
@@ -447,18 +474,18 @@ test_list_change6 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n");
/* insertion with joining */
- attr = attribute_from_string ("[3,10]style=normal");
+ attr = attribute_from_string ("3 10 style normal");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,20]style=normal\n"
- "[15,18]fallback=false");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 20 style normal\n"
+ "15 18 fallback false");
pango_attr_list_unref (list);
}
@@ -469,19 +496,19 @@ test_list_change7 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n");
/* insertion with joining */
- attr = attribute_from_string ("[3,4]style=normal");
+ attr = attribute_from_string ("3 4 style normal");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false");
pango_attr_list_unref (list);
}
@@ -492,20 +519,20 @@ test_list_change8 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n");
/* insertion with joining */
- attr = attribute_from_string ("[3,11]style=italic");
+ attr = attribute_from_string ("3 11 style italic");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,3]style=normal\n"
- "[3,11]style=italic\n"
- "[11,20]style=normal\n"
- "[15,18]fallback=false");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 3 style normal\n"
+ "3 11 style italic\n"
+ "11 20 style normal\n"
+ "15 18 fallback false");
pango_attr_list_unref (list);
}
@@ -516,20 +543,20 @@ test_list_change9 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n");
/* insertion with joining */
- attr = attribute_from_string ("[2,3]style=italic");
+ attr = attribute_from_string ("2 3 style italic");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,3]style=italic\n"
- "[3,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 3 style italic\n"
+ "3 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false");
pango_attr_list_unref (list);
}
@@ -540,20 +567,20 @@ test_list_change10 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n");
/* insertion with joining */
- attr = attribute_from_string ("[3,4]style=italic");
+ attr = attribute_from_string ("3 4 style italic");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,3]style=normal\n"
- "[3,4]style=italic\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 3 style normal\n"
+ "3 4 style italic\n"
+ "10 20 style normal\n"
+ "15 18 fallback false");
pango_attr_list_unref (list);
}
@@ -564,22 +591,22 @@ test_list_change11 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[3,5]fallback=false\n"
- "[10,20]style=italic\n"
- "[15,18]fallback=false\n"
- "[22,30]style=italic\n");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "3 5 fallback false\n"
+ "10 20 style italic\n"
+ "15 18 fallback false\n"
+ "22 30 style italic\n");
/* insertion with joining */
- attr = attribute_from_string ("[3,22]style=italic");
+ attr = attribute_from_string ("3 22 style italic");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,3]style=normal\n"
- "[3,30]style=italic\n"
- "[3,5]fallback=false\n"
- "[15,18]fallback=false\n");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 3 style normal\n"
+ "3 30 style italic\n"
+ "3 5 fallback false\n"
+ "15 18 fallback false\n");
pango_attr_list_unref (list);
}
@@ -590,25 +617,25 @@ test_list_change12 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,3]weight=800\n"
- "[2,4]style=normal\n"
- "[3,5]fallback=false\n"
- "[10,20]style=normal\n"
- "[15,18]fallback=false\n"
- "[20,30]style=oblique\n"
- "[21,22]fallback=false");
+ list = pango_attr_list_from_string ("0 3 weight 800\n"
+ "2 4 style normal\n"
+ "3 5 fallback false\n"
+ "10 20 style normal\n"
+ "15 18 fallback false\n"
+ "20 30 style oblique\n"
+ "21 22 fallback false");
/* insertion with joining */
- attr = attribute_from_string ("[3,22]style=italic");
+ attr = attribute_from_string ("3 22 style italic");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,3]weight=800\n"
- "[2,3]style=normal\n"
- "[3,22]style=italic\n"
- "[3,5]fallback=false\n"
- "[15,18]fallback=false\n"
- "[21,22]fallback=false\n"
- "[22,30]style=oblique");
+ assert_attr_list (list, "0 3 weight ultrabold\n"
+ "2 3 style normal\n"
+ "3 22 style italic\n"
+ "3 5 fallback false\n"
+ "15 18 fallback false\n"
+ "21 22 fallback false\n"
+ "22 30 style oblique");
pango_attr_list_unref (list);
}
@@ -620,18 +647,18 @@ test_list_splice (void)
PangoAttrList *list;
PangoAttrList *other;
- base = attributes_from_string ("[0,-1]size=10\n"
- "[10,15]weight=700\n"
- "[20,30]variant=1\n");
+ base = pango_attr_list_from_string ("0 -1 size 10\n"
+ "10 15 weight 700\n"
+ "20 30 variant 1\n");
/* splice in an empty list */
list = pango_attr_list_copy (base);
other = pango_attr_list_new ();
pango_attr_list_splice (list, other, 11, 5);
- assert_attr_list (list, "[0,-1]size=10\n"
- "[10,20]weight=700\n"
- "[25,35]variant=1\n");
+ assert_attr_list (list, "0 -1 size 10\n"
+ "10 20 weight bold\n"
+ "25 35 variant small-caps\n");
pango_attr_list_unref (list);
pango_attr_list_unref (other);
@@ -639,17 +666,17 @@ test_list_splice (void)
/* splice in some attributes */
list = pango_attr_list_copy (base);
- other = attributes_from_string ("[0,3]size=20\n"
- "[2,4]stretch=2\n");
+ other = pango_attr_list_from_string ("0 3 size 20\n"
+ "2 4 stretch 2\n");
pango_attr_list_splice (list, other, 11, 5);
- assert_attr_list (list, "[0,11]size=10\n"
- "[10,20]weight=700\n"
- "[11,14]size=20\n"
- "[13,15]stretch=2\n"
- "[14,-1]size=10\n"
- "[25,35]variant=1\n");
+ assert_attr_list (list, "0 11 size 10\n"
+ "10 20 weight bold\n"
+ "11 14 size 20\n"
+ "13 15 stretch condensed\n"
+ "14 -1 size 10\n"
+ "25 35 variant small-caps\n");
pango_attr_list_unref (list);
pango_attr_list_unref (other);
@@ -672,19 +699,19 @@ test_list_splice2 (void)
g_assert_null (pango_attr_list_get_attributes (list));
- attr = attribute_from_string ("[0,-1]size=10");
+ attr = attribute_from_string ("0 -1 size 10");
pango_attr_list_insert (other, attr);
pango_attr_list_splice (list, other, 11, 5);
- assert_attr_list (list, "[11,16]size=10\n");
+ assert_attr_list (list, "11 16 size 10\n");
pango_attr_list_unref (other);
other = pango_attr_list_new ();
pango_attr_list_splice (list, other, 11, 5);
- assert_attr_list (list, "[11,21]size=10\n");
+ assert_attr_list (list, "11 21 size 10\n");
pango_attr_list_unref (other);
pango_attr_list_unref (list);
@@ -697,13 +724,13 @@ test_list_splice3 (void)
PangoAttrList *list;
PangoAttrList *other;
- list = attributes_from_string ("[10,30]variant=1\n");
- other = attributes_from_string ("[0,-1]weight=700\n");
+ list = pango_attr_list_from_string ("10 30 variant 1\n");
+ other = pango_attr_list_from_string ("0 -1 weight 700\n");
pango_attr_list_splice (list, other, 20, 5);
- assert_attr_list (list, "[10,35]variant=1\n"
- "[20,25]weight=700\n");
+ assert_attr_list (list, "10 35 variant small-caps\n"
+ "20 25 weight bold\n");
pango_attr_list_unref (other);
pango_attr_list_unref (list);
@@ -730,9 +757,9 @@ test_list_filter (void)
PangoAttrList *list;
PangoAttrList *out;
- list = attributes_from_string ("[0,-1]size=10\n"
- "[10,20]stretch=2\n"
- "[20,-1]weight=700\n");
+ list = pango_attr_list_from_string ("0 -1 size 10\n"
+ "10 20 stretch 2\n"
+ "20 -1 weight 700\n");
out = pango_attr_list_filter (list, never_true, NULL);
g_assert_null (out);
@@ -740,9 +767,9 @@ test_list_filter (void)
out = pango_attr_list_filter (list, just_weight, NULL);
g_assert_nonnull (out);
- assert_attr_list (list, "[0,-1]size=10\n"
- "[10,20]stretch=2\n");
- assert_attr_list (out, "[20,-1]weight=700\n");
+ assert_attr_list (list, "0 -1 size 10\n"
+ "10 20 stretch condensed\n");
+ assert_attr_list (out, "20 -1 weight bold\n");
pango_attr_list_unref (list);
pango_attr_list_unref (out);
@@ -767,11 +794,11 @@ test_iter (void)
pango_attr_list_unref (list);
list = pango_attr_list_new ();
- attr = attribute_from_string ("[0,-1]size=10");
+ attr = attribute_from_string ("0 -1 size 10");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,30]stretch=condensed");
+ attr = attribute_from_string ("10 30 stretch condensed");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[20,-1]weight=bold");
+ attr = attribute_from_string ("20 -1 weight bold");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -817,9 +844,9 @@ test_iter_get (void)
list = pango_attr_list_new ();
attr = pango_attr_size_new (10);
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,30]stretch=condensed");
+ attr = attribute_from_string ("10 30 stretch condensed");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[20,-1]weight=bold");
+ attr = attribute_from_string ("20 -1 weight bold");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -855,17 +882,17 @@ test_iter_get_font (void)
list = pango_attr_list_new ();
attr = pango_attr_size_new (10 * PANGO_SCALE);
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[0,-1]family=Times");
+ attr = attribute_from_string ("0 -1 family Times");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,30]stretch=condensed");
+ attr = attribute_from_string ("10 30 stretch condensed");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,20]absolute-size=10240");
+ attr = attribute_from_string ("10 20 absolute-size 10240");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,20]language=ja-JP");
+ attr = attribute_from_string ("10 20 language ja-JP");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[20,-1]rise=100");
+ attr = attribute_from_string ("20 -1 rise 100");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[20,-1]fallback=0");
+ attr = attribute_from_string ("20 -1 fallback 0");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
@@ -895,8 +922,8 @@ test_iter_get_font (void)
desc2 = pango_font_description_from_string ("Times Condensed 10");
g_assert_true (pango_font_description_equal (desc, desc2));
g_assert_null (lang);
- assert_attributes (attrs, "[20,-1]rise=100\n"
- "[20,-1]fallback=0\n");
+ assert_attributes (attrs, "20 -1 rise 100\n"
+ "20 -1 fallback false\n");
g_slist_free_full (attrs, (GDestroyNotify)pango_attribute_destroy);
pango_font_description_free (desc);
@@ -916,39 +943,39 @@ test_iter_get_attrs (void)
list = pango_attr_list_new ();
attr = pango_attr_size_new (10 * PANGO_SCALE);
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[0,-1]family=Times");
+ attr = attribute_from_string ("0 -1 family Times");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,30]stretch=condensed");
+ attr = attribute_from_string ("10 30 stretch condensed");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[10,20]language=ja-JP");
+ attr = attribute_from_string ("10 20 language ja-JP");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[20,-1]rise=100");
+ attr = attribute_from_string ("20 -1 rise 100");
pango_attr_list_insert (list, attr);
- attr = attribute_from_string ("[20,-1]fallback=0");
+ attr = attribute_from_string ("20 -1 fallback 0");
pango_attr_list_insert (list, attr);
iter = pango_attr_list_get_iterator (list);
- assert_attr_iterator (iter, "[0,-1]size=10240\n"
- "[0,-1]family=Times\n");
+ assert_attr_iterator (iter, "0 -1 size 10240\n"
+ "0 -1 family Times\n");
pango_attr_iterator_next (iter);
- assert_attr_iterator (iter, "[0,-1]size=10240\n"
- "[0,-1]family=Times\n"
- "[10,30]stretch=2\n"
- "[10,20]language=ja-jp\n");
+ assert_attr_iterator (iter, "0 -1 size 10240\n"
+ "0 -1 family Times\n"
+ "10 30 stretch 2\n"
+ "10 20 language ja-jp\n");
pango_attr_iterator_next (iter);
- assert_attr_iterator (iter, "[0,-1]size=10240\n"
- "[0,-1]family=Times\n"
- "[10,30]stretch=2\n"
- "[20,-1]rise=100\n"
- "[20,-1]fallback=0\n");
+ assert_attr_iterator (iter, "0 -1 size 10240\n"
+ "0 -1 family Times\n"
+ "10 30 stretch 2\n"
+ "20 -1 rise 100\n"
+ "20 -1 fallback 0\n");
pango_attr_iterator_next (iter);
- assert_attr_iterator (iter, "[0,-1]size=10240\n"
- "[0,-1]family=Times\n"
- "[20,-1]rise=100\n"
- "[20,-1]fallback=0\n");
+ assert_attr_iterator (iter, "0 -1 size 10240\n"
+ "0 -1 family Times\n"
+ "20 -1 rise 100\n"
+ "20 -1 fallback 0\n");
pango_attr_iterator_next (iter);
g_assert_null (pango_attr_iterator_get_attrs (iter));
@@ -962,18 +989,18 @@ test_list_update (void)
{
PangoAttrList *list;
- list = attributes_from_string ("[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
+ list = pango_attr_list_from_string ("0 200 rise 100\n"
+ "5 15 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback 0\n"
+ "30 60 stretch 2\n");
pango_attr_list_update (list, 8, 10, 20);
- assert_attr_list (list, "[0,210]rise=100\n"
- "[5,8]family=Times\n"
- "[28,110]fallback=0\n"
- "[40,70]stretch=2\n");
+ assert_attr_list (list, "0 210 rise 100\n"
+ "5 8 family Times\n"
+ "28 110 fallback false\n"
+ "40 70 stretch condensed\n");
pango_attr_list_unref (list);
}
@@ -998,11 +1025,11 @@ test_list_update3 (void)
{
PangoAttrList *list;
- list = attributes_from_string ("[5,4294967285]family=Times\n");
+ list = pango_attr_list_from_string ("5 4294967285 family Times\n");
pango_attr_list_update (list, 8, 10, 30);
- assert_attr_list (list, "[5,-1]family=Times\n");
+ assert_attr_list (list, "5 -1 family Times\n");
pango_attr_list_unref (list);
}
@@ -1021,14 +1048,14 @@ test_list_equal (void)
g_assert_true (pango_attr_list_equal (list1, list1));
g_assert_true (pango_attr_list_equal (list1, list2));
- attr = attribute_from_string ("[0,7]size=10240");
+ attr = attribute_from_string ("0 7 size 10240");
pango_attr_list_insert (list1, pango_attribute_copy (attr));
pango_attr_list_insert (list2, pango_attribute_copy (attr));
pango_attribute_destroy (attr);
g_assert_true (pango_attr_list_equal (list1, list2));
- attr = attribute_from_string ("[0,1]stretch=condensed");
+ attr = attribute_from_string ("0 1 stretch condensed");
pango_attr_list_insert (list1, pango_attribute_copy (attr));
g_assert_true (!pango_attr_list_equal (list1, list2));
@@ -1037,7 +1064,7 @@ test_list_equal (void)
pango_attribute_destroy (attr);
/* Same range as the first attribute */
- attr = attribute_from_string ("[0,7]size=30720");
+ attr = attribute_from_string ("0 7 size 30720");
pango_attr_list_insert (list2, pango_attribute_copy (attr));
g_assert_true (!pango_attr_list_equal (list1, list2));
pango_attr_list_insert (list1, pango_attribute_copy (attr));
@@ -1082,30 +1109,30 @@ test_insert (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
+ list = pango_attr_list_from_string ("0 200 rise 100\n"
+ "5 15 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback 0\n"
+ "30 60 stretch 2\n");
- attr = attribute_from_string ("[10,25]family=Times");
+ attr = attribute_from_string ("10 25 family Times");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,25]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
+ assert_attr_list (list, "0 200 rise 100\n"
+ "5 25 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback false\n"
+ "30 60 stretch condensed\n");
- attr = attribute_from_string ("[11,25]family=Futura");
+ attr = attribute_from_string ("11 25 family Futura");
pango_attr_list_insert (list, attr);
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,25]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[11,25]family=Futura\n"
- "[30,60]stretch=2\n");
+ assert_attr_list (list, "0 200 rise 100\n"
+ "5 25 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback false\n"
+ "11 25 family Futura\n"
+ "30 60 stretch condensed\n");
pango_attr_list_unref (list);
}
@@ -1116,23 +1143,23 @@ test_insert2 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[20,30]family=Times\n"
- "[30,40]family=Futura\n"
- "[30,60]stretch=2\n");
+ list = pango_attr_list_from_string ("0 200 rise 100\n"
+ "5 15 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback 0\n"
+ "20 30 family Times\n"
+ "30 40 family Futura\n"
+ "30 60 stretch 2\n");
- attr = attribute_from_string ("[10,35]family=Times");
+ attr = attribute_from_string ("10 35 family Times");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,35]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[35,40]family=Futura\n"
- "[30,60]stretch=2\n");
+ assert_attr_list (list, "0 200 rise 100\n"
+ "5 35 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback false\n"
+ "35 40 family Futura\n"
+ "30 60 stretch condensed\n");
pango_attr_list_unref (list);
}
@@ -1152,25 +1179,25 @@ test_merge (void)
PangoAttrList *list;
PangoAttrList *list2;
- list = attributes_from_string ("[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,11]size=10240\n"
- "[11,100]fallback=0\n"
- "[30,60]stretch=2\n");
+ list = pango_attr_list_from_string ("0 200 rise 100\n"
+ "5 15 family Times\n"
+ "10 11 size 10240\n"
+ "11 100 fallback 0\n"
+ "30 60 stretch 2\n");
- list2 = attributes_from_string ("[11,13]size=10240\n"
- "[13,15]size=11264\n"
- "[40,50]size=12288\n");
+ list2 = pango_attr_list_from_string ("11 13 size 10240\n"
+ "13 15 size 11264\n"
+ "40 50 size 12288\n");
pango_attr_list_filter (list2, attr_list_merge_filter, list);
- assert_attr_list (list, "[0,200]rise=100\n"
- "[5,15]family=Times\n"
- "[10,13]size=10240\n"
- "[11,100]fallback=0\n"
- "[13,15]size=11264\n"
- "[30,60]stretch=2\n"
- "[40,50]size=12288\n");
+ assert_attr_list (list, "0 200 rise 100\n"
+ "5 15 family Times\n"
+ "10 13 size 10240\n"
+ "11 100 fallback false\n"
+ "13 15 size 11264\n"
+ "30 60 stretch condensed\n"
+ "40 50 size 12288\n");
pango_attr_list_unref (list);
pango_attr_list_unref (list2);
@@ -1185,34 +1212,34 @@ test_merge2 (void)
PangoAttrList *list;
PangoAttribute *attr;
- list = attributes_from_string ("[0,10]underline=1\n"
- "[0,10]foreground=#00000000ffff\n");
+ list = pango_attr_list_from_string ("0 10 underline 1\n"
+ "0 10 foreground #00000000ffff\n");
- attr = attribute_from_string ("[2,3]foreground=#ffff00000000");
+ attr = attribute_from_string ("2 3 foreground #ffff00000000");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]underline=1\n"
- "[0,2]foreground=#00000000ffff\n"
- "[2,3]foreground=#ffff00000000\n"
- "[3,10]foreground=#00000000ffff\n");
+ assert_attr_list (list, "0 10 underline single\n"
+ "0 2 foreground #00000000ffff\n"
+ "2 3 foreground #ffff00000000\n"
+ "3 10 foreground #00000000ffff");
- attr = attribute_from_string ("[3,4]foreground=#0000ffff0000");
+ attr = attribute_from_string ("3 4 foreground #0000ffff0000");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]underline=1\n"
- "[0,2]foreground=#00000000ffff\n"
- "[2,3]foreground=#ffff00000000\n"
- "[3,4]foreground=#0000ffff0000\n"
- "[4,10]foreground=#00000000ffff\n");
+ assert_attr_list (list, "0 10 underline single\n"
+ "0 2 foreground #00000000ffff\n"
+ "2 3 foreground #ffff00000000\n"
+ "3 4 foreground #0000ffff0000\n"
+ "4 10 foreground #00000000ffff");
- attr = attribute_from_string ("[4,5]foreground=#00000000ffff");
+ attr = attribute_from_string ("4 5 foreground #00000000ffff");
pango_attr_list_change (list, attr);
- assert_attr_list (list, "[0,10]underline=1\n"
- "[0,2]foreground=#00000000ffff\n"
- "[2,3]foreground=#ffff00000000\n"
- "[3,4]foreground=#0000ffff0000\n"
- "[4,10]foreground=#00000000ffff\n");
+ assert_attr_list (list, "0 10 underline single\n"
+ "0 2 foreground #00000000ffff\n"
+ "2 3 foreground #ffff00000000\n"
+ "3 4 foreground #0000ffff0000\n"
+ "4 10 foreground #00000000ffff");
pango_attr_list_unref (list);
}
@@ -1229,25 +1256,25 @@ print_tags_for_attributes (PangoAttrIterator *iter,
attr = pango_attr_iterator_get (iter, PANGO_ATTR_RISE);
if (attr)
- g_string_append_printf (s, "[%d, %d]rise=%d\n",
+ g_string_append_printf (s, "%d %d rise %d\n",
attr->start_index, attr->end_index,
((PangoAttrInt*)attr)->value);
attr = pango_attr_iterator_get (iter, PANGO_ATTR_SIZE);
if (attr)
- g_string_append_printf (s, "[%d, %d]size=%d\n",
+ g_string_append_printf (s, "%d %d size %d\n",
attr->start_index, attr->end_index,
((PangoAttrInt*)attr)->value);
attr = pango_attr_iterator_get (iter, PANGO_ATTR_SCALE);
if (attr)
- g_string_append_printf (s, "[%d, %d]scale=%f\n",
+ g_string_append_printf (s, "%d %d scale %f\n",
attr->start_index, attr->end_index,
((PangoAttrFloat*)attr)->value);
attr = pango_attr_iterator_get (iter, PANGO_ATTR_ALLOW_BREAKS);
if (attr)
- g_string_append_printf (s, "[%d, %d]allow_breaks=%d\n",
+ g_string_append_printf (s, "%d %d allow_breaks %d\n",
attr->start_index, attr->end_index,
((PangoAttrInt*)attr)->value);
}
@@ -1284,24 +1311,24 @@ test_iter_epsilon_zero (void)
g_assert_cmpstr (s->str, ==,
"range: [0, 4]\n"
"range: [4, 5]\n"
- "[4, 5]rise=-6000\n"
- "[4, 5]scale=0.694444\n"
+ "4 5 rise -6000\n"
+ "4 5 scale 0.694444\n"
"range: [5, 12]\n"
"range: [12, 16]\n"
- "[12, 23]rise=8000\n"
- "[12, 23]scale=0.833333\n"
+ "12 23 rise 8000\n"
+ "12 23 scale 0.833333\n"
"range: [16, 20]\n"
- "[16, 23]rise=14000\n"
- "[16, 23]scale=0.694444\n"
+ "16 23 rise 14000\n"
+ "16 23 scale 0.694444\n"
"range: [20, 21]\n"
- "[20, 23]rise=20000\n"
- "[16, 23]scale=0.694444\n"
+ "20 23 rise 20000\n"
+ "16 23 scale 0.694444\n"
"range: [21, 22]\n"
- "[21, 23]rise=23000\n"
- "[16, 23]scale=0.694444\n"
+ "21 23 rise 23000\n"
+ "16 23 scale 0.694444\n"
"range: [22, 23]\n"
- "[22, 23]rise=26000\n"
- "[16, 23]scale=0.694444\n"
+ "22 23 rise 26000\n"
+ "16 23 scale 0.694444\n"
"range: [23, 2147483647]\n");
g_free (text);
diff --git a/tests/testserialize.c b/tests/testserialize.c
new file mode 100644
index 00000000..cc6c67bc
--- /dev/null
+++ b/tests/testserialize.c
@@ -0,0 +1,134 @@
+/* Pango
+ *
+ * Copyright (C) 2021 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include <glib.h>
+#include <pango/pangocairo.h>
+
+static void
+test_serialize_attr_list (void)
+{
+ const char *valid[] = {
+ "5 16 style italic",
+ "0 10 foreground red, 5 15 weight bold, 0 200 font-desc \"Sans Small-Caps 10\"",
+ "0 10 foreground red\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
+ " 0 10 fallback false,\n 5 15 weight semilight\n\n \n \n",
+ "0 100 font-desc \"Cantarell, Sans, Italic Ultra-Light 64\", 10 11 weight 100",
+ "0 -1 size 10",
+ "0 1 weight 700, 2 4 weight book",
+ "0 200 rise 100\n5 15 family Times\n10 11 size 10240\n11 100 fallback 0\n30 60 stretch 2\n",
+ ""
+ };
+ const char *roundtripped[] = {
+ "5 16 style italic",
+ "0 10 foreground #ffff00000000\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
+ "0 10 foreground #ffff00000000\n5 15 weight bold\n0 200 font-desc \"Sans Small-Caps 10\"",
+ "0 10 fallback false\n5 15 weight semilight",
+ "0 100 font-desc \"Cantarell,Sans Ultra-Light Italic 64\"\n10 11 weight thin",
+ "0 4294967295 size 10",
+ "0 1 weight bold\n2 4 weight book",
+ "0 200 rise 100\n5 15 family Times\n10 11 size 10240\n11 100 fallback false\n30 60 stretch condensed",
+ ""
+ };
+ const char *invalid[] = {
+ "not an attr list",
+ "0 -1 FOREGROUND xyz",
+ ",,bla.wewq",
+ };
+
+ for (int i = 0; i < G_N_ELEMENTS (valid); i++)
+ {
+ PangoAttrList *attrs;
+ char *str;
+
+ attrs = pango_attr_list_from_string (valid[i]);
+ g_assert_nonnull (attrs);
+ str = pango_attr_list_to_string (attrs);
+ g_assert_cmpstr (str, ==, roundtripped[i]);
+ g_free (str);
+ pango_attr_list_unref (attrs);
+ }
+
+ for (int i = 0; i < G_N_ELEMENTS (invalid); i++)
+ {
+ PangoAttrList *attrs;
+
+ attrs = pango_attr_list_from_string (invalid[i]);
+ g_assert_null (attrs);
+ }
+}
+
+static void
+test_serialize_tab_array (void)
+{
+ const char *valid[] = {
+ "0 10 100 200 400",
+ "0px 10px 100px 200px 400px",
+ " 0 10 ",
+ "20 10",
+ ""
+ };
+ const char *roundtripped[] = {
+ "0 10 100 200 400",
+ "0px 10px 100px 200px 400px",
+ "0 10",
+ "20 10",
+ ""
+ };
+ const char *invalid[] = {
+ "not a tabarray",
+ "-10\n-20",
+ "10ps 20pu",
+ "10, 20",
+ "10 20px 30",
+ };
+
+ for (int i = 0; i < G_N_ELEMENTS (valid); i++)
+ {
+ PangoTabArray *tabs;
+ char *str;
+
+ tabs = pango_tab_array_from_string (valid[i]);
+ g_assert_nonnull (tabs);
+ str = pango_tab_array_to_string (tabs);
+ g_assert_cmpstr (str, ==, roundtripped[i]);
+ g_free (str);
+ pango_tab_array_free (tabs);
+ }
+
+ for (int i = 0; i < G_N_ELEMENTS (invalid); i++)
+ {
+ PangoTabArray *tabs;
+
+ tabs = pango_tab_array_from_string (invalid[i]);
+ g_assert_null (tabs);
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/serialize/attr-list", test_serialize_attr_list);
+ g_test_add_func ("/serialize/tab-array", test_serialize_tab_array);
+
+ return g_test_run ();
+}