[pango/pango2: 74/301] Port tests to PangoSimpleLayout
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 74/301] Port tests to PangoSimpleLayout
- Date: Wed, 22 Jun 2022 15:53:34 +0000 (UTC)
commit 22161c402a1b24898c15cca2bdf4953009b0fbfa
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 10 21:47:08 2022 -0400
Port tests to PangoSimpleLayout
tests/breaks/fourteen.expected | 2 +-
tests/test-bidi.c | 122 +++++++++--------
tests/test-break.c | 27 +---
tests/test-ellipsize.c | 52 ++++----
tests/test-layout.c | 14 +-
tests/test-pangocairo-threads.c | 21 +--
tests/testiter.c | 148 ++++++++++----------
tests/testmisc.c | 289 ++++++++++++++++++++--------------------
tests/testrandom.c | 42 +++---
tests/testserialize.c | 5 +-
10 files changed, 361 insertions(+), 361 deletions(-)
---
diff --git a/tests/breaks/fourteen.expected b/tests/breaks/fourteen.expected
index 1f176a6a2..c8f2328d5 100644
--- a/tests/breaks/fourteen.expected
+++ b/tests/breaks/fourteen.expected
@@ -1,5 +1,5 @@
Text: a b c [ ] α β γ [0x0a]
-Breaks: c c Lc
+Breaks: c Lc
Whitespace: x w w
Sentences: bs e b
Words: bs bse bse be b
diff --git a/tests/test-bidi.c b/tests/test-bidi.c
index 509f110d1..edd597b7b 100644
--- a/tests/test-bidi.c
+++ b/tests/test-bidi.c
@@ -73,8 +73,8 @@ test_bidi_embedding_levels (void)
}
}
-/* Some basic tests for pango_layout_move_cursor_visually inside
- * a single PangoLayoutLine:
+/* Some basic tests for pango_simple_layout_move_cursor inside
+ * a single PangoLine:
* - check that we actually move the cursor in the right direction
* - check that we get through the line with at most n steps
* - check that we don't skip legitimate cursor positions
@@ -89,10 +89,10 @@ test_move_cursor_line (void)
"aאב12b",
"paragraph", // soft hyphens
};
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
gboolean fail = FALSE;
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
for (int i = 0; i < G_N_ELEMENTS (tests); i++)
{
@@ -103,7 +103,9 @@ test_move_cursor_line (void)
gboolean trailing;
PangoRectangle s_pos, old_s_pos;
PangoRectangle w_pos, old_w_pos;
- PangoLayoutLine *line;
+ PangoLines *lines;
+ PangoLine *line;
+ PangoLine *new_line;
struct {
int direction;
gboolean strong;
@@ -121,14 +123,15 @@ test_move_cursor_line (void)
int j;
const char *p;
- pango_layout_set_text (layout, tests[i], -1);
+ pango_simple_layout_set_text (layout, tests[i], -1);
- text = pango_layout_get_text (layout);
- line = pango_layout_get_line_readonly (layout, 0);
+ text = pango_simple_layout_get_text (layout);
+ lines = pango_simple_layout_get_lines (layout);
+ line = pango_lines_get_line (lines, 0, NULL, NULL);
n_chars = g_utf8_strlen (text, -1);
- attrs = pango_layout_get_log_attrs_readonly (layout, &n_attrs);
+ attrs = pango_simple_layout_get_log_attrs (layout, &n_attrs);
strong_cursor = g_new (int, n_attrs);
weak_cursor = g_new (int, n_attrs);
met_cursor = g_new (gboolean, n_attrs);
@@ -136,7 +139,7 @@ test_move_cursor_line (void)
{
if (attrs[j].is_cursor_position)
{
- pango_layout_get_cursor_pos (layout, p - text, &s_pos, &w_pos);
+ pango_lines_get_cursor_pos (lines, NULL, p - text, &s_pos, &w_pos);
strong_cursor[j] = s_pos.x;
weak_cursor[j] = w_pos.x;
}
@@ -154,7 +157,7 @@ test_move_cursor_line (void)
params[j].direction > 0 ? "->" : "<-",
params[j].strong ? "strong" : "weak");
- if ((pango_layout_line_get_resolved_direction (line) == PANGO_DIRECTION_LTR) ==
(params[j].direction > 0))
+ if ((pango_line_get_resolved_direction (line) == PANGO_DIRECTION_LTR) == (params[j].direction > 0))
start_index = 0;
else
start_index = strlen (text);
@@ -163,7 +166,7 @@ test_move_cursor_line (void)
memset (met_cursor, 0, sizeof (gboolean) * n_attrs);
- pango_layout_get_cursor_pos (layout, index, &s_pos, &w_pos);
+ pango_lines_get_cursor_pos (lines, NULL, index, &s_pos, &w_pos);
for (int l = 0; l < n_attrs; l++)
{
if ((params[j].strong && strong_cursor[l] == s_pos.x) ||
@@ -177,10 +180,12 @@ test_move_cursor_line (void)
{
old_s_pos = s_pos;
old_w_pos = w_pos;
- pango_layout_move_cursor_visually (layout, params[j].strong,
- index, 0,
- params[j].direction,
- &index, &trailing);
+ pango_lines_move_cursor (lines, params[j].strong,
+ NULL,
+ index, 0,
+ params[j].direction,
+ &new_line,
+ &index, &trailing);
while (trailing--)
index = g_utf8_next_char (text + index) - text;
@@ -191,7 +196,7 @@ test_move_cursor_line (void)
if (index == -1 || index == G_MAXINT)
break;
- pango_layout_get_cursor_pos (layout, index, &s_pos, &w_pos);
+ pango_lines_get_cursor_pos (lines, NULL, index, &s_pos, &w_pos);
for (int l = 0; l < n_attrs; l++)
{
if ((params[j].strong && strong_cursor[l] == s_pos.x) ||
@@ -265,46 +270,52 @@ test_move_cursor_para (void)
{ "long word", 40 },
{ "זוהי השורה הראשונה" "\n" "זוהי השורה השנייה" "\n" "זוהי השורה השלישית" , 200 },
};
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoRectangle pos, old_pos;
int index;
int trailing;
const char *text;
- int line_no;
- PangoLayoutLine *line;
+ PangoLine *line;
PangoRectangle ext;
- PangoLayoutIter *iter;
+ PangoLines *lines;
+ PangoLineIter *iter;
+ PangoLine *new_line;
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
for (int i = 0; i < G_N_ELEMENTS (tests); i++)
{
- pango_layout_set_text (layout, tests[i].text, -1);
- text = pango_layout_get_text (layout);
+ pango_simple_layout_set_text (layout, tests[i].text, -1);
+ text = pango_simple_layout_get_text (layout);
if (tests[i].width > 0)
- pango_layout_set_width (layout, tests[i].width * PANGO_SCALE);
+ pango_simple_layout_set_width (layout, tests[i].width * PANGO_SCALE);
else
- pango_layout_set_width (layout, -1);
+ pango_simple_layout_set_width (layout, -1);
index = 0;
- pango_layout_get_cursor_pos (layout, index, &pos, NULL);
+ lines = pango_simple_layout_get_lines (layout);
+ pango_lines_get_cursor_pos (lines, NULL, index, &pos, NULL);
while (index < G_MAXINT)
{
old_pos = pos;
- pango_layout_index_to_line_x (layout, index, FALSE, &line_no, NULL);
- line = pango_layout_get_line (layout, line_no);
- iter = pango_layout_get_iter (layout);
- while (pango_layout_iter_get_line (iter) != line)
- pango_layout_iter_next_line (iter);
- pango_layout_iter_get_line_extents (iter, NULL, &ext);
- pango_layout_iter_free (iter);
-
- pango_layout_move_cursor_visually (layout, TRUE,
- index, 0,
- 1,
- &index, &trailing);
+ pango_lines_index_to_line (lines, index, &line, NULL, NULL, NULL);
+ if (line == NULL)
+ break;
+
+ iter = pango_lines_get_iter (lines);
+ while (pango_line_iter_get_line (iter) != line)
+ pango_line_iter_next_line (iter);
+ pango_line_iter_get_line_extents (iter, NULL, &ext);
+ pango_line_iter_free (iter);
+
+ pango_lines_move_cursor(lines, TRUE,
+ NULL,
+ index, 0,
+ 1,
+ &new_line,
+ &index, &trailing);
while (trailing--)
index = g_utf8_next_char (text + index) - text;
@@ -317,7 +328,7 @@ test_move_cursor_para (void)
if (index >= strlen (tests[i].text) - 1)
continue;
- pango_layout_get_cursor_pos (layout, index, &pos, NULL);
+ pango_lines_get_cursor_pos (lines, NULL, index, &pos, NULL);
// assert that we are either moving to the right
// or jumping to the next line
@@ -328,24 +339,27 @@ test_move_cursor_para (void)
/* and now backwards */
index = strlen (text);
- pango_layout_get_cursor_pos (layout, index, &pos, NULL);
+ pango_lines_get_cursor_pos (lines, NULL, index, &pos, NULL);
while (index > -1)
{
old_pos = pos;
- pango_layout_index_to_line_x (layout, index, FALSE, &line_no, NULL);
- line = pango_layout_get_line (layout, line_no);
- iter = pango_layout_get_iter (layout);
- while (pango_layout_iter_get_line (iter) != line)
- pango_layout_iter_next_line (iter);
- pango_layout_iter_get_line_extents (iter, NULL, &ext);
- pango_layout_iter_free (iter);
-
- pango_layout_move_cursor_visually (layout, TRUE,
- index, 0,
- -1,
- &index, &trailing);
+ line = NULL;
+ pango_lines_index_to_line (lines, index, &line, NULL, NULL, NULL);
+ g_assert_nonnull (line);
+ iter = pango_lines_get_iter (lines);
+ while (pango_line_iter_get_line (iter) != line)
+ pango_line_iter_next_line (iter);
+ pango_line_iter_get_line_extents (iter, NULL, &ext);
+ pango_line_iter_free (iter);
+
+ pango_lines_move_cursor (lines, TRUE,
+ NULL,
+ index, 0,
+ -1,
+ &new_line,
+ &index, &trailing);
while (trailing--)
index = g_utf8_next_char (text + index) - text;
@@ -355,7 +369,7 @@ test_move_cursor_para (void)
if (index == -1 || index == G_MAXINT)
break;
- pango_layout_get_cursor_pos (layout, index, &pos, NULL);
+ pango_lines_get_cursor_pos (lines, NULL, index, &pos, NULL);
// assert that we are either moving to the left
// or jumping to the previous line
diff --git a/tests/test-break.c b/tests/test-break.c
index 127a3e71f..570ba1a5c 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -43,10 +43,8 @@ test_file (const gchar *filename, GString *string)
gchar *contents;
gsize length;
GError *error = NULL;
- PangoLogAttr *attrs;
- const PangoLogAttr *attrs2;
+ const PangoLogAttr *attrs;
int len;
- int len2;
char *p;
int i;
GString *s1, *s2, *s3, *s4, *s5, *s6;
@@ -54,8 +52,7 @@ test_file (const gchar *filename, GString *string)
char *test;
char *text;
PangoAttrList *attributes;
- PangoLayout *layout;
- PangoLayout *layout2;
+ PangoSimpleLayout *layout;
g_file_get_contents (filename, &contents, &length, &error);
g_assert_no_error (error);
@@ -72,9 +69,9 @@ test_file (const gchar *filename, GString *string)
pango_parse_markup (test, -1, 0, &attributes, &text, NULL, &error);
g_assert_no_error (error);
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, text, length);
- pango_layout_set_attributes (layout, attributes);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, text, length);
+ pango_simple_layout_set_attributes (layout, attributes);
#if 0
if (pango_layout_get_unknown_glyphs_count (layout) > 0)
@@ -93,25 +90,14 @@ test_file (const gchar *filename, GString *string)
}
#endif
- pango_layout_get_log_attrs (layout, &attrs, &len);
- attrs2 = pango_layout_get_log_attrs_readonly (layout, &len2);
+ attrs = pango_simple_layout_get_log_attrs (layout, &len);
- g_assert_cmpint (len, ==, len2);
- g_assert_true (memcmp (attrs, attrs2, sizeof (PangoLogAttr) * len) == 0);
if (!pango_validate_log_attrs (text, length, attrs, len, &error))
{
g_warning ("%s: Log attrs invalid: %s", filename, error->message);
// g_assert_not_reached ();
}
- layout2 = pango_layout_copy (layout);
- attrs2 = pango_layout_get_log_attrs_readonly (layout2, &len2);
-
- g_assert_cmpint (len, ==, len2);
- g_assert_true (memcmp (attrs, attrs2, sizeof (PangoLogAttr) * len) == 0);
-
- g_object_unref (layout2);
-
s1 = g_string_new ("Breaks: ");
s2 = g_string_new ("Whitespace: ");
s3 = g_string_new ("Sentences:");
@@ -291,7 +277,6 @@ test_file (const gchar *filename, GString *string)
g_string_free (s6, TRUE);
g_object_unref (layout);
- g_free (attrs);
g_free (contents);
g_free (text);
pango_attr_list_unref (attributes);
diff --git a/tests/test-ellipsize.c b/tests/test-ellipsize.c
index 163184ff1..3246f3116 100644
--- a/tests/test-ellipsize.c
+++ b/tests/test-ellipsize.c
@@ -31,26 +31,26 @@ static PangoContext *context;
static void
test_ellipsize_height (void)
{
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
int height1, height2;
PangoFontDescription *desc;
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
desc = pango_font_description_from_string ("Fixed 7");
//pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
- pango_layout_set_text (layout, "some text that should be ellipsized", -1);
- g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1);
- pango_layout_get_size (layout, NULL, &height1);
+ pango_simple_layout_set_text (layout, "some text that should be ellipsized", -1);
+ g_assert_cmpint (pango_lines_get_line_count (pango_simple_layout_get_lines (layout)), ==, 1);
+ pango_lines_get_size (pango_simple_layout_get_lines (layout), NULL, &height1);
- pango_layout_set_width (layout, 100 * PANGO_SCALE);
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ pango_simple_layout_set_width (layout, 100 * PANGO_SCALE);
+ pango_simple_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1);
- g_assert_cmpint (pango_layout_is_ellipsized (layout), ==, 1);
- pango_layout_get_size (layout, NULL, &height2);
+ g_assert_cmpint (pango_lines_get_line_count (pango_simple_layout_get_lines (layout)), ==, 1);
+ g_assert_true (pango_lines_is_ellipsized (pango_simple_layout_get_lines (layout)));
+ pango_lines_get_size (pango_simple_layout_get_lines (layout), NULL, &height2);
g_assert_cmpint (height1, ==, height2);
@@ -62,18 +62,18 @@ test_ellipsize_height (void)
static void
test_ellipsize_crash (void)
{
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
- pango_layout_set_text (layout, "some text that should be ellipsized", -1);
- g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1);
+ pango_simple_layout_set_text (layout, "some text that should be ellipsized", -1);
+ g_assert_cmpint (pango_lines_get_line_count (pango_simple_layout_get_lines (layout)), ==, 1);
- pango_layout_set_width (layout, 100 * PANGO_SCALE);
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ pango_simple_layout_set_width (layout, 100 * PANGO_SCALE);
+ pango_simple_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- g_assert_cmpint (pango_layout_get_line_count (layout), ==, 1);
- g_assert_cmpint (pango_layout_is_ellipsized (layout), ==, 1);
+ g_assert_cmpint (pango_lines_get_line_count (pango_simple_layout_get_lines (layout)), ==, 1);
+ g_assert_true (pango_lines_is_ellipsized (pango_simple_layout_get_lines (layout)));
g_object_unref (layout);
}
@@ -84,21 +84,21 @@ test_ellipsize_crash (void)
static void
test_ellipsize_fully (void)
{
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoRectangle ink, logical;
PangoRectangle ink2, logical2;
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
- pango_layout_set_text (layout, "…", -1);
- pango_layout_get_extents (layout, &ink, &logical);
+ pango_simple_layout_set_text (layout, "…", -1);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), &ink, &logical);
- pango_layout_set_text (layout, "ellipsized", -1);
+ pango_simple_layout_set_text (layout, "ellipsized", -1);
- pango_layout_set_width (layout, 10 * PANGO_SCALE);
- pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+ pango_simple_layout_set_width (layout, 10 * PANGO_SCALE);
+ pango_simple_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
- pango_layout_get_extents (layout, &ink2, &logical2);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), &ink2, &logical2);
g_assert_cmpint (ink.width, ==, ink2.width);
g_assert_cmpint (logical.width, ==, logical2.width);
diff --git a/tests/test-layout.c b/tests/test-layout.c
index ca98523de..fab6501fa 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -45,7 +45,7 @@ test_layout (gconstpointer d)
gsize length;
GBytes *orig;
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
if (!PANGO_FC_IS_FONT_MAP (pango_cairo_font_map_get_default ()))
{
@@ -69,10 +69,11 @@ test_layout (gconstpointer d)
orig = g_bytes_new_take (contents, length);
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_deserialize (context, orig, PANGO_LAYOUT_DESERIALIZE_CONTEXT, &error);
+ layout = pango_simple_layout_deserialize (context, orig, PANGO_SIMPLE_LAYOUT_DESERIALIZE_CONTEXT, &error);
g_assert_no_error (error);
- bytes = pango_layout_serialize (layout, PANGO_LAYOUT_SERIALIZE_CONTEXT | PANGO_LAYOUT_SERIALIZE_OUTPUT);
+ bytes = pango_simple_layout_serialize (layout, PANGO_SIMPLE_LAYOUT_SERIALIZE_CONTEXT |
+ PANGO_SIMPLE_LAYOUT_SERIALIZE_OUTPUT);
g_object_unref (layout);
g_object_unref (context);
@@ -175,16 +176,17 @@ main (int argc, char *argv[])
GBytes *orig;
GBytes *bytes;
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
g_file_get_contents (argv[1], &contents, &length, &error);
g_assert_no_error (error);
orig = g_bytes_new_take (contents, length);
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_deserialize (context, orig, PANGO_LAYOUT_DESERIALIZE_CONTEXT, &error);
+ layout = pango_simple_layout_deserialize (context, orig, PANGO_SIMPLE_LAYOUT_DESERIALIZE_CONTEXT,
&error);
g_assert_no_error (error);
- bytes = pango_layout_serialize (layout, PANGO_LAYOUT_SERIALIZE_CONTEXT |
PANGO_LAYOUT_SERIALIZE_OUTPUT);
+ bytes = pango_simple_layout_serialize (layout, PANGO_SIMPLE_LAYOUT_SERIALIZE_CONTEXT |
+ PANGO_SIMPLE_LAYOUT_SERIALIZE_OUTPUT);
g_object_unref (layout);
g_object_unref (context);
diff --git a/tests/test-pangocairo-threads.c b/tests/test-pangocairo-threads.c
index ea97fc179..308f87e4c 100644
--- a/tests/test-pangocairo-threads.c
+++ b/tests/test-pangocairo-threads.c
@@ -18,17 +18,20 @@ create_surface (void)
return cairo_image_surface_create (CAIRO_FORMAT_A8, WIDTH, HEIGHT);
}
-static PangoLayout *
+static PangoSimpleLayout *
create_layout (cairo_t *cr)
{
- PangoLayout *layout = pango_cairo_create_layout (cr);
- pango_layout_set_text (layout, text, -1);
- pango_layout_set_width (layout, WIDTH * PANGO_SCALE);
+ PangoSimpleLayout *layout;
+
+ layout = pango_cairo_create_simple_layout (cr);
+ pango_simple_layout_set_text (layout, text, -1);
+ pango_simple_layout_set_width (layout, WIDTH * PANGO_SCALE);
+
return layout;
}
static void
-draw (cairo_t *cr, PangoLayout *layout, unsigned int i)
+draw (cairo_t *cr, PangoSimpleLayout *layout, unsigned int i)
{
cairo_set_source_rgba (cr, 1, 1, 1, 1);
cairo_paint (cr);
@@ -37,16 +40,16 @@ draw (cairo_t *cr, PangoLayout *layout, unsigned int i)
cairo_identity_matrix (cr);
cairo_scale (cr, (100 + i) / 100., (100 + i) / 100.);
- pango_cairo_update_layout (cr, layout);
+ pango_cairo_update_context (cr, pango_simple_layout_get_context (layout));
- pango_cairo_show_layout (cr, layout);
+ pango_cairo_show_lines (cr, pango_simple_layout_get_lines (layout));
}
static gpointer
thread_func (gpointer data)
{
cairo_surface_t *surface = data;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
int i;
cairo_t *cr = cairo_create (surface);
@@ -99,7 +102,7 @@ pangocairo_threads (void)
{
cairo_surface_t *ref_surface = create_surface ();
cairo_t *cr = cairo_create (ref_surface);
- PangoLayout *layout = create_layout (cr);
+ PangoSimpleLayout *layout = create_layout (cr);
unsigned char *ref_data = cairo_image_surface_get_data (ref_surface);
unsigned int len = WIDTH * HEIGHT;
diff --git a/tests/testiter.c b/tests/testiter.c
index c948c29ff..5282c236d 100644
--- a/tests/testiter.c
+++ b/tests/testiter.c
@@ -11,7 +11,7 @@
*
* 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
+ * 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
@@ -77,21 +77,21 @@ const char *test_texts[] =
* - GlyphString's index_to_x positions match those returned by the Iter
*/
static void
-iter_char_test (PangoLayout *layout)
+iter_char_test (PangoSimpleLayout *layout)
{
PangoRectangle extents, run_extents;
- PangoLayoutIter *iter;
- PangoLayoutRun *run;
+ PangoLineIter *iter;
+ PangoGlyphItem *run;
int num_chars;
int i, index, offset;
int leading_x, trailing_x, x0, x1;
gboolean iter_next_ok, rtl;
const char *text, *ptr;
- text = pango_layout_get_text (layout);
+ text = pango_simple_layout_get_text (layout);
num_chars = g_utf8_strlen (text, -1);
- iter = pango_layout_get_iter (layout);
+ iter = pango_lines_get_iter (pango_simple_layout_get_lines (layout));
iter_next_ok = TRUE;
for (i = 0 ; i < num_chars; ++i)
@@ -99,61 +99,61 @@ iter_char_test (PangoLayout *layout)
gchar *char_str;
g_assert (iter_next_ok);
- index = pango_layout_iter_get_index (iter);
+ index = pango_line_iter_get_index (iter);
ptr = text + index;
char_str = g_strndup (ptr, g_utf8_next_char (ptr) - ptr);
verbose ("i=%d (visual), index = %d '%s':\n",
- i, index, char_str);
+ i, index, char_str);
g_free (char_str);
- pango_layout_iter_get_char_extents (iter, &extents);
+ pango_line_iter_get_char_extents (iter, &extents);
verbose (" char extents: x=%d,y=%d w=%d,h=%d\n",
- extents.x, extents.y,
- extents.width, extents.height);
+ extents.x, extents.y,
+ extents.width, extents.height);
- run = pango_layout_iter_get_run (iter);
+ run = pango_line_iter_get_run (iter);
if (run)
- {
+ {
PangoFontDescription *desc;
char *str;
- /* Get needed data for the GlyphString */
- pango_layout_iter_get_run_extents(iter, NULL, &run_extents);
- offset = run->item->offset;
- rtl = run->item->analysis.level%2;
+ /* Get needed data for the GlyphString */
+ pango_line_iter_get_run_extents (iter, NULL, &run_extents);
+ offset = run->item->offset;
+ rtl = run->item->analysis.level%2;
desc = pango_font_describe (run->item->analysis.font);
str = pango_font_description_to_string (desc);
- verbose (" (current run: font=%s,offset=%d,x=%d,len=%d,rtl=%d)\n",
- str, offset, run_extents.x, run->item->length, rtl);
+ verbose (" (current run: font=%s,offset=%d,x=%d,len=%d,rtl=%d)\n",
+ str, offset, run_extents.x, run->item->length, rtl);
g_free (str);
pango_font_description_free (desc);
- /* Calculate expected x result using index_to_x */
- pango_glyph_string_index_to_x (run->glyphs,
- (char *)(text + offset), run->item->length,
- &run->item->analysis,
- index - offset, FALSE, &leading_x);
- pango_glyph_string_index_to_x (run->glyphs,
- (char *)(text + offset), run->item->length,
- &run->item->analysis,
- index - offset, TRUE, &trailing_x);
-
- x0 = run_extents.x + MIN (leading_x, trailing_x);
- x1 = run_extents.x + MAX (leading_x, trailing_x);
-
- verbose (" (index_to_x ind=%d: expected x=%d, width=%d)\n",
- index - offset, x0, x1 - x0);
-
- g_assert (extents.x == x0);
- g_assert (extents.width == x1 - x0);
- }
+ /* Calculate expected x result using index_to_x */
+ pango_glyph_string_index_to_x (run->glyphs,
+ (char *)(text + offset), run->item->length,
+ &run->item->analysis,
+ index - offset, FALSE, &leading_x);
+ pango_glyph_string_index_to_x (run->glyphs,
+ (char *)(text + offset), run->item->length,
+ &run->item->analysis,
+ index - offset, TRUE, &trailing_x);
+
+ x0 = run_extents.x + MIN (leading_x, trailing_x);
+ x1 = run_extents.x + MAX (leading_x, trailing_x);
+
+ verbose (" (index_to_x ind=%d: expected x=%d, width=%d)\n",
+ index - offset, x0, x1 - x0);
+
+ g_assert (extents.x == x0);
+ g_assert (extents.width == x1 - x0);
+ }
else
- {
- /* We're on a line terminator */
- }
+ {
+ /* We're on a line terminator */
+ }
- iter_next_ok = pango_layout_iter_next_char (iter);
+ iter_next_ok = pango_line_iter_next_char (iter);
verbose ("more to go? %d\n", iter_next_ok);
}
@@ -161,39 +161,39 @@ iter_char_test (PangoLayout *layout)
* input string */
g_assert (!iter_next_ok);
- pango_layout_iter_free (iter);
+ pango_line_iter_free (iter);
}
static void
-iter_cluster_test (PangoLayout *layout)
+iter_cluster_test (PangoSimpleLayout *layout)
{
PangoRectangle extents;
- PangoLayoutIter *iter;
+ PangoLineIter *iter;
int index;
gboolean iter_next_ok;
- PangoLayoutLine *last_line = NULL;
+ PangoLine *last_line = NULL;
int expected_next_x = 0;
- iter = pango_layout_get_iter (layout);
+ iter = pango_lines_get_iter (pango_simple_layout_get_lines (layout));
iter_next_ok = TRUE;
while (iter_next_ok)
{
- PangoLayoutLine *line = pango_layout_iter_get_line (iter);
+ PangoLine *line = pango_line_iter_get_line (iter);
/* Every cluster is part of a run */
- g_assert (pango_layout_iter_get_run (iter));
+ g_assert (pango_line_iter_get_run (iter));
- index = pango_layout_iter_get_index (iter);
+ index = pango_line_iter_get_index (iter);
- pango_layout_iter_get_cluster_extents (iter, NULL, &extents);
+ pango_line_iter_get_cluster_extents (iter, NULL, &extents);
- iter_next_ok = pango_layout_iter_next_cluster (iter);
+ iter_next_ok = pango_line_iter_next_cluster (iter);
verbose ("index = %d:\n", index);
verbose (" cluster extents: x=%d,y=%d w=%d,h=%d\n",
- extents.x, extents.y,
- extents.width, extents.height);
+ extents.x, extents.y,
+ extents.width, extents.height);
verbose ("more to go? %d\n", iter_next_ok);
/* All the clusters on a line should be next to each other and occupy
@@ -201,7 +201,7 @@ iter_cluster_test (PangoLayout *layout)
g_assert (extents.width >= 0);
if (last_line == line)
- g_assert (extents.x == expected_next_x);
+ g_assert (extents.x == expected_next_x);
expected_next_x = extents.x + extents.width;
@@ -210,7 +210,7 @@ iter_cluster_test (PangoLayout *layout)
g_assert (!iter_next_ok);
- pango_layout_iter_free (iter);
+ pango_line_iter_free (iter);
}
static void
@@ -220,24 +220,24 @@ test_layout_iter (void)
PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *font_desc;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
fontmap = pango_cairo_font_map_get_default ();
context = pango_font_map_create_context (fontmap);
font_desc = pango_font_description_from_string ("cantarell 11");
pango_context_set_font_description (context, font_desc);
- layout = pango_layout_new (context);
- pango_layout_set_width (layout, LAYOUT_WIDTH);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_width (layout, LAYOUT_WIDTH);
for (ptext = test_texts; *ptext != NULL; ++ptext)
{
verbose ("--------- checking next text ----------\n");
verbose (" <%s>\n", *ptext);
verbose ( "len=%ld, bytes=%ld\n",
- (long)g_utf8_strlen (*ptext, -1), (long)strlen (*ptext));
+ (long)g_utf8_strlen (*ptext, -1), (long)strlen (*ptext));
- pango_layout_set_text (layout, *ptext, -1);
+ pango_simple_layout_set_text (layout, *ptext, -1);
iter_char_test (layout);
iter_cluster_test (layout);
}
@@ -253,8 +253,8 @@ test_glyphitem_iter (void)
PangoFontMap *fontmap;
PangoContext *context;
PangoFontDescription *font_desc;
- PangoLayout *layout;
- PangoLayoutLine *line;
+ PangoSimpleLayout *layout;
+ PangoLine *line;
const char *text;
GSList *l;
@@ -263,13 +263,13 @@ test_glyphitem_iter (void)
font_desc = pango_font_description_from_string ("cantarell 11");
pango_context_set_font_description (context, font_desc);
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
/* This shouldn't form any ligatures. */
- pango_layout_set_text (layout, "test تست", -1);
- text = pango_layout_get_text (layout);
+ pango_simple_layout_set_text (layout, "test تست", -1);
+ text = pango_simple_layout_get_text (layout);
- line = pango_layout_get_line (layout, 0);
- for (l = line->runs; l; l = l->next)
+ line = pango_lines_get_line (pango_simple_layout_get_lines (layout), 0, NULL, NULL);
+ for (l = pango_line_get_runs (line); l; l = l->next)
{
PangoGlyphItem *run = l->data;
int direction;
@@ -281,12 +281,12 @@ test_glyphitem_iter (void)
PangoGlyphItemIter *iter2;
for (have_cluster = direction ?
- pango_glyph_item_iter_init_start (&iter, run, text) :
- pango_glyph_item_iter_init_end (&iter, run, text);
- have_cluster;
- have_cluster = direction ?
- pango_glyph_item_iter_next_cluster (&iter) :
- pango_glyph_item_iter_prev_cluster (&iter))
+ pango_glyph_item_iter_init_start (&iter, run, text) :
+ pango_glyph_item_iter_init_end (&iter, run, text);
+ have_cluster;
+ have_cluster = direction ?
+ pango_glyph_item_iter_next_cluster (&iter) :
+ pango_glyph_item_iter_prev_cluster (&iter))
{
verbose ("start index %d end index %d\n", iter.start_index, iter.end_index);
g_assert_true (iter.start_index < iter.end_index);
diff --git a/tests/testmisc.c b/tests/testmisc.c
index ce5f2b051..3abc59c46 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -23,24 +23,6 @@
#include <glib.h>
#include <pango/pangocairo.h>
-/* test that we don't crash in shape_tab when the layout
- * is such that we don't have effective attributes
- */
-static void
-test_shape_tab_crash (void)
-{
- PangoContext *context;
- PangoLayout *layout;
-
- context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one\ttwo", -1);
- pango_layout_is_ellipsized (layout);
-
- g_object_unref (layout);
- g_object_unref (context);
-}
-
/* Test that itemizing a string with 0 characters works
*/
static void
@@ -75,13 +57,13 @@ static void
test_short_string_crash (void)
{
PangoContext *context;
- PangoLayout *layout;
- int width, height;
+ PangoSimpleLayout *layout;
+ PangoRectangle ext;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "short text", 200);
- pango_layout_get_pixel_size (layout, &width, &height);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "short text", 200);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), &ext, &ext);
g_object_unref (layout);
g_object_unref (context);
@@ -105,17 +87,17 @@ static void
test_line_height (void)
{
PangoContext *context;
- PangoLayout *layout;
- PangoLayoutLine *line;
- int height = 0;
+ PangoSimpleLayout *layout;
+ PangoLine *line;
+ PangoRectangle ext;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one\ttwo", -1);
- line = pango_layout_get_line_readonly (layout, 0);
- pango_layout_line_get_height (line, &height);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "one\ttwo", -1);
+ line = pango_lines_get_line (pango_simple_layout_get_lines (layout), 0, NULL, NULL);
+ pango_line_get_extents (line, NULL, &ext);
- g_assert_cmpint (height, >, 0);
+ g_assert_cmpint (ext.height, >, 0);
g_object_unref (layout);
g_object_unref (context);
@@ -125,24 +107,25 @@ static void
test_line_height2 (void)
{
PangoContext *context;
- PangoLayout *layout;
- PangoLayoutLine *line;
- int height1 = 0;
- int height2 = 0;
+ PangoSimpleLayout *layout;
+ PangoLine *line;
+ PangoRectangle ext1, ext2;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one", -1);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "one", -1);
- line = pango_layout_get_line_readonly (layout, 0);
- pango_layout_line_get_height (line, &height1);
+ line = pango_lines_get_line (pango_simple_layout_get_lines (layout), 0, NULL, NULL);
+ g_assert_nonnull (line);
+ pango_line_get_extents (line, NULL, &ext1);
- pango_layout_set_text (layout, "", -1);
+ pango_simple_layout_set_text (layout, "", -1);
- line = pango_layout_get_line_readonly (layout, 0);
- pango_layout_line_get_height (line, &height2);
+ line = pango_lines_get_line (pango_simple_layout_get_lines (layout), 0, NULL, NULL);
+ g_assert_nonnull (line);
+ pango_line_get_extents (line, NULL, &ext2);
- g_assert_cmpint (height1, ==, height2);
+ g_assert_cmpint (ext1.height, ==, ext2.height);
g_object_unref (layout);
g_object_unref (context);
@@ -152,29 +135,31 @@ static void
test_line_height3 (void)
{
PangoContext *context;
- PangoLayout *layout;
- PangoLayoutLine *line;
+ PangoSimpleLayout *layout;
+ PangoLine *line;
PangoAttrList *attrs;
- int height1 = 0;
- int height2 = 0;
+ PangoRectangle ext1;
+ PangoRectangle ext2;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one", -1);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "one", -1);
attrs = pango_attr_list_new ();
pango_attr_list_insert (attrs, pango_attr_line_height_new (2.0));
- pango_layout_set_attributes (layout, attrs);
+ pango_simple_layout_set_attributes (layout, attrs);
pango_attr_list_unref (attrs);
- line = pango_layout_get_line_readonly (layout, 0);
- pango_layout_line_get_height (line, &height1);
+ line = pango_lines_get_line (pango_simple_layout_get_lines (layout), 0, NULL, NULL);
+ g_assert_cmpint (pango_lines_get_line_count (pango_simple_layout_get_lines (layout)), ==, 1);
+ pango_line_get_extents (line, NULL, &ext1);
- pango_layout_set_text (layout, "", -1);
+ pango_simple_layout_set_text (layout, "", -1);
- line = pango_layout_get_line_readonly (layout, 0);
- pango_layout_line_get_height (line, &height2);
+ g_assert_cmpint (pango_lines_get_line_count (pango_simple_layout_get_lines (layout)), ==, 1);
+ line = pango_lines_get_line (pango_simple_layout_get_lines (layout), 0, NULL, NULL);
+ pango_line_get_extents (line, NULL, &ext2);
- g_assert_cmpint (height1, ==, height2);
+ g_assert_cmpint (ext1.height, ==, ext2.height);
g_object_unref (layout);
g_object_unref (context);
@@ -184,8 +169,8 @@ static void
test_run_height (void)
{
PangoContext *context;
- PangoLayout *layout;
- PangoLayoutIter *iter;
+ PangoSimpleLayout *layout;
+ PangoLineIter *iter;
PangoRectangle logical1, logical2;
if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
@@ -195,18 +180,18 @@ test_run_height (void)
}
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one", -1);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "one", -1);
- iter = pango_layout_get_iter (layout);
- pango_layout_iter_get_run_extents (iter, NULL, &logical1);
- pango_layout_iter_free (iter);
+ iter = pango_lines_get_iter (pango_simple_layout_get_lines (layout));
+ pango_line_iter_get_run_extents (iter, NULL, &logical1);
+ pango_line_iter_free (iter);
- pango_layout_set_text (layout, "", -1);
+ pango_simple_layout_set_text (layout, "", -1);
- iter = pango_layout_get_iter (layout);
- pango_layout_iter_get_run_extents (iter, NULL, &logical2);
- pango_layout_iter_free (iter);
+ iter = pango_lines_get_iter (pango_simple_layout_get_lines (layout));
+ pango_line_iter_get_run_extents (iter, NULL, &logical2);
+ pango_line_iter_free (iter);
g_assert_cmpint (logical1.height, ==, logical2.height);
@@ -218,13 +203,13 @@ static void
test_cursor_height (void)
{
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoRectangle strong;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one\ttwo", -1);
- pango_layout_get_cursor_pos (layout, 0, &strong, NULL);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "one\ttwo", -1);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 0, &strong, NULL);
g_assert_cmpint (strong.height, >, 0);
@@ -236,7 +221,7 @@ static void
test_cursor_height2 (void)
{
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoRectangle strong1, strong2;
if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
@@ -246,14 +231,14 @@ test_cursor_height2 (void)
}
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "one", -1);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "one", -1);
- pango_layout_get_cursor_pos (layout, 0, &strong1, NULL);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 0, &strong1, NULL);
- pango_layout_set_text (layout, "", -1);
+ pango_simple_layout_set_text (layout, "", -1);
- pango_layout_get_cursor_pos (layout, 0, &strong2, NULL);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 0, &strong2, NULL);
g_assert_cmpint (strong1.height, ==, strong2.height);
@@ -427,22 +412,22 @@ static void
test_get_cursor_crash (void)
{
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
int i;
const char *string = "foo\n\rbar\r\nbaz\n\nqux\n\n..";
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
- pango_layout_set_text (layout, string, -1);
+ pango_simple_layout_set_text (layout, string, -1);
for (i = 0; string[i]; i++)
{
PangoRectangle rectA, rectB;
- pango_layout_get_cursor_pos (layout, i, &rectA, &rectB);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, i, &rectA, &rectB);
g_assert_cmpint (rectA.x, ==, rectB.x);
}
@@ -459,27 +444,27 @@ test_get_cursor (void)
{
const char *text = "abאב";
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoRectangle strong, weak;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, text, -1);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, text, -1);
- pango_layout_get_cursor_pos (layout, 0, &strong, &weak);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 0, &strong, &weak);
g_assert_cmpint (strong.x, ==, weak.x);
- pango_layout_get_cursor_pos (layout, 1, &strong, &weak);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 1, &strong, &weak);
g_assert_cmpint (strong.x, ==, weak.x);
- pango_layout_get_cursor_pos (layout, 2, &strong, &weak);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 2, &strong, &weak);
g_assert_cmpint (strong.x, !=, weak.x);
- pango_layout_get_cursor_pos (layout, 4, &strong, &weak);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 4, &strong, &weak);
g_assert_cmpint (strong.x, ==, weak.x);
- pango_layout_get_cursor_pos (layout, 6, &strong, &weak);
+ pango_lines_get_cursor_pos (pango_simple_layout_get_lines (layout), NULL, 6, &strong, &weak);
g_assert_cmpint (strong.x, !=, weak.x);
g_object_unref (layout);
@@ -499,31 +484,29 @@ test_index_to_x (void)
for (int i = 0; i < G_N_ELEMENTS (tests); i++)
{
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
const char *text;
const char *p;
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, tests[i], -1);
- text = pango_layout_get_text (layout);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, tests[i], -1);
+ text = pango_simple_layout_get_text (layout);
for (p = text; *p; p = g_utf8_next_char (p))
{
int index = p - text;
- int l;
- PangoLayoutLine *line;
+ PangoLine *line;
int x;
int index2, trailing;
gunichar ch;
ch = g_utf8_get_char (p);
- pango_layout_index_to_line_x (layout, index, FALSE, &l, NULL);
- line = pango_layout_get_line (layout, l);
+ pango_lines_index_to_line (pango_simple_layout_get_lines (layout), index, &line, NULL, NULL, NULL);
g_assert_nonnull (line);
- pango_layout_line_index_to_x (line, index, 0, &x);
- pango_layout_line_x_to_index (line, x, &index2, &trailing);
+ pango_line_index_to_x (line, index, 0, &x);
+ pango_line_x_to_index (line, x, &index2, &trailing);
if (!pango_is_zero_width (ch))
g_assert_cmpint (index, ==, index2);
}
@@ -548,57 +531,74 @@ static void
test_extents (void)
{
PangoContext *context;
- const char *tests[] = {
- "Some long text that has multiple lines that are wrapped by Pango."
+ struct {
+ const char *text;
+ int width;
+ } tests[] = {
+ { "Some long text that has multiple lines that are wrapped by Pango.", 60 },
+ { "This paragraph should actually have multiple lines, unlike all the other wannabe äöü paragraph
tests in this ugh test-case. Grow some lines!\n", 188 },
+ { "你好 Hello שלום Γειά σας", 60 },
+ { "line 1
line 2
line 3\nline 4\r\nline 5", -1 }, // various separators
+ { "abc😂️def", -1 },
+ { "abcאבגdef", -1 },
+ { "אבabcב",
+ -1 },
+ { "aאב12b", -1 },
+ { "paragraph", -1 }, // soft hyphens
};
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
for (int i = 0; i < G_N_ELEMENTS (tests); i++)
{
- PangoLayout *layout;
- PangoLayoutIter *iter;
+ PangoSimpleLayout *layout;
+ PangoLines *lines;
+ PangoLineIter *iter;
PangoRectangle layout_extents;
PangoRectangle line_extents;
PangoRectangle run_extents;
PangoRectangle cluster_extents;
PangoRectangle char_extents;
PangoRectangle pos;
+ PangoRectangle strong, weak;
+ int index;
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, tests[i], -1);
- pango_layout_set_width (layout, 60 * PANGO_SCALE);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, tests[i].text, -1);
+ pango_simple_layout_set_width (layout, tests[i].width > 0 ? tests[i].width * PANGO_SCALE :
tests[i].width);
- pango_layout_get_extents (layout, NULL, &layout_extents);
+ lines = pango_simple_layout_get_lines (layout);
+ pango_lines_get_extents (lines, NULL, &layout_extents);
- iter = pango_layout_get_iter (layout);
+ iter = pango_lines_get_iter (lines);
do
{
- pango_layout_iter_get_line_extents (iter, NULL, &line_extents);
- pango_layout_iter_get_run_extents (iter, NULL, &run_extents);
- pango_layout_iter_get_cluster_extents (iter, NULL, &cluster_extents);
- pango_layout_iter_get_char_extents (iter, &char_extents);
-
- pango_layout_index_to_pos (layout,
- pango_layout_iter_get_index (iter),
- &pos);
+ pango_line_iter_get_line_extents (iter, NULL, &line_extents);
+ pango_line_iter_get_run_extents (iter, NULL, &run_extents);
+ pango_line_iter_get_cluster_extents (iter, NULL, &cluster_extents);
+ pango_line_iter_get_char_extents (iter, &char_extents);
+ index = pango_line_iter_get_index (iter);
+ pango_lines_index_to_pos (lines, NULL, index, &pos);
if (pos.width < 0)
{
pos.x += pos.width;
pos.width = - pos.width;
}
+ pango_lines_get_cursor_pos (lines, NULL, index, &strong, &weak);
g_assert_true (pango_rectangle_contains (&layout_extents, &line_extents));
g_assert_true (pango_rectangle_contains (&line_extents, &run_extents));
g_assert_true (pango_rectangle_contains (&run_extents, &cluster_extents));
g_assert_true (pango_rectangle_contains (&cluster_extents, &char_extents));
- g_assert_true (pango_rectangle_contains (&line_extents, &pos));
+ g_assert_true (pango_rectangle_contains (&run_extents, &pos));
+ g_assert_true (pango_rectangle_contains (&line_extents, &strong));
+ g_assert_true (pango_rectangle_contains (&line_extents, &weak));
}
- while (pango_layout_iter_next_char (iter));
+ while (pango_line_iter_next_char (iter));
- pango_layout_iter_free (iter);
+ pango_line_iter_free (iter);
g_object_unref (layout);
}
@@ -609,7 +609,7 @@ static void
test_empty_line_height (void)
{
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoFontDescription *description;
PangoRectangle ext1, ext2, ext3;
cairo_font_options_t *options;
@@ -636,20 +636,20 @@ test_empty_line_height (void)
pango_cairo_context_set_font_options (context, options);
cairo_font_options_destroy (options);
- layout = pango_layout_new (context);
- pango_layout_set_font_description (layout, description);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_font_description (layout, description);
- pango_layout_get_extents (layout, NULL, &ext1);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), NULL, &ext1);
- pango_layout_set_text (layout, "a", 1);
+ pango_simple_layout_set_text (layout, "a", 1);
- pango_layout_get_extents (layout, NULL, &ext2);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), NULL, &ext2);
g_assert_cmpint (ext1.height, ==, ext2.height);
- pango_layout_set_text (layout, "Pg", 1);
+ pango_simple_layout_set_text (layout, "Pg", 1);
- pango_layout_get_extents (layout, NULL, &ext3);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), NULL, &ext3);
g_assert_cmpint (ext2.height, ==, ext3.height);
@@ -744,22 +744,22 @@ static void
test_wrap_char (void)
{
PangoContext *context;
- PangoLayout *layout;
- int w, h, w0, h0;
+ PangoSimpleLayout *layout;
+ PangoRectangle ext, ext1;
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
- pango_layout_set_text (layout, "Rows can have suffix widgets", -1);
- pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_text (layout, "Rows can have suffix widgets", -1);
+ pango_simple_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
- pango_layout_set_width (layout, 0);
- pango_layout_get_size (layout, &w0, &h0);
+ pango_simple_layout_set_width (layout, 0);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), NULL, &ext);
- pango_layout_set_width (layout, w0);
- pango_layout_get_size (layout, &w, &h);
+ pango_simple_layout_set_width (layout, ext.width);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), NULL, &ext1);
- g_assert_cmpint (w0, ==, w);
- g_assert_cmpint (h0, >=, h);
+ g_assert_cmpint (ext.width, ==, ext1.width);
+ g_assert_cmpint (ext.height, >=, ext1.height);
g_object_unref (layout);
g_object_unref (context);
@@ -770,9 +770,9 @@ static void
test_small_caps_crash (void)
{
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
PangoFontDescription *desc;
- int w, h;
+ PangoRectangle ext;
if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
{
@@ -781,13 +781,13 @@ test_small_caps_crash (void)
}
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
- layout = pango_layout_new (context);
+ layout = pango_simple_layout_new (context);
desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
- pango_layout_set_font_description (layout, desc);
+ pango_simple_layout_set_font_description (layout, desc);
- pango_layout_set_text (layout, "Pere Ràfols Soler\nEqualiser, LV2\nAudio: 1, 1\nMidi: 0, 0\nControls: 53,
2\nCV: 0, 0", -1);
+ pango_simple_layout_set_text (layout, "Pere Ràfols Soler\nEqualiser, LV2\nAudio: 1, 1\nMidi: 0,
0\nControls: 53, 2\nCV: 0, 0", -1);
- pango_layout_get_size (layout, &w, &h);
+ pango_lines_get_extents (pango_simple_layout_get_lines (layout), NULL, &ext);
pango_font_description_free (desc);
g_object_unref (layout);
@@ -799,7 +799,6 @@ main (int argc, char *argv[])
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/layout/shape-tab-crash", test_shape_tab_crash);
g_test_add_func ("/layout/itemize-empty-crash", test_itemize_empty_crash);
g_test_add_func ("/layout/itemize-utf8", test_itemize_utf8);
g_test_add_func ("/layout/short-string-crash", test_short_string_crash);
diff --git a/tests/testrandom.c b/tests/testrandom.c
index c321fb6a9..f72bbcadf 100644
--- a/tests/testrandom.c
+++ b/tests/testrandom.c
@@ -90,13 +90,13 @@ compare_size (gconstpointer a,
}
static void
-layout_check_size (PangoLayout *layout,
- int width,
- Size *out_size)
+layout_check_size (PangoSimpleLayout *layout,
+ int width,
+ Size *out_size)
{
out_size->set_width = width;
- pango_layout_set_width (layout, width);
- pango_layout_get_size (layout, &out_size->width, &out_size->height);
+ pango_simple_layout_set_width (layout, width);
+ pango_lines_get_size (pango_simple_layout_get_lines (layout), &out_size->width, &out_size->height);
}
static void
@@ -105,7 +105,7 @@ test_wrap_char (gconstpointer data)
PangoDirection dir = GPOINTER_TO_UINT (data);
PangoFontDescription *desc;
PangoContext *context;
- PangoLayout *layout;
+ PangoSimpleLayout *layout;
char *sentence;
Size min, max;
Size sizes[100];
@@ -113,15 +113,15 @@ test_wrap_char (gconstpointer data)
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
desc = pango_font_description_from_string ("Sans 10");
- layout = pango_layout_new (context);
- pango_layout_set_font_description (layout, desc);
+ layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
- pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
+ pango_simple_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
for (j = 0; j < N_SENTENCES; j++)
{
sentence = create_random_sentence (dir);
- pango_layout_set_text (layout, sentence, -1);
+ pango_simple_layout_set_text (layout, sentence, -1);
g_test_message ("%s", sentence);
g_free (sentence);
@@ -175,7 +175,7 @@ test_wrap_char_min_width (gconstpointer data)
PangoDirection dir = GPOINTER_TO_UINT (data);
PangoFontDescription *desc;
PangoContext *context;
- PangoLayout *test_layout, *ref_layout;
+ PangoSimpleLayout *test_layout, *ref_layout;
char *sentence, *s;
GString *ref_string;
gsize j;
@@ -183,18 +183,18 @@ test_wrap_char_min_width (gconstpointer data)
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
desc = pango_font_description_from_string ("Sans 10");
- ref_layout = pango_layout_new (context);
- pango_layout_set_font_description (ref_layout, desc);
- test_layout = pango_layout_new (context);
- pango_layout_set_font_description (test_layout, desc);
- pango_layout_set_wrap (test_layout, PANGO_WRAP_WORD_CHAR);
- pango_layout_set_width (test_layout, 0);
+ ref_layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_font_description (ref_layout, desc);
+ test_layout = pango_simple_layout_new (context);
+ pango_simple_layout_set_font_description (test_layout, desc);
+ pango_simple_layout_set_wrap (test_layout, PANGO_WRAP_WORD_CHAR);
+ pango_simple_layout_set_width (test_layout, 0);
pango_font_description_free (desc);
for (j = 0; j < N_SENTENCES; j++)
{
sentence = create_random_sentence (dir);
- pango_layout_set_text (test_layout, sentence, -1);
+ pango_simple_layout_set_text (test_layout, sentence, -1);
g_test_message ("%s", sentence);
ref_string = g_string_new ("");
for (s = sentence; *s; s = g_utf8_next_char (s))
@@ -203,12 +203,12 @@ test_wrap_char_min_width (gconstpointer data)
g_string_append_unichar (ref_string, g_test_rand_bit () ? 0x2010 : '-');
g_string_append_c (ref_string, '\n');
}
- pango_layout_set_text (ref_layout, ref_string->str, ref_string->len);
+ pango_simple_layout_set_text (ref_layout, ref_string->str, ref_string->len);
g_string_free (ref_string, TRUE);
g_free (sentence);
- pango_layout_get_size (test_layout, &test_width, NULL);
- pango_layout_get_size (ref_layout, &ref_width, NULL);
+ pango_lines_get_size (pango_simple_layout_get_lines (test_layout), &test_width, NULL);
+ pango_lines_get_size (pango_simple_layout_get_lines (ref_layout), &ref_width, NULL);
g_assert_cmpint (test_width, <=, ref_width);
}
diff --git a/tests/testserialize.c b/tests/testserialize.c
index e480da31b..dabcf798d 100644
--- a/tests/testserialize.c
+++ b/tests/testserialize.c
@@ -273,7 +273,6 @@ test_serialize_layout_valid (void)
PangoContext *context;
GBytes *bytes;
PangoLayout *layout;
- PangoTabArray *tabs;
GError *error = NULL;
GBytes *out_bytes;
char *s;
@@ -287,9 +286,7 @@ test_serialize_layout_valid (void)
g_assert_true (PANGO_IS_LAYOUT (layout));
g_assert_cmpstr (pango_layout_get_text (layout), ==, "Some fun with layouts!");
g_assert_nonnull (pango_layout_get_attributes (layout));
- tabs = pango_layout_get_tabs (layout);
- g_assert_nonnull (tabs);
- pango_tab_array_free (tabs);
+ g_assert_nonnull (pango_layout_get_tabs (layout));
s = pango_font_description_to_string (pango_layout_get_font_description (layout));
g_assert_cmpstr (s, ==, "Sans Bold 32");
g_free (s);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]