+
+ PangoAnalysis const *pa = &(glyph_item->item->analysis);
+ PangoGlyphString *pgs = glyph_item->glyphs;
+
+ PangoRectangle logical_rect;
+ PangoRectangle ink_rect;
+ pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect);
+
+ PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font,
+ PANGO_TYPE_FC_FONT,
+ PangoFcFont);
+
+ FT_Face ftface = pango_fc_font_lock_face (fcfont);
+
+ PangoRectangle const *which_rect = tight_bbox ? &ink_rect
+ : &logical_rect;
+
+ Box b (Interval (PANGO_LBEARING (logical_rect),
+ PANGO_RBEARING (logical_rect)),
+ Interval (-PANGO_DESCENT (*which_rect),
+ PANGO_ASCENT (*which_rect)));
+ b.scale (scale_);
+
+ char const *ps_name_str0 = FT_Get_Postscript_Name (ftface);
+ FcPattern *fcpat = fcfont->font_pattern;
+
+ FcChar8 *file_name_as_ptr = 0;
+ FcPatternGetString (fcpat, FC_FILE, 0, &file_name_as_ptr);
+
+ // due to a bug in FreeType 2.3.7 and earlier we can't use
+ // ftface->face_index; it is always zero for some font formats,
+ // in particular TTCs which we are interested in
+ int face_index = 0;
+ FcPatternGetInteger (fcpat, FC_INDEX, 0, &face_index);
+
+ string file_name;
+ if (file_name_as_ptr)
+ // Normalize file name.
+ file_name = File_name ((char const *)file_name_as_ptr).to_string ();
+
+ SCM glyph_exprs = SCM_EOL;
+ SCM *tail = &glyph_exprs;
+
+ Index_to_charcode_map const *cmap = 0;
+ bool has_glyph_names = ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES;
+ if (!has_glyph_names)
+ cmap = all_fonts_global->get_index_to_charcode_map (
+ file_name, face_index, ftface);
+
+ bool is_ttf = string (FT_Get_X11_Font_Format (ftface)) == "TrueType";
+ bool cid_keyed = false;
+
+ for (int i = 0; i < pgs->num_glyphs; i++)