示例#1
0
static void
pk_font_not_found (PangoLanguage *language)
{
	FcPattern *pat = NULL;
	gchar *tag = NULL;
	const gchar *lang;

	g_return_if_fail (language != NULL);

	/* convert to language */
	lang = pango_language_to_string (language);
	if (lang == NULL || lang[0] == '\0') {
		g_warning ("failed to convert language to string");
		goto out;
	}

	/* create the font tag used in as a package provides */
	pat = FcPatternCreate ();
	FcPatternAddString (pat, FC_LANG, (FcChar8 *) lang);
	tag = (gchar *) FcNameUnparse (pat);
	if (tag == NULL || tag[0] == '\0') {
		g_warning ("failed to create font tag: %s", lang);
		goto out;
	}

	/* add to array for processing in idle callback */
	queue_install_fonts_tag (tag);

out:
	if (pat != NULL)
		FcPatternDestroy (pat);
	if (tag != NULL)
		free (tag);
}
示例#2
0
int iupdrvOpen(int *argc, char ***argv)
{
  GtkStyle* style;

  if (!gtk_init_check(argc, argv))
    return IUP_ERROR;
  
  IupSetGlobal("DRIVER", "GTK");

  IupStoreGlobal("SYSTEMLANGUAGE", pango_language_to_string(gtk_get_default_language()));

  /* driver system version */
  IupSetfAttribute(NULL, "GTKVERSION", "%d.%d.%d", gtk_major_version, 
                                                   gtk_minor_version, 
                                                   gtk_micro_version);
  IupSetfAttribute(NULL, "GTKDEVVERSION", "%d.%d.%d", GTK_MAJOR_VERSION, 
                                                      GTK_MINOR_VERSION, 
                                                      GTK_MICRO_VERSION);

  gtkSetDrvGlobalAttrib();

  style = gtk_style_new();
  iupgtkUpdateGlobalColors(style);
  IupSetGlobal("_IUP_RESET_GLOBALCOLORS", "YES");  /* will update the global colors when the first dialog is mapped */
  g_object_unref(style);

  return IUP_NOERROR;
}
示例#3
0
/**
 * pango_language_includes_script:
 * @language: a PangoLanguage
 * @script: a #PangoScript
 * 
 * Determines if @script is one of the scripts used to
 * write @language. The returned value is conservative;
 * if nothing is known about the language tag @language,
 * %TRUE will be returned, since, as far as Pango knows,
 * @script might be used to write @language.
 *
 * This routine is used in Pango's itemization process when
 * determining if a supplied language tag is relevant to
 * a particular section of text. It probably is not useful for
 * applications in most circumstances.
 * 
 * Return value: %TRUE if @script is one of the scripts used
 * to write @language, or if nothing is known about @language.
 *
 * Since: 1.4
 **/
gboolean
pango_language_includes_script (PangoLanguage *language,
				PangoScript    script)
{
  PangoScriptForLang *script_for_lang;
  unsigned int j;

  g_return_val_if_fail (language != NULL, FALSE);

  if (!REAL_SCRIPT (script))
    return TRUE;

  /* This bsearch could be optimized to occur only once if
   * we store the pointer to the PangoScriptForLang in the
   * same block as the string value for the PangoLanguage.
   */
  script_for_lang = bsearch (pango_language_to_string (language),
			     pango_script_for_lang,
			     G_N_ELEMENTS (pango_script_for_lang),
			     sizeof (PangoScriptForLang),
			     script_for_lang_compare);
  if (!script_for_lang)
    return TRUE;

  for (j = 0; j < G_N_ELEMENTS (script_for_lang->scripts); j++)
    if (script_for_lang->scripts[j] == script)
      return TRUE;

  return FALSE;
}
示例#4
0
int iupdrvOpen(int *argc, char ***argv)
{
  char* value;

  if (!gtk_init_check(argc, argv))
    return IUP_ERROR;

#if defined(IUPGTK_DEBUG)
  g_log_set_default_handler(iupgtk_log, NULL);
#endif

  IupSetGlobal("DRIVER", "GTK");

  IupStoreGlobal("SYSTEMLANGUAGE", pango_language_to_string(gtk_get_default_language()));

  /* driver system version */
  IupSetfAttribute(NULL, "GTKVERSION", "%d.%d.%d", gtk_major_version, 
                                                   gtk_minor_version, 
                                                   gtk_micro_version);
  IupSetfAttribute(NULL, "GTKDEVVERSION", "%d.%d.%d", GTK_MAJOR_VERSION, 
                                                      GTK_MINOR_VERSION, 
                                                      GTK_MICRO_VERSION);

  gtkSetGlobalAttrib();

  gtkSetGlobalColors();

  IupSetGlobal("SHOWMENUIMAGES", "YES");

  value = getenv("UBUNTU_MENUPROXY");  /* for now only in Ubuntu */
  if (value && (iupStrEqualNoCase(value, "libappmenu.so") || iupStrEqualNoCase(value, "1")))
    IupSetGlobal("GLOBALMENU", "Yes");
  
  return IUP_NOERROR;
}
CefString ClientApp::GetCurrentLanguage()
{
    const char* locconst =  pango_language_to_string( gtk_get_default_language() );
    //Rado: for me it prints "en-us", so I have to strip everything after the "-"
    char loc[10] = {0};
    strncpy(loc, locconst, 9);
    for(int i=0; i<8; i++)
        if ( (loc[i] == '-') || (loc[i] == '_') ) { loc[i] = 0; break; }

    //TODO Explore possibility of using locale as-is, without stripping
    return CefString(loc);
}
示例#6
0
int main (int argc, char *argv[]) {
	GtkWidget * window, * warning;
	char locale[3];
	const char * lang = pango_language_to_string (gtk_get_default_language ());

	locale[0] = lang[0];
	locale[1] = lang[1];
	locale[2] = '\0';

	setlocale(LC_ALL, "");
	char * lng = setlocale(LC_MESSAGES, "");
	g_debug("setlocale(LC_MESSAGES, \"%s\") = %s", locale, lng);

	lng = setlocale(LC_NUMERIC, "C");
	g_debug("setlocale(LC_NUMERIC, \"C\") = %s", lng);

#ifdef ENABLE_NLS
	bindtextdomain (PACKAGE, saa_locale_directory());
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain (PACKAGE);
	printf("%s : %s ; %s\n", PACKAGE, saa_locale_directory(), locale);
#endif

	//gtk_disable_setlocale();
	gtk_init (&argc, &argv);
	//printf("setlocale(LC_ALL, NULL) :\n%s\n", setlocale(LC_ALL, NULL));
	gtk_gl_init (&argc, &argv);

	switch(argc) {
	case 1:
	  window = saa_main_window_new("");
	  break;
	case 2:
	  window = saa_main_window_new(argv[1]);
	  break;
	default:
	  window = saa_main_window_new("");
	  warning = gtk_message_dialog_new (GTK_WINDOW(window),
              GTK_DIALOG_DESTROY_WITH_PARENT,
              GTK_MESSAGE_WARNING,
              GTK_BUTTONS_CLOSE,
              "usage : gsolaar [solid.saa]\n");
	  gtk_dialog_run(GTK_DIALOG(warning));
	  gtk_widget_destroy(warning);
	}
	gtk_widget_show (window);

	gtk_main();

	gtk_widget_destroy(window);

	return 0;
}
示例#7
0
/* The fact that this comparison function works is dependent
 * on a property of the pango_script_lang_table which accidental rather
 * than inherent.
 *
 * The property is if we take any element in the table and suffix it
 * <elem>-<suffix> then that must strcmp() between any elements
 * preceding the element in the table and any element following in the
 * table. So, if we had something like:
 *
 * 'zh'
 *' zh-cn'
 *
 * in the table we would have a problem since 'zh-tw' follows 'zh-cn'.
 * On the other hand:
 *
 * 'zh'
 * 'zha'
 *
 * Works because 'zh-tw' precedes 'zha'.
 */
