Re: pango text color in textbuffer
- From: Ahmed El-Helw <ahmed piousity net>
- To: Ahmed El-Helw <ahmed piousity net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: pango text color in textbuffer
- Date: Fri, 5 Aug 2005 18:48:27 -0400
does anyone have any ideas or can recommend an example i can look at?
thanks,
-ahmed
On Jul 28, 2005, at 12:18 AM, Ahmed El-Helw wrote:
hi all -
i am trying to write some code to populate a gtktextbuffer with
some arabic text.
however, due to the nature of the application i am writing, i need
to have a certain
word be potentially consistent of different colors [ie the first
letter is red, the rest of
the word is blue, or the middle two letters are blue and the rest
is green, etc].
the problem i am having is that the way i am doing it right now
breaks shaping.
i'd emailed owen about this, and he said that pango should handle
this, so i am
guessing that i am doing this wrong...
essentially, i am making two identical texttags, with the only
difference being the
color, and just setting half of the text using one tag and the
other half the text using
another.
the relevant code is pasted below:
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 the program looks very similar to what you can see at
this screenshot,
which i took from the original gtk# version that i wrote before
writing the c version.
http://piousity.net/images/arabic_html-04.29.2005.png
if someone can suggest to me a correct way to do this, i'd
appreciate it. please also
note that in the c# version, i also tried doing all of this with
one tag -- ie initialize the
tag, use it to insert the first half the string, then set the
foreground attribute to something
else, then try to put the second half in -- but that didn't work
either.
thanks,
-ahmed
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]