#include <string.h>

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

/* compile with the following commandline:
 *
 * gcc -Wall `pkg-config --libs --cflags pangoft2` -o pango-fontlist pango-fontlist.c
 */

void
pantest_list_fonts (void)
{
  PangoFontMap     *fontmap;
  PangoContext     *context;
  PangoFontFamily **families;
  PangoFontFace   **faces;
  gint              n_families;
  gint              n_faces;
  gint              i, j;

  fontmap = pango_ft2_font_map_new ();
  context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
  g_object_unref (fontmap);

  pango_font_map_list_families (fontmap, &families, &n_families);

  for (i = 0; i < n_families; i++)
    {
      pango_font_family_list_faces (families[i], &faces, &n_faces);

      for (j = 0; j < n_faces; j++)
        {
          PangoFontDescription *desc;

          desc = pango_font_face_describe (faces[j]);
          if (!strcmp ("LeBe", pango_font_description_get_family (desc)))
            g_printerr ("Font: %s\n", pango_font_description_to_string (desc));
          pango_font_description_free (desc);
        }
    }

  g_free (families);

  g_object_unref (context);
}

int
main (int argc, char *argv[])
{
  pantest_list_fonts ();
  return 0;
}