static int
script_for_lang_compare (gconstpointer key,
			 gconstpointer member)
{
  PangoLanguage *lang = (PangoLanguage *)key;
  const PangoScriptForLang *script_for_lang = member;

  if (pango_language_matches (lang, script_for_lang->lang))
    return 0;
  else
    return strcmp (pango_language_to_string (lang),
		   script_for_lang->lang);
}
示例#8
0
static void
text_to_glyphs (cairo_t *cr,
                const gchar *text,
                cairo_glyph_t **glyphs,
                int *num_glyphs)
{
  PangoAttribute *fallback_attr;
  PangoAttrList *attr_list;
  PangoContext *context;
  PangoDirection base_dir;
  GList *items;
  GList *visual_items;
  FT_Face ft_face;
  hb_font_t *hb_font;
  gdouble x = 0, y = 0;
  gint i;
  gdouble x_scale, y_scale;

  *num_glyphs = 0;
  *glyphs = NULL;

  base_dir = pango_find_base_dir (text, -1);

  cairo_scaled_font_t *cr_font = cairo_get_scaled_font (cr);
  ft_face = cairo_ft_scaled_font_lock_face (cr_font);
  hb_font = hb_ft_font_create (ft_face, NULL);

  cairo_surface_t *target = cairo_get_target (cr);
  cairo_surface_get_device_scale (target, &x_scale, &y_scale);

  /* We abuse pango itemazation to split text into script and direction
   * runs, since we use our fonts directly no through pango, we don't
   * bother changing the default font, but we disable font fallback as
   * pango will split runs at font change */
  context = pango_cairo_create_context (cr);
  attr_list = pango_attr_list_new ();
  fallback_attr = pango_attr_fallback_new (FALSE);
  pango_attr_list_insert (attr_list, fallback_attr);
  items = pango_itemize_with_base_dir (context, base_dir,
                                       text, 0, strlen (text),
                                       attr_list, NULL);
  g_object_unref (context);
  pango_attr_list_unref (attr_list);

  /* reorder the items in the visual order */
  visual_items = pango_reorder_items (items);

  while (visual_items) {
    PangoItem *item;
    PangoAnalysis analysis;
    hb_buffer_t *hb_buffer;
    hb_glyph_info_t *hb_glyphs;
    hb_glyph_position_t *hb_positions;
    gint n;

    item = visual_items->data;
    analysis = item->analysis;

    hb_buffer = hb_buffer_create ();
    hb_buffer_add_utf8 (hb_buffer, text, -1, item->offset, item->length);
    hb_buffer_set_script (hb_buffer, hb_glib_script_to_script (analysis.script));
    hb_buffer_set_language (hb_buffer, hb_language_from_string (pango_language_to_string (analysis.language), -1));
    hb_buffer_set_direction (hb_buffer, analysis.level % 2 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);

    hb_shape (hb_font, hb_buffer, NULL, 0);

    n = hb_buffer_get_length (hb_buffer);
    hb_glyphs = hb_buffer_get_glyph_infos (hb_buffer, NULL);
    hb_positions = hb_buffer_get_glyph_positions (hb_buffer, NULL);

    *glyphs = g_renew (cairo_glyph_t, *glyphs, *num_glyphs + n);

    for (i = 0; i < n; i++) {
      (*glyphs)[*num_glyphs + i].index = hb_glyphs[i].codepoint;
      (*glyphs)[*num_glyphs + i].x = x + (hb_positions[i].x_offset / (64. * x_scale));
      (*glyphs)[*num_glyphs + i].y = y - (hb_positions[i].y_offset / (64. * y_scale));
      x += (hb_positions[i].x_advance / (64. * x_scale));
      y -= (hb_positions[i].y_advance / (64. * y_scale));
    }

    *num_glyphs += n;

    hb_buffer_destroy (hb_buffer);

    visual_items = visual_items->next;
  }

  g_list_free_full (visual_items, (GDestroyNotify) pango_item_free);
  g_list_free_full (items, (GDestroyNotify) pango_item_free);

  hb_font_destroy (hb_font);
  cairo_ft_scaled_font_unlock_face (cr_font);
}
示例#9
0
/**
 * gail_misc_get_default_attributes:
 * @attrib_set: The #AtkAttributeSet to add the attribute to
 * @layout: The PangoLayout from which the attributes will be obtained
 * @widget: The GtkWidget for which the default attributes are required.
 *
 * Adds the default attributes to the specified attribute set.
 *
 * Returns: A pointer to the #AtkAttributeSet.
 **/
