summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/serializer.c34
-rw-r--r--tests/layouts/valid-12.layout25
-rw-r--r--tests/layouts/valid-13.layout25
-rw-r--r--tests/testserialize.c17
4 files changed, 85 insertions, 16 deletions
diff --git a/pango/serializer.c b/pango/serializer.c
index 6e394a1c..372fbd8b 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -218,9 +218,15 @@ add_tab_array (JsonBuilder *builder,
json_builder_begin_array (builder);
for (int i = 0; i < pango_tab_array_get_size (tabs); i++)
{
+ PangoTabAlign align;
int pos;
- pango_tab_array_get_tab (tabs, i, NULL, &pos);
+ pango_tab_array_get_tab (tabs, i, &align, &pos);
+ json_builder_begin_object (builder);
+ json_builder_set_member_name (builder, "position");
json_builder_add_int_value (builder, pos);
+ json_builder_set_member_name (builder, "alignment");
+ add_enum_value (builder, PANGO_TYPE_TAB_ALIGN, align, FALSE);
+ json_builder_end_object (builder);
}
json_builder_end_array (builder);
@@ -1133,9 +1139,31 @@ json_to_tab_array (JsonReader *reader,
for (int i = 0; i < json_reader_count_elements (reader); i++)
{
int pos;
+ PangoTabAlign align;
+
json_reader_read_element (reader, i);
- pos = json_reader_get_int_value (reader);
- pango_tab_array_set_tab (tabs, i, PANGO_TAB_LEFT, pos);
+ if (json_reader_is_object (reader))
+ {
+ json_reader_read_member (reader, "position");
+ pos = json_reader_get_int_value (reader);
+ json_reader_end_member (reader);
+ json_reader_read_member (reader, "alignment");
+
+ align = get_enum_value (PANGO_TYPE_TAB_ALIGN,
+ json_reader_get_string_value (reader),
+ FALSE,
+ error);
+ if (align == -1)
+ goto fail;
+ json_reader_end_member (reader);
+ }
+ else
+ {
+ pos = json_reader_get_int_value (reader);
+ align = PANGO_TAB_LEFT;
+ }
+
+ pango_tab_array_set_tab (tabs, i, align, pos);
json_reader_end_element (reader);
}
}
diff --git a/tests/layouts/valid-12.layout b/tests/layouts/valid-12.layout
index cc647178..bbe9a576 100644
--- a/tests/layouts/valid-12.layout
+++ b/tests/layouts/valid-12.layout
@@ -21,11 +21,26 @@
"tabs" : {
"positions-in-pixels" : true,
"positions" : [
- 0,
- 50,
- 100,
- 150,
- 200
+ {
+ "position" : 0,
+ "alignment" : "left"
+ },
+ {
+ "position" : 50,
+ "alignment" : "left"
+ },
+ {
+ "position" : 100,
+ "alignment" : "left"
+ },
+ {
+ "position" : 150,
+ "alignment" : "left"
+ },
+ {
+ "position" : 200,
+ "alignment" : "left"
+ }
]
},
"output" : {
diff --git a/tests/layouts/valid-13.layout b/tests/layouts/valid-13.layout
index 7b70a602..bc20a3c1 100644
--- a/tests/layouts/valid-13.layout
+++ b/tests/layouts/valid-13.layout
@@ -21,11 +21,26 @@
"tabs" : {
"positions-in-pixels" : true,
"positions" : [
- 0,
- 50,
- 100,
- 150,
- 200
+ {
+ "position" : 0,
+ "alignment" : "left"
+ },
+ {
+ "position" : 50,
+ "alignment" : "left"
+ },
+ {
+ "position" : 100,
+ "alignment" : "left"
+ },
+ {
+ "position" : 150,
+ "alignment" : "left"
+ },
+ {
+ "position" : 200,
+ "alignment" : "left"
+ }
]
},
"single-paragraph" : true,
diff --git a/tests/testserialize.c b/tests/testserialize.c
index 4ea7425e..325338f1 100644
--- a/tests/testserialize.c
+++ b/tests/testserialize.c
@@ -86,6 +86,7 @@ test_serialize_tab_array (void)
"0px 10px 100px 200px 400px",
" 0 10 ",
"20 10",
+ "left:10px right:20px center:30px decimal:40px",
""
};
const char *roundtripped[] = {
@@ -93,6 +94,7 @@ test_serialize_tab_array (void)
"0px 10px 100px 200px 400px",
"0 10",
"20 10",
+ "10px right:20px center:30px decimal:40px",
""
};
const char *invalid[] = {
@@ -231,9 +233,18 @@ test_serialize_layout_valid (void)
" \"tabs\" : {\n"
" \"positions-in-pixels\" : true,\n"
" \"positions\" : [\n"
- " 0,\n"
- " 50,\n"
- " 100\n"
+ " {\n"
+ " \"position\" : 0,\n"
+ " \"alignment\" : \"left\"\n"
+ " },\n"
+ " {\n"
+ " \"position\" : 50,\n"
+ " \"alignment\" : \"center\"\n"
+ " },\n"
+ " {\n"
+ " \"position\" : 100,\n"
+ " \"alignment\" : \"right\"\n"
+ " }\n"
" ]\n"
" },\n"
" \"alignment\" : \"center\",\n"