title: Using GTK/GDK to get Pango-rendered pixels
body: <p>I'm trying to get a bitmap rendered by Pango with a given character, in this case the letter "T".  I thought this should work, but it just prints out garbage..</p>
  
  <p>In this code, <code>gtk_window</code> is already initialized as a GTK window.</p>
  
  <pre><code>int width, height;
  PangoLayout *layout = gtk_widget_create_pango_layout(gtk_window, "T");
  PangoFontDescription *fontdesc = pango_font_description_from_string("Terminus 12");
  pango_layout_set_font_description (layout, fontdesc);
  pango_layout_get_pixel_size (layout, &amp;width, &amp;height);
  
  GdkPixmap *temp_pixmap = gdk_pixmap_new(NULL, width, height, 24) ;
  GdkGC *gc = gdk_gc_new(temp_pixmap);
  gdk_draw_layout( temp_pixmap, gc, 0, 0, layout) ;
  
  GdkColormap *cmap = gdk_colormap_get_system() ;
  GdkPixbuf *temp_pixbuf = gdk_pixbuf_get_from_drawable(NULL, temp_pixmap,
                                         cmap, 0, 0, 0, 0, width, height);
  
  int n_channels = gdk_pixbuf_get_n_channels (temp_pixbuf);
  int rowstride = gdk_pixbuf_get_rowstride(temp_pixbuf);
  guchar *pixels = gdk_pixbuf_get_pixels(temp_pixbuf);
  
  int i,j;
  for (j=0; j&lt;height; j++) {
      for (i=0; i&lt;(width*n_channels); i++) {
          printf("%02x ",
                 *(pixels + i + j*rowstride));
      }
      printf("\n");
  }
  </code></pre>
  
  <p>The output is different every time, but an example:</p>
  
  <pre><code>dd 24 f8 dd 24 f8 8f 28 28 8f 28 28 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  ef 14 ce 00 00 00 d0 00 20 00 00 00 ef 02 02 d0 00 01 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 fc 00 00 00 00 00 ef 02 02 00 03 40 00 00 b9 00 00 c8 
  00 00 01 00 00 07 00 00 07 00 00 00 00 00 02 00 00 00 00 00 d0 00 00 c8 
  00 00 01 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 
  00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 12 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 7a 4e 00 00 00 01 00 00 00 00 00 00 00 00 00 01 ff ff ff ff ff ff 
  ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  </code></pre>
  
  <p>Which looks nothing like the letter "T"!</p>
  
  <p>Any idea what I'm doing wrong? Thanks!</p>