AtkAttributeSet* 
gail_misc_get_default_attributes (AtkAttributeSet *attrib_set,
                                  PangoLayout     *layout,
                                  GtkWidget       *widget)
{
  PangoContext *context;
  GtkStyleContext *style_context;
  gint int_value;
  PangoWrapMode mode;
  GdkRGBA color;
  gchar *value;

  attrib_set = gail_misc_add_attribute (attrib_set, 
                                        ATK_TEXT_ATTR_DIRECTION,
     g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_DIRECTION, 
                                        gtk_widget_get_direction (widget))));

  context = pango_layout_get_context (layout);
  if (context)
    {
      PangoLanguage* language;
      PangoFontDescription* font;

      language = pango_context_get_language (context);
      if (language)
        {
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_LANGUAGE,
                      g_strdup (pango_language_to_string (language)));
        }
      font = pango_context_get_font_description (context);
      if (font)
        {
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_STYLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE,
                                   pango_font_description_get_style (font))));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_VARIANT,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT,
                                   pango_font_description_get_variant (font))));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_STRETCH,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH,
                                   pango_font_description_get_stretch (font))));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_FAMILY_NAME,
              g_strdup (pango_font_description_get_family (font)));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_WEIGHT,
                    g_strdup_printf ("%d",
                                   pango_font_description_get_weight (font)));
          attrib_set = gail_misc_add_attribute (attrib_set,
                                                ATK_TEXT_ATTR_SIZE,
                    g_strdup_printf ("%i",
                                   pango_font_description_get_size (font) / PANGO_SCALE));
        }
    }
  if (pango_layout_get_justify (layout))
    {
      int_value = 3;
    }
  else
    {
      PangoAlignment align;

      align = pango_layout_get_alignment (layout);
      if (align == PANGO_ALIGN_LEFT)
        int_value = 0;
      else if (align == PANGO_ALIGN_CENTER)
        int_value = 2;
      else /* if (align == PANGO_ALIGN_RIGHT) */
        int_value = 1;
    }
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_JUSTIFICATION,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_JUSTIFICATION, 
                                                      int_value))); 
  mode = pango_layout_get_wrap (layout);
  if (mode == PANGO_WRAP_WORD)
    int_value = 2;
  else /* if (mode == PANGO_WRAP_CHAR) */
    int_value = 1;
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_WRAP_MODE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE, 
                                                      int_value))); 

  style_context = gtk_widget_get_style_context (widget);

  gtk_style_context_get_background_color (style_context, 0, &color);
  value = g_strdup_printf ("%u,%u,%u",
                           (guint) ceil (color.red * 65536 - color.red),
                           (guint) ceil (color.green * 65536 - color.green),
                           (guint) ceil (color.blue * 65536 - color.blue));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_BG_COLOR,
                                        value); 

  gtk_style_context_get_color (style_context, 0, &color);
  value = g_strdup_printf ("%u,%u,%u",
                           (guint) ceil (color.red * 65536 - color.red),
                           (guint) ceil (color.green * 65536 - color.green),
                           (guint) ceil (color.blue * 65536 - color.blue));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_FG_COLOR,
                                        value); 

  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_FG_STIPPLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_FG_STIPPLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_BG_STIPPLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_BG_STIPPLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_STRIKETHROUGH,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_UNDERLINE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_RISE,
                                               g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_SCALE,
                                               g_strdup_printf ("%g", 1.0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_BG_FULL_HEIGHT,
                                               g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_PIXELS_INSIDE_WRAP,
                                               g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_PIXELS_BELOW_LINES,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_PIXELS_ABOVE_LINES,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_EDITABLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_EDITABLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_INVISIBLE,
              g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_INVISIBLE, 
                                                      0))); 
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_INDENT,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_RIGHT_MARGIN,
                                        g_strdup_printf ("%i", 0));
  attrib_set = gail_misc_add_attribute (attrib_set,
                                        ATK_TEXT_ATTR_LEFT_MARGIN,
                                        g_strdup_printf ("%i", 0));
  return attrib_set;
}
示例#10
0
/**
 * gail_misc_layout_get_run_attributes:
 * @attrib_set: The #AtkAttributeSet to add the attribute to
 * @layout: The PangoLayout from which the attributes will be obtained
 * @text: The text 
 * @offset: The offset at which the attributes are required
 * @start_offset: The start offset of the current run
 * @end_offset: The end offset of the current run
 *
 * Adds the attributes for the run starting at offset to the specified
 * attribute set.
 *
 * Returns: A pointer to the #AtkAttributeSet.
 **/
