#include <pango/pango.h>
#include <pango/pangocairo.h>

gint
main (gint    argc,
      gchar **argv)
{
  gint i;
  PangoContext *pc;
  PangoLayout  *pl;
  PangoFontMap *fontmap;

  gchar *string= "foo\n\rbar\r\nbaz\n\nqux\n\n..";

  fontmap = pango_cairo_font_map_get_default ();
  pc = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));

  pl = pango_layout_new (pc);

  pango_layout_set_text (pl, string, -1);

  for (i=0; string[i]; i++)
    {
      PangoRectangle rectA, rectB;

      pango_layout_get_cursor_pos (pl, i, &rectA, &rectB);
      g_print ("%i: '%c' %i, %i\n", i, string[i], rectA.x, rectA.y);

    }
  return 0;
}

#ifdef THE_GENERATED_OUTPUT

0: 'f' 0, 0
1: 'o' 6144, 0
2: 'o' 16384, 0
3: '
' 26624, 0
' 0, 19456
5: 'b' 0, 38912
6: 'a' 11264, 38912
7: 'r' 21504, 38912
' 29696, 38912
**
** Pango:ERROR:(/tmp/buildd/pango1.0-1.20.5/pango/pango-layout.c:2147):pango_layout_line_get_char_direction: code should not be reached
Aborted
#endif
