cairo_status_t status = CAIRO_STATUS_SUCCESS; cairo_glyph_t origin_glyph; cairo_text_extents_t origin_extents; cairo_font_scale_t sc; int i; double min_x = 0.0, min_y = 0.0, max_x = 0.0, max_y = 0.0; double x_pos = 0.0, y_pos = 0.0; int set = 0;
cairo_status_t status;
_cairo_gstate_glyph_extents (cairo_gstate_t *gstate,			     cairo_glyph_t *glyphs, 			     int num_glyphs,			     cairo_text_extents_t *extents){    cairo_status_t status = CAIRO_STATUS_SUCCESS;    cairo_glyph_t origin_glyph;    cairo_text_extents_t origin_extents;    cairo_font_scale_t sc;    int i;    double min_x = 0.0, min_y = 0.0, max_x = 0.0, max_y = 0.0;    double x_pos = 0.0, y_pos = 0.0;    int set = 0;    if (!num_glyphs)    {	extents->x_bearing = 0.0;	extents->y_bearing = 0.0;	extents->width = 0.0;	extents->height = 0.0;	extents->x_advance = 0.0;	extents->y_advance = 0.0;	return CAIRO_STATUS_SUCCESS;    }    _build_font_scale (gstate, &sc);    for (i = 0; i < num_glyphs; i++)    {	double		x, y;	double		wm, hm;		origin_glyph = glyphs[i];	origin_glyph.x = 0.0;	origin_glyph.y = 0.0;	status = _cairo_unscaled_font_glyph_extents (gstate->font, &sc,						     &origin_glyph, 1,						     &origin_extents);		/*	 * Transform font space metrics into user space metrics	 * by running the corners through the font matrix and	 * expanding the bounding box as necessary	 */	x = origin_extents.x_bearing;	y = origin_extents.y_bearing;	cairo_matrix_transform_point (&gstate->font_matrix,				      &x, &y);	for (hm = 0.0; hm <= 1.0; hm += 1.0)	    for (wm = 0.0; wm <= 1.0; wm += 1.0)	    {		x = origin_extents.x_bearing + origin_extents.width * wm;		y = origin_extents.y_bearing + origin_extents.height * hm;		cairo_matrix_transform_point (&gstate->font_matrix,					      &x, &y);		x += glyphs[i].x;		y += glyphs[i].y;		if (!set)		{		    min_x = max_x = x;		    min_y = max_y = y;		    set = 1;		}		else		{		    if (x < min_x) min_x = x;		    if (x > max_x) max_x = x;		    if (y < min_y) min_y = y;		    if (y > max_y) max_y = y;		}	    }	x = origin_extents.x_advance;	y = origin_extents.y_advance;	cairo_matrix_transform_point (&gstate->font_matrix,				      &x, &y);	x_pos = glyphs[i].x + x;	y_pos = glyphs[i].y + y;    }    extents->x_bearing = min_x - glyphs[0].x;    extents->y_bearing = min_y - glyphs[0].y;    extents->width = max_x - min_x;    extents->height = max_y - min_y;    extents->x_advance = x_pos - glyphs[0].x;    extents->y_advance = y_pos - glyphs[0].y;    return status;}