AtkAttributeSet* 
gail_misc_layout_get_run_attributes (AtkAttributeSet *attrib_set,
                                     PangoLayout     *layout,
                                     const gchar     *text,
                                     gint            offset,
                                     gint            *start_offset,
                                     gint            *end_offset)
{
  PangoAttrIterator *iter;
  PangoAttrList *attr;  
  PangoAttrString *pango_string;
  PangoAttrInt *pango_int;
  PangoAttrColor *pango_color;
  PangoAttrLanguage *pango_lang;
  PangoAttrFloat *pango_float;
  gint index, start_index, end_index;
  gboolean is_next = TRUE;
  gchar *value = NULL;
  glong len;

  len = g_utf8_strlen (text, -1);
  /* Grab the attributes of the PangoLayout, if any */
  if ((attr = pango_layout_get_attributes (layout)) == NULL)
    {
      *start_offset = 0;
      *end_offset = len;
      return attrib_set;
    }
  iter = pango_attr_list_get_iterator (attr);
  /* Get invariant range offsets */
  /* If offset out of range, set offset in range */
  if (offset > len)
    offset = len;
  else if (offset < 0)
    offset = 0;

  index = g_utf8_offset_to_pointer (text, offset) - text;
  pango_attr_iterator_range (iter, &start_index, &end_index);
  while (is_next)
    {
      if (index >= start_index && index < end_index)
        {
          *start_offset = g_utf8_pointer_to_offset (text, 
                                                    text + start_index);  
          if (end_index == G_MAXINT)
          /* Last iterator */
            end_index = len;
      
          *end_offset = g_utf8_pointer_to_offset (text, 
                                                  text + end_index);  
          break;
        }  
      is_next = pango_attr_iterator_next (iter);
      pango_attr_iterator_range (iter, &start_index, &end_index);
    }
  /* Get attributes */
  if ((pango_string = (PangoAttrString*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_FAMILY)) != NULL)
    {
      value = g_strdup_printf("%s", pango_string->value);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_FAMILY_NAME, 
                                            value);
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_STYLE)) != NULL)
    {
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_STYLE, 
      g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STYLE, pango_int->value)));
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_WEIGHT)) != NULL)
    {
      value = g_strdup_printf("%i", pango_int->value);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_WEIGHT, 
                                            value);
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_VARIANT)) != NULL)
    {
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_VARIANT, 
       g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_VARIANT, pango_int->value)));
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_STRETCH)) != NULL)
    {
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_STRETCH, 
       g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRETCH, pango_int->value)));
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_SIZE)) != NULL)
    {
      value = g_strdup_printf("%i", pango_int->value / PANGO_SCALE);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_SIZE,
                                            value);
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_UNDERLINE)) != NULL)
    {
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_UNDERLINE, 
       g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_UNDERLINE, pango_int->value)));
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_STRIKETHROUGH)) != NULL)
    {
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_STRIKETHROUGH, 
       g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_STRIKETHROUGH, pango_int->value)));
    } 
  if ((pango_int = (PangoAttrInt*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_RISE)) != NULL)
    {
      value = g_strdup_printf("%i", pango_int->value);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_RISE,
                                            value);
    } 
  if ((pango_lang = (PangoAttrLanguage*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_LANGUAGE)) != NULL)
    {
      value = g_strdup( pango_language_to_string( pango_lang->value));
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_LANGUAGE, 
                                            value);
    } 
  if ((pango_float = (PangoAttrFloat*) pango_attr_iterator_get (iter, 
                                   PANGO_ATTR_SCALE)) != NULL)
    {
      value = g_strdup_printf("%g", pango_float->value);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_SCALE, 
                                            value);
    } 
  if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter, 
                                    PANGO_ATTR_FOREGROUND)) != NULL)
    {
      value = g_strdup_printf ("%u,%u,%u", 
                               pango_color->color.red, 
                               pango_color->color.green, 
                               pango_color->color.blue);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_FG_COLOR, 
                                            value);
    } 
  if ((pango_color = (PangoAttrColor*) pango_attr_iterator_get (iter, 
                                     PANGO_ATTR_BACKGROUND)) != NULL)
    {
      value = g_strdup_printf ("%u,%u,%u", 
                               pango_color->color.red, 
                               pango_color->color.green, 
                               pango_color->color.blue);
      attrib_set = gail_misc_add_attribute (attrib_set, 
                                            ATK_TEXT_ATTR_BG_COLOR, 
                                            value);
    } 
  pango_attr_iterator_destroy (iter);
  return attrib_set;
}
示例#11
0
/**
 * pango_ot_tag_from_language:
 * @language: A #PangoLanguage, or %NULL
 *
 * Finds the OpenType language-system tag best describing @language.
 *
 * Return value: #PangoOTTag best matching @language or
 * %PANGO_OT_TAG_DEFAULT_LANGUAGE if none found or if @language
 * is %NULL.
 *
 * Since: 1.18
 **/
