color changes break arabic shaping
Submitted by Ahmed El-Helw
Link to original bug (#313181)
Description
not quite sure if this is a bug or programmer error -- but either way, two separate tests i've done with similar results.
the first: trying to write arabic text in a gtk_text_buffer, where some characters are in a different color than other characters.
i tried the following: tb = gtk_text_buffer_new(NULL); gtk_text_buffer_get_start_iter(tb, &textIter); tag = gtk_text_buffer_create_tag(tb, "black_settings", "justification", GTK_JUSTIFY_RIGHT, "wrap-mode", GTK_WRAP_WORD, "font", "Verdana 24", "foreground", "black", NULL); tag2 = gtk_text_buffer_create_tag(tb, "blue_settings", "justification", GTK_JUSTIFY_RIGHT, "wrap-mode", GTK_WRAP_WORD, "font", "Verdana 24", "foreground", "blue", NULL); gtk_text_buffer_insert(tb, &textIter, "Correct:\n", strlen("Correct:\n")); gtk_text_buffer_insert_with_tags(tb, &textIter, str, -1, tag, NULL);
gtk_text_buffer_insert(tb, &textIter, "\n\nNow:\n", strlen("\n\nNow:\n")); gtk_text_buffer_insert_with_tags(tb, &textIter, str, 33, tag, NULL); gtk_text_buffer_insert_with_tags(tb, &textIter, str+33, -1, tag2, NULL);
the output of this is broken shaping, as can be seen in this screenshot taking of a gtk# version of the above program: http://piousity.net/images/arabic_html-04.29.2005.png
the second thing i tried was due to me thinking that the above might be an error on my understanding of the apis. so i tried something simpler - populating a label and changing some of the colors of the label.
there are two subcases, one works, and one doesn't:
str = readArabicTextFromXML();
asprintf(&s2, "<span size="x-large" foreground="blue">%s</span>
<span
size="x-large" foreground="red">%s</span>
",
substr(str, 0, 33), substr(str, 33, strlen(str)));
pango_parse_markup(s2, -1, 0, &attrList, NULL, NULL, NULL); window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window1), _("window1"));
label1 = gtk_label_new (str); gtk_label_set_attributes(GTK_LABEL(label1), attrList);
in this case, although the substr splits it into two strings, where the first letter of the second word is part of the first string and the remainder of the second word is part of the second string, the first word comes up blue and the second comes up red [rather than the first word and first letter of second word being blue and the rest being red].
alternately, if you change the asprintf to be identical with the exception of the fact that you remove the color being red from the second half, it works as expected.
what i really want to do is be able to insert arabic text in a gtk_text_buffer, being able to have different colors amongst some of the letters, without breaking shaping. any help would be appreciated. thanks.
Version: 1.8.x