summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-13 16:27:38 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-11-13 16:27:38 +0000
commit82599ca5ee42291ec824a1865c454e8dbc38ec80 (patch)
treedb8b7a76d7b35f16f056833ad3fdc1e763a52964
parent6101f21df7e260e25a18bc8918a7429378cd85f3 (diff)
parent4db8ff2ea3b2b20c9b38670a3c49e73125f1673e (diff)
downloadpango-82599ca5ee42291ec824a1865c454e8dbc38ec80.tar.gz
Merge branch 'fix-itemize-crash' into 'main'
Fix a bug in Small Caps handling Closes #627 See merge request GNOME/pango!505
-rw-r--r--pango/itemize.c4
-rw-r--r--tests/testmisc.c30
2 files changed, 32 insertions, 2 deletions
diff --git a/pango/itemize.c b/pango/itemize.c
index 82c737cc..77e86507 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -1380,7 +1380,7 @@ split_item_for_variant (const char *text,
/* p0 .. p is a lowercase segment */
if (p < end)
{
- new_item = pango_item_split (item, p - p0, g_utf8_strlen (p, p - p0));
+ new_item = pango_item_split (item, p - p0, g_utf8_strlen (p0, p - p0));
list_item->data = new_item;
list_item = g_list_insert_before (list_item, list_item->next, item);
list_item = list_item->next;
@@ -1429,7 +1429,7 @@ split_item_for_variant (const char *text,
/* p0 .. p is a uppercase segment */
if (p < end)
{
- new_item = pango_item_split (item, p - p0, g_utf8_strlen (p, p - p0));
+ new_item = pango_item_split (item, p - p0, g_utf8_strlen (p0, p - p0));
list_item->data = new_item;
list_item = g_list_insert_before (list_item, list_item->next, item);
list_item = list_item->next;
diff --git a/tests/testmisc.c b/tests/testmisc.c
index a91dcbb3..555f0dce 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -779,6 +779,35 @@ test_wrap_char (void)
g_object_unref (context);
}
+/* Test the crash with Small Caps in itemization from #627 */
+static void
+test_small_caps_crash (void)
+{
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoFontDescription *desc;
+ int w, h;
+
+ if (strcmp (G_OBJECT_TYPE_NAME (pango_cairo_font_map_get_default ()), "PangoCairoCoreTextFontMap") == 0)
+ {
+ g_test_skip ("This test needs a fontmap that supports Small-Caps");
+ return;
+ }
+
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+ layout = pango_layout_new (context);
+ desc = pango_font_description_from_string ("Cantarell Small-Caps 11");
+ pango_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_layout_get_size (layout, &w, &h);
+
+ pango_font_description_free (desc);
+ g_object_unref (layout);
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
@@ -813,6 +842,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/gravity-metrics", test_gravity_metrics);
g_test_add_func ("/layout/wrap-char", test_wrap_char);
g_test_add_func ("/matrix/transform-rectangle", test_transform_rectangle);
+ g_test_add_func ("/itemize/small-caps-crash", test_small_caps_crash);
return g_test_run ();
}