PangoOTTag
pango_ot_tag_from_language (PangoLanguage *language)
{
    return (PangoOTTag) hb_ot_tag_from_language (hb_language_from_string (pango_language_to_string (language), -1));
}
示例#12
0
static void
print_attr (PangoAttribute *attr, GString *string)
{
  g_string_append_printf (string, "[%d %d] ", attr->start_index, attr->end_index);
  switch (attr->klass->type)
    {
    case PANGO_ATTR_LANGUAGE:
      g_string_append_printf (string,"language %s\n", pango_language_to_string (((PangoAttrLanguage *)attr)->value));
      break;
    case PANGO_ATTR_FAMILY:
      g_string_append_printf (string,"family %s\n", ((PangoAttrString *)attr)->value);
      break;
    case PANGO_ATTR_STYLE:
      g_string_append_printf (string,"style %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_WEIGHT:
      g_string_append_printf (string,"weight %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_VARIANT:
      g_string_append_printf (string,"variant %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_STRETCH:
      g_string_append_printf (string,"stretch %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_SIZE:
      g_string_append_printf (string,"size %d\n", ((PangoAttrSize *)attr)->size);
      break;
    case PANGO_ATTR_FONT_DESC:
      g_string_append_printf (string,"font %s\n", pango_font_description_to_string (((PangoAttrFontDesc *)attr)->desc));
      break;
    case PANGO_ATTR_FOREGROUND:
      g_string_append_printf (string,"foreground %s\n", pango_color_to_string (&((PangoAttrColor *)attr)->color));
      break;
    case PANGO_ATTR_BACKGROUND:
      g_string_append_printf (string,"background %s\n", pango_color_to_string (&((PangoAttrColor *)attr)->color));
      break;
    case PANGO_ATTR_UNDERLINE:
      g_string_append_printf (string,"underline %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_STRIKETHROUGH:
      g_string_append_printf (string,"strikethrough %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_RISE:
      g_string_append_printf (string,"rise %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_SHAPE:
      g_string_append_printf (string,"shape\n");
      break;
    case PANGO_ATTR_SCALE:
      g_string_append_printf (string,"scale %f\n", ((PangoAttrFloat *)attr)->value);
      break;
    case PANGO_ATTR_FALLBACK:
      g_string_append_printf (string,"fallback %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_LETTER_SPACING:
      g_string_append_printf (string,"letter-spacing %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_UNDERLINE_COLOR:
      g_string_append_printf (string,"underline-color %s\n", pango_color_to_string (&((PangoAttrColor *)attr)->color));
      break;
    case PANGO_ATTR_STRIKETHROUGH_COLOR:
      g_string_append_printf (string,"strikethrough-color %s\n", pango_color_to_string (&((PangoAttrColor *)attr)->color));
      break;
    case PANGO_ATTR_ABSOLUTE_SIZE:
      g_string_append_printf (string,"absolute-size %d\n", ((PangoAttrSize *)attr)->size);
      break;
    case PANGO_ATTR_GRAVITY:
      g_string_append_printf (string,"gravity %d\n", ((PangoAttrInt *)attr)->value);
      break;
    case PANGO_ATTR_GRAVITY_HINT:
      g_string_append_printf (string,"gravity-hint %d\n", ((PangoAttrInt *)attr)->value);
      break;
    default:
      g_assert_not_reached ();
      break;
    }
}
示例#13
0
static VALUE
rg_to_str(VALUE self)
{
    return CSTR2RVAL(pango_language_to_string(_SELF(self)));
}
static void
gtk_text_buffer_insert_markup(GtkTextBuffer * buffer, GtkTextIter * iter,
			      const gchar * markup)
{
    PangoAttrIterator *paiter;
    PangoAttrList *attrlist;
    GtkTextMark *mark;
    GError *error = NULL;
    gchar *text;

    g_return_if_fail(GTK_IS_TEXT_BUFFER(buffer));
    g_return_if_fail(markup != NULL);

    if (*markup == '\000')
	return;

    /* invalid */
    if (!pango_parse_markup(markup, -1, 0, &attrlist, &text, NULL, &error)) {
	g_warning("Invalid markup string: %s", error->message);
	g_error_free(error);
	return;
    }

    /* trivial, no markup */
    if (attrlist == NULL) {
	gtk_text_buffer_insert(buffer, iter, text, -1);
	g_free(text);
	return;
    }

    /* create mark with right gravity */
    mark = gtk_text_buffer_create_mark(buffer, NULL, iter, FALSE);
    paiter = pango_attr_list_get_iterator(attrlist);

    do {
	PangoAttribute *attr;
	GtkTextTag *tag;
	GtkTextTag *tag_para;
	gint start, end;

	pango_attr_iterator_range(paiter, &start, &end);

	if (end == G_MAXINT)	/* last chunk */
	    end = start - 1;	/* resulting in -1 to be passed to _insert */

	tag = gtk_text_tag_new(NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_LANGUAGE)))
	    g_object_set(tag, "language",
			 pango_language_to_string(((PangoAttrLanguage *)
						   attr)->value), NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_FAMILY)))
	    g_object_set(tag, "family", ((PangoAttrString *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_STYLE)))
	    g_object_set(tag, "style", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_WEIGHT)))
	    g_object_set(tag, "weight", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_VARIANT)))
	    g_object_set(tag, "variant", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_STRETCH)))
	    g_object_set(tag, "stretch", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_SIZE)))
	    g_object_set(tag, "size", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_FONT_DESC)))
	    g_object_set(tag, "font-desc",
			 ((PangoAttrFontDesc *) attr)->desc, NULL);

	if ((attr =
	     pango_attr_iterator_get(paiter, PANGO_ATTR_FOREGROUND))) {
	    GdkColor col = { 0,
		((PangoAttrColor *) attr)->color.red,
		((PangoAttrColor *) attr)->color.green,
		((PangoAttrColor *) attr)->color.blue
	    };

	    g_object_set(tag, "foreground-gdk", &col, NULL);
	}

	if ((attr =
	     pango_attr_iterator_get(paiter, PANGO_ATTR_BACKGROUND))) {
	    GdkColor col = { 0,
		((PangoAttrColor *) attr)->color.red,
		((PangoAttrColor *) attr)->color.green,
		((PangoAttrColor *) attr)->color.blue
	    };

	    g_object_set(tag, "background-gdk", &col, NULL);
	}

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_UNDERLINE)))
	    g_object_set(tag, "underline", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr =
	     pango_attr_iterator_get(paiter, PANGO_ATTR_STRIKETHROUGH)))
	    g_object_set(tag, "strikethrough",
			 (gboolean) (((PangoAttrInt *) attr)->value != 0),
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_RISE)))
	    g_object_set(tag, "rise", ((PangoAttrInt *) attr)->value,
			 NULL);

	if ((attr = pango_attr_iterator_get(paiter, PANGO_ATTR_SCALE)))
	    g_object_set(tag, "scale", ((PangoAttrFloat *) attr)->value,
			 NULL);

	gtk_text_tag_table_add(gtk_text_buffer_get_tag_table(buffer), tag);

	tag_para =
	    gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table
				      (buffer), "para");
	gtk_text_buffer_insert_with_tags(buffer, iter, text + start,
					 end - start, tag, tag_para, NULL);

	/* mark had right gravity, so it should be
	 *      at the end of the inserted text now */
	gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
    } while (pango_attr_iterator_next(paiter));

    gtk_text_buffer_delete_mark(buffer, mark);
    pango_attr_iterator_destroy(paiter);
    pango_attr_list_unref(attrlist);
    g_free(text);
}
示例#15
0
String defaultLanguage()
{
    return pango_language_to_string(gtk_get_default_language());
}
示例#16
0
static VALUE
rg_language(VALUE self)
{
    return CSTR2RVAL(pango_language_to_string(gtk_text_iter_get_language(_SELF(self))));
}
示例#17
0
static VALUE
rg_s_to_string(G_GNUC_UNUSED VALUE self, VALUE language)
{
    return CSTR2RVAL(pango_language_to_string(RVAL2CSTR(language)));
}
示例#18
0
static gboolean
cb_gnm_pango_attr_dump (PangoAttribute *attr, gpointer user_data)
{
	g_print ("  start=%u; end=%u\n", attr->start_index, attr->end_index);
	switch (attr->klass->type) {
	case PANGO_ATTR_FAMILY:
		g_print ("    family=\"%s\"\n", ((PangoAttrString *)attr)->value);
		break;
	case PANGO_ATTR_LANGUAGE:
		g_print ("    language=\"%s\"\n", pango_language_to_string (((PangoAttrLanguage *)attr)->value));
		break;
	case PANGO_ATTR_STYLE:
		g_print ("    style=%s\n",
			 enum_name (PANGO_TYPE_STYLE, ((PangoAttrInt *)attr)->value));
		break;
	case PANGO_ATTR_WEIGHT:
		g_print ("    weight=%s\n",
			 enum_name (PANGO_TYPE_WEIGHT, ((PangoAttrInt *)attr)->value));
		break;
	case PANGO_ATTR_VARIANT:
		g_print ("    variant=%s\n",
			 enum_name (PANGO_TYPE_VARIANT, ((PangoAttrInt *)attr)->value));
		break;
	case PANGO_ATTR_STRETCH:
		g_print ("    stretch=%s\n",
			 enum_name (PANGO_TYPE_STRETCH, ((PangoAttrInt *)attr)->value));
		break;
	case PANGO_ATTR_UNDERLINE:
		g_print ("    underline=%s\n",
			 enum_name (PANGO_TYPE_UNDERLINE, ((PangoAttrInt *)attr)->value));
		break;
	case PANGO_ATTR_STRIKETHROUGH:
		g_print ("    strikethrough=%d\n", ((PangoAttrInt *)attr)->value);
		break;
	case PANGO_ATTR_RISE:
		g_print ("    rise=%d\n", ((PangoAttrInt *)attr)->value);
		break;
	case PANGO_ATTR_FALLBACK:
		g_print ("    fallback=%d\n", ((PangoAttrInt *)attr)->value);
		break;
	case PANGO_ATTR_LETTER_SPACING:
		g_print ("    letter_spacing=%d\n", ((PangoAttrInt *)attr)->value);
		break;
	case PANGO_ATTR_SIZE:
		g_print ("    size=%d%s\n",
			 ((PangoAttrSize *)attr)->size,
			 ((PangoAttrSize *)attr)->absolute ? " abs" : "");
		break;
	case PANGO_ATTR_SCALE:
		g_print ("    scale=%g\n", ((PangoAttrFloat *)attr)->value);
		break;
	case PANGO_ATTR_FOREGROUND:
		g_print ("    foreground=%s\n", color_to_string (((PangoAttrColor *)attr)->color));
		break;
	case PANGO_ATTR_BACKGROUND:
		g_print ("    background=%s\n", color_to_string (((PangoAttrColor *)attr)->color));
		break;
	case PANGO_ATTR_UNDERLINE_COLOR:
		g_print ("    underline_color=%s\n", color_to_string (((PangoAttrColor *)attr)->color));
		break;
	case PANGO_ATTR_STRIKETHROUGH_COLOR:
		g_print ("    strikethrough_color=%s\n", color_to_string (((PangoAttrColor *)attr)->color));
		break;
	case PANGO_ATTR_FONT_DESC: {
		char *desc = pango_font_description_to_string (((PangoAttrFontDesc*)attr)->desc);
		g_print  ("    font=\"%s\"\n", desc);
		g_free (desc);
		break;
	}
	default:
		g_print ("    type=%s\n", enum_name (PANGO_TYPE_ATTR_TYPE, attr->klass->type));
	}

	return FALSE;
}
示例#19
0
static int
go_pango_attr_as_markup_string (PangoAttribute *a, GString *gstr)
{
	int spans = 0;

	switch (a->klass->type) {
	case PANGO_ATTR_FONT_DESC :
		{
			char *str = pango_font_description_to_string
				(((PangoAttrFontDesc *)a)->desc);
			spans += 1;
			g_string_append_printf (gstr, "<span font_desc=\"%s\">", str);
			g_free (str);
		}
		break;
	case PANGO_ATTR_FAMILY :
		spans += 1;
		g_string_append_printf (gstr, "<span font_family=\"%s\">",
					((PangoAttrString *)a)->value);
		break;
	case PANGO_ATTR_ABSOLUTE_SIZE :
	case PANGO_ATTR_SIZE :
		spans += 1;
		g_string_append_printf (gstr, "<span font_size=\"%i\">",
					((PangoAttrSize *)a)->size);
		break;
	case PANGO_ATTR_RISE:
		spans += 1;
		g_string_append_printf (gstr, "<span rise=\"%i\">",
					((PangoAttrInt *)a)->value);
		break;
	case PANGO_ATTR_STYLE :
		spans += 1;
		switch (((PangoAttrInt *)a)->value) {
		case PANGO_STYLE_ITALIC:
			g_string_append (gstr, "<span font_style=\"italic\">");
			break;
		case PANGO_STYLE_OBLIQUE:
			g_string_append (gstr, "<span font_style=\"oblique\">");
			break;
		case PANGO_STYLE_NORMAL:
		default:
			g_string_append (gstr, "<span font_style=\"normal\">");
			break;
		}
		break;
	case PANGO_ATTR_WEIGHT :
		spans += 1;
		g_string_append_printf (gstr, "<span font_weight=\"%i\">",
					((PangoAttrInt *)a)->value);
	break;
	case PANGO_ATTR_STRIKETHROUGH :
		spans += 1;
		if (((PangoAttrInt *)a)->value)
			g_string_append (gstr, "<span strikethrough=\"true\">");
		else
			g_string_append (gstr, "<span strikethrough=\"false\">");
		break;
	case PANGO_ATTR_UNDERLINE :
		spans += 1;
		switch (((PangoAttrInt *)a)->value) {
		case PANGO_UNDERLINE_SINGLE:
			g_string_append (gstr, "<span underline=\"single\">");
			break;
		case PANGO_UNDERLINE_DOUBLE:
			g_string_append (gstr, "<span underline=\"double\">");
			break;
		case PANGO_UNDERLINE_LOW:
			g_string_append (gstr, "<span underline=\"low\">");
			break;
		case PANGO_UNDERLINE_ERROR:
			g_string_append (gstr, "<span underline=\"error\">");
			break;
		case PANGO_UNDERLINE_NONE:
		default:
			g_string_append (gstr, "<span underline=\"none\">");
			break;
		}
		break;
	case PANGO_ATTR_LANGUAGE :
		spans += 1;
		g_string_append_printf (gstr, "<span lang=\"%s\">",
					pango_language_to_string (((PangoAttrLanguage *)a)->value));
		break;
	case PANGO_ATTR_VARIANT :
		spans += 1;
		if (((PangoAttrInt *)a)->value == PANGO_VARIANT_NORMAL)
			g_string_append (gstr, "<span font_variant=\"normal\">");
		else
			g_string_append (gstr, "<span font_variant=\"smallcaps\">");
		break;
	case PANGO_ATTR_LETTER_SPACING :
		spans += 1;
		g_string_append_printf (gstr, "<span letter_spacing=\"%i\">",
					((PangoAttrInt *)a)->value);
		break;
	case PANGO_ATTR_FALLBACK :
		spans += 1;
		if (((PangoAttrInt *)a)->value)
			g_string_append (gstr, "<span fallback=\"true\">");
		else
			g_string_append (gstr, "<span fallback=\"false\">");
		break;
	case PANGO_ATTR_STRETCH :
		spans += 1;
		switch (((PangoAttrInt *)a)->value) {
		case PANGO_STRETCH_ULTRA_CONDENSED:
			g_string_append (gstr, "<span font_stretch=\"ultracondensed\">");
			break;
		case PANGO_STRETCH_EXTRA_CONDENSED:
			g_string_append (gstr, "<span font_stretch=\"extracondensed\">");
			break;
		case PANGO_STRETCH_CONDENSED:
			g_string_append (gstr, "<span font_stretch=\"condensed\">");
			break;
		case PANGO_STRETCH_SEMI_CONDENSED:
			g_string_append (gstr, "<span font_stretch=\"semicondensed\">");
			break;
		case PANGO_STRETCH_SEMI_EXPANDED:
			g_string_append (gstr, "<span font_stretch=\"semiexpanded\">");
			break;
		case PANGO_STRETCH_EXPANDED:
			g_string_append (gstr, "<span font_stretch=\"expanded\">");
			break;
		case PANGO_STRETCH_EXTRA_EXPANDED:
			g_string_append (gstr, "<span font_stretch=\"extraexpanded\">");
			break;
		case PANGO_STRETCH_ULTRA_EXPANDED:
			g_string_append (gstr, "<span font_stretch=\"ultraexpanded\">");
			break;
		case PANGO_STRETCH_NORMAL:
		default:
			g_string_append (gstr, "<span font_stretch=\"normal\">");
			break;
		}
		break;
	case PANGO_ATTR_GRAVITY :
		spans += 1;
		switch (((PangoAttrInt *)a)->value) {
		case PANGO_GRAVITY_SOUTH:
			g_string_append (gstr, "<span gravity=\"south\">");
			break;
		case PANGO_GRAVITY_EAST:
			g_string_append (gstr, "<span gravity=\"east\">");
			break;
		case PANGO_GRAVITY_NORTH:
			g_string_append (gstr, "<span gravity=\"north\">");
			break;
		case PANGO_GRAVITY_WEST:
			g_string_append (gstr, "<span gravity=\"west\">");
			break;
		case PANGO_GRAVITY_AUTO:
		default:
			g_string_append (gstr, "<span gravity=\"auto\">");
			break;
		}
		break;
	case PANGO_ATTR_GRAVITY_HINT :
		spans += 1;
		switch (((PangoAttrInt *)a)->value) {
		case PANGO_GRAVITY_HINT_LINE:
			g_string_append (gstr, "<span gravity_hint=\"line\">");
			break;
		case PANGO_GRAVITY_HINT_STRONG:
			g_string_append (gstr, "<span gravity_hint=\"strong\">");
			break;
		case PANGO_GRAVITY_HINT_NATURAL:
		default:
			g_string_append (gstr, "<span gravity_hint=\"natural\">");
			break;
		}
		break;

	case PANGO_ATTR_FOREGROUND :
		{
			PangoColor *color = &((PangoAttrColor *)a)->color;
			spans += 1;
			g_string_append_printf (gstr, "<span foreground=\"#%02X%02X%02X\">",
						color->red, color->green, color->blue);
		}
		break;
	case PANGO_ATTR_BACKGROUND :
		{
			PangoColor *color = &((PangoAttrColor *)a)->color;
			spans += 1;
			g_string_append_printf (gstr, "<span background=\"#%02X%02X%02X\">",
						color->red, color->green, color->blue);
		}
		break;
	case PANGO_ATTR_UNDERLINE_COLOR :
		{
			PangoColor *color = &((PangoAttrColor *)a)->color;
			spans += 1;
			g_string_append_printf (gstr, "<span underline_color=\"#%02X%02X%02X\">",
						color->red, color->green, color->blue);
		}
		break;
	case PANGO_ATTR_STRIKETHROUGH_COLOR :
		{
			PangoColor *color = &((PangoAttrColor *)a)->color;
			spans += 1;
			g_string_append_printf (gstr, "<span strikethrough_color=\"#%02X%02X%02X\">",
						color->red, color->green, color->blue);
		}
		break;

	case PANGO_ATTR_SCALE :
	case PANGO_ATTR_SHAPE :
	default :
		break; /* ignored */
	}

	return spans;
}
示例#20
0
static void
dump_runs (PangoLayout *layout, GString *string)
{
  PangoLayoutIter *iter;
  PangoLayoutRun *run;
  PangoItem *item;
  const gchar *text;
  gint index, index2;
  gboolean has_more;
  gchar *char_str;
  gint i;
  gchar *font;

  text = pango_layout_get_text (layout);
  iter = pango_layout_get_iter (layout);

  has_more = TRUE;
  index = pango_layout_iter_get_index (iter);
  i = 0;
  while (has_more)
    {
      run = pango_layout_iter_get_run (iter);
      has_more = pango_layout_iter_next_run (iter);
      i++;

      if (has_more)
        {
          index2 = pango_layout_iter_get_index (iter);
          char_str = g_strndup (text + index, index2 - index);          
        }
      else
        {
          char_str = g_strdup (text + index);
        }

      if (run)
        {
          item = ((PangoGlyphItem*)run)->item;
          font = font_name (item->analysis.font);
          g_string_append_printf (string, "i=%d, index=%d, chars=%d, level=%d, gravity=%s, flags=%d, font=%s, script=%s, language=%s, '%s'\n",
                                  i, index, item->num_chars, item->analysis.level,
                                  gravity_name (item->analysis.gravity),
                                  item->analysis.flags,
                                  "OMITTED", /* for some reason, this fails on build.gnome.org, so leave it out */
                                  script_name (item->analysis.script),
                                  pango_language_to_string (item->analysis.language),
                                  char_str);
          dump_extra_attrs (item->analysis.extra_attrs, string);
          g_free (font);
        }
      else
        {
          g_string_append_printf (string, "i=%d, index=%d, no run, line end\n",
                                  i, index);
        }

      g_free (char_str);
      index = index2;
    }
  pango_layout_iter_free (iter);
}