List Info

Thread: Problem with Pango displaying Greek letters under Linux




Problem with Pango displaying Greek letters under Linux
user name
2006-03-01 17:10:19
I have a program with a GUI written in GTK+ (by me!) and I'd really like to be able to display Greek letters, rather than write things like ";alpha";. Note that this is not a programming question, because the problem is not how to put Greek letters in labels (as I found out how to do that). The program compiles fine, but when I run it, I get the following error message:

Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

and the Greek letters aren't displayed. I'm using version 1.8.2 of Pango and what's puzzling me is that the same code works fine under FreeBSD 6.0, with the same version of Pango. For information, I'm using things like "\u03B1" as the strings for the labels in GTK+, e.g.

GtkWidget *label = gtk_label_new("\u03B2");

Any ideas as to why this doesn't work right under Linux?

Thanks!
Problem with Pango displaying Greek letters under Linux
user name
2006-03-01 18:49:54
On Wed, 1 Mar 2006, Nick Chorley wrote:

> I have a program with a GUI written in GTK+ (by me!)
and I'd really like to
> be able to display Greek letters, rather than write
things like "alpha".
> Note that this is *not* a programming question, because
the problem is not
> how to put Greek letters in labels (as I found out how
to do that). The
> program compiles fine, but when I run it, I get the
following error message:
>
> Pango-WARNING **: Invalid UTF-8 string passed to
pango_layout_set_text()
>
> and the Greek letters aren't displayed. I'm using
version 1.8.2 of Pango and
> what's puzzling me is that *the same code works fine
under FreeBSD 6.0, with
> the same version of Pango*. For information, I'm using
things like "\u03B1"
> as the strings for the labels in GTK+, e.g.
>
> GtkWidget *label =
gtk_label_new("\u03B2");

The interpretation of such a thing pretty much depends on
your
compiler, but most probably this doesn't generate what you
have
in mind, or at list not on your Linux.  Try using
g_unichar_to_utf8 instead.

behdad


> Any ideas as to why this doesn't work right under
Linux?
>
> Thanks!

--behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two
says Blood Will Spill"
	-- Dan Bern, "New American Language"
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Problem with Pango displaying Greek letters under Linux
user name
2006-03-01 19:36:03
Thanks for the reply, Behdad. What is the correct way to do this? I can't work out what I need to pass for the first argument of g_unichar_to_utf8(). The GLib reference isn't very clear, it just tells me that a gunichar is "a type which can hold any UCS-4 character code". I've tried something like the following:

gchar *greekString;
g_unichar_to_utf8(03B1, greekString);,

which won't compile. I found an example on the web that has

g_unichar_to_utf8(0x399, buffer);

and while this compiles, the program seg faults when I try to run it.

Thanks again for the reply!

Nick

On 3/1/06, Behdad Esfahbod <cs.toronto.edu">behdadcs.toronto.edu> wrote:
The interpretation of such a thing pretty much depends on your
compiler, but most probably this doesn't generate what you have
in mind, or at list not on your Linux.&nbsp; Try using
g_unichar_to_utf8 instead.

behdad

Problem with Pango displaying Greek letters under Linux
user name
2006-03-01 20:06:18
On Wed, 1 Mar 2006, Nick Chorley wrote:

> Thanks for the reply, Behdad. What is the correct way
to do this? I can't
> work out what I need to pass for the first argument of
g_unichar_to_utf8().
> The GLib reference isn't very clear, it just tells me
that a gunichar is "a
> type which can hold any UCS-4 character code".
I've tried something like the
> following:
>
> gchar *greekString;
> g_unichar_to_utf8(03B1, greekString);,
>
> which won't compile. I found an example on the web
that has
>
> g_unichar_to_utf8(0x399, buffer);
>
> and while this compiles, the program seg faults when I
try to run it.

Something like:

char buf[7];
int len;

len = g_unichar_to_utf8 (0x03B1, buf);
buf[len] = '\0';

Or simply look up the UTF-8 representation of U+03B1 in
gucharmap
and use "\316\261".

behdad


> Thanks again for the reply!
>
> Nick
>
> On 3/1/06, Behdad Esfahbod <behdadcs.toronto.edu> wrote:
>
> > The interpretation of such a thing pretty much
depends on your
> > compiler, but most probably this doesn't generate
what you have
> > in mind, or at list not on your Linux.  Try using
> > g_unichar_to_utf8 instead.
> >
> > behdad
> >
> >
>

--behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two
says Blood Will Spill"
	-- Dan Bern, "New American Language"
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-listgnome.org

http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
Problem with Pango displaying Greek letters under Linux
user name
2006-03-01 20:31:38
Works like a charm, thanks very much Behdad!

Nick

On 3/1/06, Behdad Esfahbod <cs.toronto.edu">behdadcs.toronto.edu > wrote:
Something like:

char buf[7];
int len;

len = g_unichar_to_utf8 (0x03B1, buf);
buf[len] = '\0';

Or simply look up the UTF-8 representation of U+03B1 in gucharmap
and use "\316\261".

behdad

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )