summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/markups/valid-4.expected8
-rw-r--r--tests/test-itemize.c2
-rw-r--r--tests/test-layout.c190
3 files changed, 21 insertions, 179 deletions
diff --git a/tests/markups/valid-4.expected b/tests/markups/valid-4.expected
index 0391ec8e..a9e16728 100644
--- a/tests/markups/valid-4.expected
+++ b/tests/markups/valid-4.expected
@@ -18,8 +18,8 @@ range 16 29
[16,41]strikethrough=1
range 29 32
[16,41]strikethrough=1
-[29,32]scale=0.833333
-[29,32]rise=-5000
+[29,32]font-scale=2
+[29,32]baseline-shift=2
range 32 33
[16,41]strikethrough=1
range 33 38
@@ -27,8 +27,8 @@ range 33 38
[33,38]scale=0.833333
range 38 41
[16,41]strikethrough=1
-[38,41]scale=0.833333
-[38,41]rise=5000
+[38,41]font-scale=1
+[38,41]baseline-shift=1
range 41 42
range 42 45
[42,54]family=Monospace
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index db6a715f..e5775985 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -73,10 +73,12 @@ affects_itemization (PangoAttribute *attr,
case PANGO_ATTR_ABSOLUTE_SIZE:
case PANGO_ATTR_GRAVITY:
case PANGO_ATTR_GRAVITY_HINT:
+ case PANGO_ATTR_FONT_SCALE:
/* These are part of ItemProperties, so need to break runs */
case PANGO_ATTR_LETTER_SPACING:
case PANGO_ATTR_SHAPE:
case PANGO_ATTR_RISE:
+ case PANGO_ATTR_BASELINE_SHIFT:
case PANGO_ATTR_LINE_HEIGHT:
case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
case PANGO_ATTR_TEXT_TRANSFORM:
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 0139c138..cd60450e 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -388,14 +388,7 @@ test_file (const char *filename, GString *string)
PangoFontDescription *desc;
const PangoFontDescription *desc2;
guint serial;
- PangoRectangle ink_rect, logical_rect;
- PangoRectangle ink_rect1, logical_rect1;
- int width, height;
- int width1, height1;
PangoTabArray *tabs;
- GSList *lines, *l;
- PangoLayoutIter *iter;
- PangoLayoutIter *iter2;
if (context == NULL)
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
@@ -483,174 +476,6 @@ test_file (const char *filename, GString *string)
g_assert_cmpint (pango_layout_get_character_count (layout), ==, g_utf8_strlen (pango_layout_get_text (layout), -1));
- /* Some checks on extents - we have to be careful here,
- * since we don't want to depend on font metrics.
- */
- pango_layout_get_size (layout, &width, &height);
- pango_layout_get_extents (layout, &ink_rect, &logical_rect);
- g_assert_cmpint (width, ==, logical_rect.width);
- g_assert_cmpint (height, ==, logical_rect.height);
-
- pango_extents_to_pixels (&ink_rect, NULL);
- pango_extents_to_pixels (&logical_rect, NULL);
- pango_layout_get_pixel_extents (layout, &ink_rect1, &logical_rect1);
- pango_layout_get_pixel_size (layout, &width1, &height1);
-
- assert_rectangle_equal (&ink_rect, &ink_rect1);
- assert_rectangle_equal (&logical_rect, &logical_rect1);
- g_assert_cmpint (width1, ==, logical_rect1.width);
- g_assert_cmpint (height1, ==, logical_rect1.height);
-
- lines = pango_layout_get_lines (layout);
- for (l = lines; l; l = l->next)
- {
- PangoLayoutLine *line = l->data;
- int line_width;
- int line_x;
- PangoRectangle line_ink, line_logical;
- PangoRectangle line_ink1, line_logical1;
- gboolean done;
-
- pango_layout_line_get_extents (line, &line_ink, &line_logical);
- line_x = line_logical.x;
- line_width = line_logical.width;
- pango_extents_to_pixels (&line_ink, NULL);
- pango_extents_to_pixels (&line_logical, NULL);
- pango_layout_line_get_pixel_extents (line, &line_ink1, &line_logical1);
-
- /* Not in layout coordinates, so just compare sizes */
- assert_rectangle_size_contained (&line_ink, &ink_rect);
- assert_rectangle_size_contained (&line_logical, &logical_rect);
- assert_rectangle_size_contained (&line_ink1, &ink_rect1);
- assert_rectangle_size_contained (&line_logical1, &logical_rect1);
-
- if (pango_layout_is_ellipsized (layout))
- continue;
-
- /* FIXME: should have a way to position iters */
- iter = pango_layout_get_iter (layout);
- while (pango_layout_iter_get_line_readonly (iter) != line)
- pango_layout_iter_next_line (iter);
-
- done = FALSE;
- while (!done && pango_layout_iter_get_line_readonly (iter) == line)
- {
- int prev_index, index, next_index;
- int x;
- int *ranges;
- int n_ranges;
- gboolean found_range;
- PangoLayoutRun *run;
-
- index = pango_layout_iter_get_index (iter);
- run = pango_layout_iter_get_run_readonly (iter);
-
- if (!pango_layout_iter_next_cluster (iter))
- done = TRUE;
-
- pango_layout_line_index_to_x (line, index, 0, &x);
- g_assert_cmpint (0, <=, x);
- g_assert_cmpint (x, <=, line_width);
-
- if (!run)
- break;
-
- prev_index = run->item->offset;
- next_index = run->item->offset + run->item->length;
-
- {
- PangoGlyphItem *run2 = pango_glyph_item_copy (run);
- g_assert_cmpint (run2->item->offset, ==, run->item->offset);
- g_assert_cmpint (run2->item->length, ==, run->item->length);
- pango_glyph_item_free (run2);
- }
-
- pango_layout_line_get_x_ranges (line, prev_index, next_index, &ranges, &n_ranges);
-
- /* The index is within the run, so the x should be in one of the ranges */
- if (n_ranges > 0)
- {
- found_range = FALSE;
- for (int k = 0; k < n_ranges; k++)
- {
- if (x + line_x >= ranges[2*k] && x + line_x <= ranges[2*k + 1])
- {
- found_range = TRUE;
- break;
- }
- }
- }
-
- g_assert_true (found_range);
- g_free (ranges);
- }
-
- pango_layout_iter_free (iter);
- }
-
- iter = pango_layout_get_iter (layout);
- g_assert_true (pango_layout_iter_get_layout (iter) == layout);
- g_assert_cmpint (pango_layout_iter_get_index (iter), ==, 0);
- pango_layout_iter_get_layout_extents (iter, &ink_rect, &logical_rect);
-
- iter2 = pango_layout_iter_copy (iter);
-
- do
- {
- PangoRectangle line_ink, line_logical;
- int baseline;
- PangoLayoutLine *line;
- PangoLayoutRun *run;
-
- line = pango_layout_iter_get_line (iter);
-
- pango_layout_iter_get_line_extents (iter, &line_ink, &line_logical);
- baseline = pango_layout_iter_get_baseline (iter);
-
- assert_rectangle_contained (&line_ink, &ink_rect);
- assert_rectangle_contained (&line_logical, &logical_rect);
-
- g_assert_cmpint (line_logical.y, <=, baseline);
- g_assert_cmpint (baseline, <=, line_logical.y + line_logical.height);
-
- if (pango_layout_iter_get_index (iter) == pango_layout_iter_get_index (iter2))
- {
- g_assert_cmpint (baseline, ==, pango_layout_get_baseline (layout));
- g_assert_true (line->is_paragraph_start);
- }
-
- if (pango_layout_iter_at_last_line (iter))
- {
- g_assert_cmpint (line->start_index + line->length, <=, strlen (pango_layout_get_text (layout)));
- }
-
- run = pango_layout_iter_get_run (iter);
-
- if (run)
- {
- const char *text;
- int *widths;
- int *widths2;
-
- text = pango_layout_get_text (layout);
-
- widths = g_new (int, run->item->num_chars);
- pango_glyph_item_get_logical_widths (run, text, widths);
-
- widths2 = g_new (int, run->item->num_chars);
- pango_glyph_string_get_logical_widths (run->glyphs, text + run->item->offset, run->item->length, run->item->analysis.level, widths2);
-
- g_assert_true (memcmp (widths, widths2, sizeof (int) * run->item->num_chars) == 0);
-
- g_free (widths);
- g_free (widths2);
- }
- }
- while (pango_layout_iter_next_line (iter));
-
- pango_layout_iter_free (iter);
- pango_layout_iter_free (iter2);
-
/* generate the dumps */
g_string_append (string, pango_layout_get_text (layout));
@@ -792,9 +617,24 @@ main (int argc, char *argv[])
GError *error = NULL;
const gchar *name;
gchar *path;
+ GOptionContext *option_context;
+ GOptionEntry entries[] = {
+ { "show-fonts", '0', 0, G_OPTION_ARG_NONE, &opt_show_font, "Print font names in dumps", NULL },
+ { NULL, 0 },
+ };
setlocale (LC_ALL, "");
+ option_context = g_option_context_new ("");
+ g_option_context_add_main_entries (option_context, entries, NULL);
+ g_option_context_set_ignore_unknown_options (option_context, TRUE);
+ if (!g_option_context_parse (option_context, &argc, &argv, &error))
+ {
+ g_error ("failed to parse options: %s", error->message);
+ return 1;
+ }
+ g_option_context_free (option_context);
+
if (g_getenv ("PANGO_TEST_SHOW_FONT"))
opt_show_font = TRUE;