- a->start_index = 0;
- a->end_index = len;
- }
- pango_attr_list_insert(attrs, a);
-
- // Add dummy attributes (use colour as it's invisible anyhow for 0
- // width spaces) to ensure that the spaces in the beginning/end of the
- // string are underlined too.
- if ( addDummyAttrs )
- {
- wxASSERT_MSG( len > 2, "Must have 0-width spaces at string ends" );
-
+ wxCharBuffer buf(n + 6);
+ // copy the leading U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
+ memcpy(buf.data(), "\342\200\214", 3);
+ // copy the user string
+ memcpy(buf.data() + 3, text, n);
+ // copy the trailing U+200C ZERO WIDTH NON-JOINER encoded in UTF8 format
+ memcpy(buf.data() + 3 + n, "\342\200\214", 3);
+
+ pango_layout_set_text(layout, buf, n + 6);
+
+ // Add dummy attributes (use colour as it's invisible anyhow for 0
+ // width spaces) to ensure that the spaces in the beginning/end of the
+ // string are underlined too.