[cairo] About cairo_show_text and UTF-8...

Owen Taylor otaylor at redhat.com
Thu Jan 5 19:02:17 PST 2006

On Thu, 2006-01-05 at 10:21 -0500, Scott Robert Ladd wrote:
> I'm running Cairo 1.0.2 and GTK+ 2.8.9 on a system with LANG=en_US.UTF-8
> and LC_ALL=en_US.UTF-8.
> In interface components like a GtkLabel, I can include UTF-8 encodings
> that display correctly, as in this line of code:
>    cos_label = gtk_label_new ("cos <i>\316\270</i>:");
>    gtk_widget_show (cos_label);
> However, when I try to display the same encoding using cairo_show_text,
> I see a rectangle instead of the expected theta character:
>      cairo_show_text(drawing_cr, "\316\270");
> I am using the system font (Sans) in Cairo.
> Am I missing something obvious?

Well, perhaps not obvious, but you should be using Pango as the text API
when using Cairo, just as you do for GTK+ or GDK.

  PangoLayout *layout = pango_cairo_create_layout (drawing_cr);
  pango_layout_set_text (layout, "\316\270");
  pango_cairo_show_layout(drawing_cr, layout);
  g_object_unref (layout);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060105/c5cabec3/attachment.pgp

More information about the cairo mailing list