[cairo-commit] cairo/src Makefile.am,1.10,1.11 cairo.c,1.21,1.22 cairo.h,1.19,1.20 cairo_font.c,1.11,1.12 cairo_gstate.c,1.20,1.21 cairo_xlib_surface.c,1.3,1.4 cairoint.h,1.29,1.30

Graydon Hoare commit at pdx.freedesktop.org
Thu Oct 23 15:22:31 PDT 2003


Committed by: graydon

Update of /cvs/cairo/cairo/src
In directory pdx:/tmp/cvs-serv26968/src

Modified Files:
	Makefile.am cairo.c cairo.h cairo_font.c cairo_gstate.c 
	cairo_xlib_surface.c cairoint.h 
Log Message:
2003-10-23  Graydon Hoare <graydon at redhat.com>

        * src/cairo_ft_font.c: New file.
        * src/Makefile.am: Add cairo_ft_font.c
        * src/cairo.c:
        * src/cairo.h:
        * src/cairo_font.c:
        * src/cairo_gstate.c:
        * src/cairo_xlib_surface.c:
        * src/cairoint.h: Change to virtual font interface.



Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo/src/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Makefile.am	4 Oct 2003 21:34:42 -0000	1.10
--- Makefile.am	23 Oct 2003 22:22:28 -0000	1.11
***************
*** 8,11 ****
--- 8,12 ----
  	cairo_fixed.c \
  	cairo_font.c \
+ 	cairo_ft_font.c \
  	cairo_gstate.c \
  	cairo_hull.c \

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** cairo.c	23 Oct 2003 14:47:29 -0000	1.21
--- cairo.c	23 Oct 2003 22:22:28 -0000	1.22
***************
*** 594,603 ****
  
  void
! cairo_select_font (cairo_t *cr, const char *key)
  {
      if (cr->status)
  	return;
  
!     cr->status = _cairo_gstate_select_font (cr->gstate, key);
  }
  
--- 594,637 ----
  
  void
! cairo_select_font (cairo_t              *cr, 
! 		   char                 *family, 
! 		   cairo_font_slant_t   slant, 
! 		   cairo_font_weight_t  weight)
  {
      if (cr->status)
  	return;
  
!     cr->status = _cairo_gstate_select_font (cr->gstate, family, slant, weight);
! }
! 
! cairo_font_t *
! cairo_current_font (cairo_t *cr)
! {
!     if (cr->status)
! 	return;
! 
!     cairo_font_t *ret;  
!     cr->status = _cairo_gstate_current_font (cr->gstate, &ret);  
!     return ret;
! }
! 
! void
! cairo_current_font_extents (cairo_t *ct, 
! 			    cairo_font_extents_t *extents)
! {
!     if (ct->status)
! 	return;
! 
!     ct->status = _cairo_gstate_current_font_extents (ct->gstate, extents);
! }
! 
! 
! void
! cairo_set_font (cairo_t *cr, cairo_font_t *font)
! {
!     if (cr->status)
! 	return;
! 
!     cr->status = _cairo_gstate_set_font (cr->gstate, font);  
  }
  
***************
*** 612,638 ****
  
  void
! cairo_transform_font (cairo_t *cr,
! 		      double a, double b,
! 		      double c, double d)
  {
      if (cr->status)
  	return;
  
!     cr->status = _cairo_gstate_transform_font (cr->gstate,
! 					      a, b, c, d);
  }
  
  void
! cairo_text_extents (cairo_t *cr,
! 		    const unsigned char *utf8,
! 		    double *x, double *y,
! 		    double *width, double *height,
! 		    double *dx, double *dy)
  {
      if (cr->status)
  	return;
  
!     cr->status = _cairo_gstate_text_extents (cr->gstate, utf8,
! 					     x, y, width, height, dx, dy);
  }
  
--- 646,680 ----
  
  void
! cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix)
  {
      if (cr->status)
  	return;
  
!     cr->status = _cairo_gstate_transform_font (cr->gstate, matrix);
  }
  
+ 
  void
! cairo_text_extents (cairo_t                *cr,
! 		    const unsigned char    *utf8,
! 		    cairo_text_extents_t   *extents)
  {
      if (cr->status)
  	return;
+     
+     cr->status = _cairo_gstate_text_extents (cr->gstate, utf8, extents);
+ }
  
! void
! cairo_glyph_extents (cairo_t                *cr,
! 		     cairo_glyph_t          *glyphs, 
! 		     int                    num_glyphs,
! 		     cairo_text_extents_t   *extents)
! {
!     if (cr->status)
! 	return;
! 
!     cr->status = _cairo_gstate_glyph_extents (cr->gstate, glyphs, num_glyphs,
! 					      extents);
  }
  
***************
*** 647,650 ****
--- 689,720 ----
  
  void
+ cairo_show_glyphs (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs)
+ {
+     if (cr->status)
+ 	return;
+ 
+     cr->status = _cairo_gstate_show_glyphs (cr->gstate, glyphs, num_glyphs);
+ }
+ 
+ void
+ cairo_text_path  (cairo_t *cr, const unsigned char *utf8)
+ {
+     if (cr->status)
+ 	return;
+ 
+     cr->status = _cairo_gstate_text_path (cr->gstate, utf8);
+ }
+ 
+ void
+ cairo_glyph_path (cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs)
+ {
+     if (cr->status)
+ 	return;
+ 
+     cr->status = _cairo_gstate_glyph_path (cr->gstate, glyphs, num_glyphs);  
+ }
+ 
+ 
+ void
  cairo_show_surface (cairo_t		*cr,
  		    cairo_surface_t	*surface,

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** cairo.h	23 Oct 2003 14:47:29 -0000	1.19
--- cairo.h	23 Oct 2003 22:22:28 -0000	1.20
***************
*** 321,349 ****
  /* Font/Text functions */
  
! /* XXX: The font support should probably expose a cairo_font_t object with
!    several functions, (cairo_font_transform, etc.) in a parallel manner as
!    cairo_matrix_t and (eventually) cairo_color_t */
  extern void __external_linkage
! cairo_select_font (cairo_t *cr, const char *key);
  
  extern void __external_linkage
  cairo_scale_font (cairo_t *cr, double scale);
  
- /* XXX: Probably want to use a cairo_matrix_t here, (to fix as part of the
-    big text support rewrite) */
  extern void __external_linkage
! cairo_transform_font (cairo_t *cr,
! 		double a, double b,
! 		double c, double d);
  
  extern void __external_linkage
! cairo_text_extents (cairo_t *cr,
! 	      const unsigned char *utf8,
! 	      double *x, double *y,
! 	      double *width, double *height,
! 	      double *dx, double *dy);
  
  extern void __external_linkage
! cairo_show_text (cairo_t *cr, const unsigned char *utf8);
  
  /* Image functions */
--- 321,452 ----
  /* Font/Text functions */
  
! typedef struct cairo_font cairo_font_t;
! 
! typedef struct {
!   unsigned long        index;
!   double               x;
!   double               y;
! } cairo_glyph_t;
! 
! typedef struct {
!     double left_side_bearing;
!     double right_side_bearing;
!     double ascent;
!     double descent;
!     double x_advance;
!     double y_advance;
! } cairo_text_extents_t;
! 
! typedef struct {
!     double ascent;
!     double descent;
!     double height;
!     double max_x_advance;
!     double max_y_advance;
! } cairo_font_extents_t;
! 
! typedef enum cairo_font_weight {
!   CAIRO_FONT_WEIGHT_NORMAL,
!   CAIRO_FONT_WEIGHT_BOLD
! } cairo_font_weight_t;
!   
! typedef enum cairo_font_slant {
!   CAIRO_FONT_SLANT_NORMAL,
!   CAIRO_FONT_SLANT_ITALIC,
!   CAIRO_FONT_SLANT_OBLIQUE
! } cairo_font_slant_t;
!   
! 
! /* This interface is for dealing with text as text, not caring about the
!    font object inside the the cairo_t. */
! 
  extern void __external_linkage
! cairo_select_font (cairo_t              *ct, 
! 		   char                 *family, 
! 		   cairo_font_slant_t   slant, 
! 		   cairo_font_weight_t  weight);
  
  extern void __external_linkage
  cairo_scale_font (cairo_t *cr, double scale);
  
  extern void __external_linkage
! cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix);
  
  extern void __external_linkage
! cairo_show_text (cairo_t *ct, const unsigned char *utf8);
  
  extern void __external_linkage
! cairo_show_glyphs (cairo_t *ct, cairo_glyph_t *glyphs, int num_glyphs);
! 
! extern cairo_font_t * __external_linkage
! cairo_current_font (cairo_t *ct);
! 
! extern void __external_linkage
! cairo_current_font_extents (cairo_t *ct, 
! 			    cairo_font_extents_t *extents);
! 
! extern void __external_linkage
! cairo_set_font (cairo_t *ct, cairo_font_t *font);
! 
! 
! /* NYI
! 
! extern void __external_linkage
! cairo_text_extents (cairo_t                *ct,
! 		    const unsigned char    *utf8,
! 		    cairo_text_extents_t   *extents);
! 
! extern void __external_linkage
! cairo_glyph_extents (cairo_t               *ct,
! 		     cairo_glyph_t         *glyphs, 
! 		     int                   num_glyphs,
! 		     cairo_text_extents_t  *extents);
! 
! extern void __external_linkage
! cairo_text_path  (cairo_t *ct, const unsigned char *utf8);
! 
! extern void __external_linkage
! cairo_glyph_path (cairo_t *ct, cairo_glyph_t *glyphs, int num_glyphs);
! 
! */
! 
! 
! /* Portable interface to general font features. */
!   
! extern void __external_linkage
! cairo_font_reference (cairo_font_t *font);
! 
! extern void __external_linkage
! cairo_font_destroy (cairo_font_t *font);
! 
! extern void __external_linkage
! cairo_font_set_transform (cairo_font_t *font, 
! 			  cairo_matrix_t *matrix);
! 
! extern void __external_linkage
! cairo_font_current_transform (cairo_font_t *font, 
! 			      cairo_matrix_t *matrix);
! 
! 
! /* Fontconfig/Freetype platform-specific font interface */
! 
! #include <freetype/freetype.h>
! 
! extern cairo_font_t * __external_linkage
! cairo_ft_font_create (FcPattern *pattern);
! 
! extern cairo_font_t * __external_linkage
! cairo_ft_font_create_for_ft_face (FT_Face face);
! 
! extern void __external_linkage
! cairo_ft_font_destroy (cairo_font_t *ft_font);
! 
! extern FT_Face __external_linkage
! cairo_ft_font_face (cairo_font_t *ft_font);
! 
! extern FcPattern * __external_linkage
! cairo_ft_font_pattern (cairo_font_t  *ft_font);
! 
! 
  
  /* Image functions */

Index: cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_font.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** cairo_font.c	23 Oct 2003 14:47:29 -0000	1.11
--- cairo_font.c	23 Oct 2003 22:22:28 -0000	1.12
***************
*** 29,60 ****
  
  cairo_int_status_t
! _cairo_font_init (cairo_font_t *font, const struct cairo_font_backend *backend)
  {
      if (font == NULL)
! 	return CAIRO_STATUS_SUCCESS;
! 
!     font->key = (unsigned char *) strdup (CAIRO_FONT_KEY_DEFAULT);
      cairo_matrix_set_identity (&font->matrix);
! 
      font->backend = backend;
! 
!     return CAIRO_STATUS_SUCCESS;
! }
! 
! cairo_int_status_t
! _cairo_font_init_copy (cairo_font_t *font, cairo_font_t *other)
! {
!     if (other == NULL)
! 	return CAIRO_STATUS_SUCCESS;
! 
!     if (other->key) {
! 	font->key = (unsigned char *) strdup ((char *) other->key);
! 	if (font->key == NULL)
! 	    return CAIRO_STATUS_NO_MEMORY;
!     }
!     font->matrix = other->matrix;
! 
!     font->backend = other->backend;
! 
      return CAIRO_STATUS_SUCCESS;
  }
--- 29,48 ----
  
  cairo_int_status_t
! _cairo_font_init (cairo_font_t *font, 
! 		  const struct cairo_font_backend *backend)
  {
      if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
!     
!     font->family = (unsigned char *) strdup (CAIRO_FONT_FAMILY_DEFAULT);
!     if (font->family == NULL)
! 	return CAIRO_STATUS_NO_MEMORY;
!     
      cairo_matrix_set_identity (&font->matrix);
!     font->refcount = 1;
!     font->weight = CAIRO_FONT_WEIGHT_NORMAL;
!     font->slant = CAIRO_FONT_SLANT_NORMAL;
      font->backend = backend;
!     
      return CAIRO_STATUS_SUCCESS;
  }
***************
*** 63,70 ****
  _cairo_font_copy (cairo_font_t *font)
  {
      if (font == NULL || font->backend->copy == NULL)
  	return NULL;
  
!     return font->backend->copy (font);
  }
  
--- 51,79 ----
  _cairo_font_copy (cairo_font_t *font)
  {
+     cairo_font_t *newfont = NULL;
+     char *tmp = NULL;
+ 
      if (font == NULL || font->backend->copy == NULL)
  	return NULL;
+     
+     if (font->family) {
+ 	tmp = (unsigned char *) strdup ((char *) font->family);
+ 	if (tmp == NULL)
+ 	    return NULL;
+     }
+     
+     newfont = font->backend->copy (font);
+     if (newfont == NULL) {
+ 	free (tmp);
+ 	return NULL;
+     }
  
!     newfont->refcount = 1;
!     newfont->family = tmp;
!     cairo_matrix_copy(&newfont->matrix, &font->matrix);
!     newfont->slant = font->slant;
!     newfont->weight = font->weight;
!     newfont->backend = font->backend;
!     return newfont;
  }
  
***************
*** 75,154 ****
  	return;
  
!     if (font->key)
! 	free (font->key);
!     font->key = NULL;
  
      _cairo_matrix_fini (&font->matrix);
! 
      if (font->backend->close)
  	font->backend->close (font);
  }
  
! cairo_int_status_t
! _cairo_font_select (cairo_font_t *font, const char *key)
  {
      if (font == NULL)
! 	return CAIRO_STATUS_SUCCESS;
! 
!     if (font->backend->close)
! 	font->backend->close (font);
! 
!     if (font->key)
! 	free (font->key);
! 
!     font->key = (unsigned char *) strdup ((char *) key);
!     if (font->key == NULL)
! 	return CAIRO_STATUS_NO_MEMORY;
  
!     return CAIRO_STATUS_SUCCESS;
  }
  
! cairo_int_status_t
! _cairo_font_scale (cairo_font_t *font, double scale)
  {
      if (font == NULL)
! 	return CAIRO_STATUS_SUCCESS;
! 
!     cairo_matrix_scale (&font->matrix, scale, scale);
! 
!     return CAIRO_STATUS_SUCCESS;
  }
  
  cairo_int_status_t
! _cairo_font_transform (cairo_font_t *font,
! 		       double a, double b,
! 		       double c, double d)
  {
-     cairo_matrix_t m;
- 
      if (font == NULL)
! 	return CAIRO_STATUS_SUCCESS;
! 
!     cairo_matrix_set_affine (&m, a, b, c, d, 0, 0);
!     cairo_matrix_multiply (&font->matrix, &m, &font->matrix);
  
!     return CAIRO_STATUS_SUCCESS;
  }
  
  cairo_int_status_t
! _cairo_font_text_extents (cairo_font_t *font,
! 			  cairo_matrix_t *ctm,
! 			  const unsigned char *utf8,
! 			  double *x, double *y,
! 			  double *width, double *height,
! 			  double *dx, double *dy)
  {
      if (font == NULL)
! 	return CAIRO_STATUS_SUCCESS;
! 
!     if (!font->backend->text_extents)
! 	return CAIRO_STATUS_SUCCESS;
  
!     return font->backend->text_extents (font, ctm, utf8, x, y, width, height, dx, dy);
  }
  
  cairo_int_status_t
  _cairo_font_show_text (cairo_font_t		*font,
- 		       cairo_matrix_t		*ctm,
  		       cairo_operator_t		operator,
  		       cairo_surface_t		*source,
--- 84,145 ----
  	return;
  
!     if (--(font->refcount) > 0)
! 	return;
  
+     if (font->family)
+ 	free (font->family);
+     font->family = NULL;
+     
      _cairo_matrix_fini (&font->matrix);
!     
      if (font->backend->close)
  	font->backend->close (font);
  }
  
! cairo_status_t
! _cairo_font_scale (cairo_font_t *font, double scale)
  {
      if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
  
!     return cairo_matrix_scale (&font->matrix, scale, scale);
  }
  
! cairo_status_t
! _cairo_font_transform (cairo_font_t *font, cairo_matrix_t *matrix)
  {
      if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
!     
!     return cairo_matrix_multiply (&font->matrix, matrix, &font->matrix);
  }
  
+ 
  cairo_int_status_t
! _cairo_font_text_extents (cairo_font_t *font,
! 			  const unsigned char *utf8,
! 			  cairo_text_extents_t *extents)
  {
      if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
  
!     return font->backend->text_extents(font, utf8, extents);
  }
  
  cairo_int_status_t
! _cairo_font_glyph_extents (cairo_font_t *font,
!                            cairo_glyph_t *glyphs,
!                            int num_glyphs,
! 			   cairo_text_extents_t *extents)
  {
      if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
  
!     return font->backend->glyph_extents(font, glyphs, num_glyphs, extents);
  }
  
+ 
  cairo_int_status_t
  _cairo_font_show_text (cairo_font_t		*font,
  		       cairo_operator_t		operator,
  		       cairo_surface_t		*source,
***************
*** 159,167 ****
  {
      if (font == NULL)
! 	return CAIRO_STATUS_SUCCESS;
  
!     if (!font->backend->show_text)
! 	return CAIRO_STATUS_SUCCESS;
  
!     return font->backend->show_text (font, ctm, operator, source, surface, x, y, utf8);
  }
--- 150,251 ----
  {
      if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
  
!     return font->backend->show_text(font, operator, source, 
! 				    surface, x, y, utf8);
! }
  
! cairo_int_status_t
! _cairo_font_show_glyphs (cairo_font_t           *font,
!                          cairo_operator_t       operator,
!                          cairo_surface_t        *source,
!                          cairo_surface_t        *surface,
! 			 double                 x,
! 			 double                 y,
!                          cairo_glyph_t          *glyphs,
!                          int                    num_glyphs)
! {
!     if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
!     
!     return font->backend->show_glyphs(font, operator, source, 
! 				      surface, x, y, glyphs, num_glyphs);
! }
! 
! cairo_int_status_t
! _cairo_font_text_path (cairo_font_t             *font,
!                        cairo_path_t             *path,
!                        const unsigned char      *utf8)
! {
!     if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
!     
!     return font->backend->text_path(font, path, utf8);
! }
! 
! cairo_int_status_t
! _cairo_font_glyph_path (cairo_font_t            *font,
!                         cairo_path_t            *path,
!                         cairo_glyph_t           *glyphs, 
!                         int                     num_glyphs)
! {
!     if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
!     
!     return font->backend->glyph_path(font, path, 
! 				     glyphs, num_glyphs);
! }
! 
! cairo_int_status_t
! _cairo_font_font_extents (cairo_font_t *font,
! 			  cairo_font_extents_t *extents)
! {
!     if (font == NULL)
! 	return CAIRO_INT_STATUS_NULL_POINTER;
!     
!     return font->backend->font_extents(font, extents);
  }
+ 
+ 
+ cairo_font_t *
+ _cairo_font_create_font (char                 *family, 
+ 			 cairo_font_slant_t   slant, 
+ 			 cairo_font_weight_t  weight)
+ {
+     /* Platform-specific; ifdef if you have another font system. */
+     const struct cairo_font_backend *default_font_impl = &cairo_ft_font_backend;
+     return default_font_impl->create(family, slant, weight);
+ }
+ 
+ 
+ 
+ 
+ /* public font interface follows */
+ 
+ void
+ cairo_font_reference (cairo_font_t *font)
+ {
+     font->refcount++;
+ }
+ 
+ void
+ cairo_font_destroy (cairo_font_t *font)
+ {
+     _cairo_font_fini (font);
+ }
+ 
+ void
+ cairo_font_set_transform (cairo_font_t *font, 
+ 			  cairo_matrix_t *matrix)
+ {
+     cairo_matrix_copy (&(font->matrix), matrix);
+ }
+ 
+ void
+ cairo_font_current_transform (cairo_font_t *font, 
+ 			      cairo_matrix_t *matrix)
+ {
+     cairo_matrix_copy (matrix, &(font->matrix));
+ }
+ 
+ 

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** cairo_gstate.c	23 Oct 2003 14:47:29 -0000	1.20
--- cairo_gstate.c	23 Oct 2003 22:22:29 -0000	1.21
***************
*** 1356,1434 ****
  
  cairo_status_t
- _cairo_gstate_select_font (cairo_gstate_t *gstate, const char *key)
- {
-     return _cairo_font_select (gstate->font, key);
- }
- 
- cairo_status_t
- _cairo_gstate_scale_font (cairo_gstate_t *gstate, double scale)
- {
-     return _cairo_font_scale (gstate->font, scale);
- }
- 
- cairo_status_t
- _cairo_gstate_transform_font (cairo_gstate_t *gstate,
- 			      double a, double b,
- 			      double c, double d)
- {
-     return _cairo_font_transform (gstate->font,
- 				  a, b, c, d);
- }
- 
- cairo_status_t
- _cairo_gstate_text_extents (cairo_gstate_t *gstate,
- 			    const unsigned char *utf8,
- 			    double *x, double *y,
- 			    double *width, double *height,
- 			    double *dx, double *dy)
- {
-     return _cairo_font_text_extents (gstate->font, &gstate->ctm, utf8,
- 	    			     x, y, width, height, dx, dy);
- }
- 
- cairo_status_t
- _cairo_gstate_show_text (cairo_gstate_t *gstate, const unsigned char *utf8)
- {
-     cairo_status_t status;
-     double x, y;
-     cairo_matrix_t user_to_source, device_to_source;
- 
-     /* XXX: I believe this is correct, but it would be much more clear
-        to have some explicit current_point accesor functions, (one for
-        user- and one for device-space). */
-     if (gstate->has_current_point) {
- 	x = gstate->current_point.x;
- 	y = gstate->current_point.y;
-     } else {
- 	x = 0;
- 	y = 0;
- 	cairo_matrix_transform_point (&gstate->ctm, &x, &y);
-     }
- 
-     status = _cairo_gstate_ensure_source (gstate);
-     if (status)
- 	return status;
- 
-     /* XXX: This same source matrix manipulation code shows up in
-        about 3 or 4 places. We should move that into a shared function
-        or two. */
-     if (! gstate->source_is_solid) {
- 	cairo_surface_get_matrix (gstate->source, &user_to_source);
- 	cairo_matrix_multiply (&device_to_source, &gstate->ctm_inverse, &user_to_source);
- 	cairo_surface_set_matrix (gstate->source, &device_to_source);
-     }
- 
-     status = _cairo_font_show_text (gstate->font, &gstate->ctm,
- 				    gstate->operator, gstate->source,
- 				    gstate->surface, x, y, utf8);
- 
-     /* restore the matrix originally in the source surface */
-     if (! gstate->source_is_solid)
- 	cairo_surface_set_matrix (gstate->source, &user_to_source);
- 
-     return status;
- }
- 
- cairo_status_t
  _cairo_gstate_show_surface (cairo_gstate_t	*gstate,
  			    cairo_surface_t	*surface,
--- 1356,1359 ----
***************
*** 1489,1490 ****
--- 1414,1715 ----
      return CAIRO_STATUS_SUCCESS;
  }
+ 
+ cairo_status_t
+ _cairo_gstate_select_font (cairo_gstate_t       *gstate, 
+ 			   char                 *family, 
+ 			   cairo_font_slant_t   slant, 
+ 			   cairo_font_weight_t  weight)
+ {
+     if (gstate->font != NULL)
+ 	_cairo_font_fini (gstate->font);
+ 
+     gstate->font = _cairo_font_create_font(family, slant, weight);
+     if (gstate->font == NULL)
+ 	return CAIRO_INT_STATUS_NULL_POINTER;
+   
+     return CAIRO_STATUS_SUCCESS;
+ }
+ 
+ cairo_status_t
+ _cairo_gstate_scale_font (cairo_gstate_t *gstate, 
+ 			  double scale)
+ {
+     return _cairo_font_scale (gstate->font, scale);
+ }
+ 
+ cairo_status_t
+ _cairo_gstate_transform_font (cairo_gstate_t *gstate, 
+ 			      cairo_matrix_t *matrix)
+ {
+     return _cairo_font_transform (gstate->font, matrix);    
+ }
+ 
+ cairo_status_t
+ _cairo_gstate_current_font (cairo_gstate_t *gstate, 
+ 			    cairo_font_t **font)
+ {
+     if (font == NULL)
+ 	return CAIRO_INT_STATUS_NULL_POINTER;
+   
+     *font = gstate->font;
+     return CAIRO_STATUS_SUCCESS;
+ }
+ 
+ cairo_status_t
+ _cairo_gstate_current_font_extents (cairo_gstate_t *gstate, 
+ 				    cairo_font_extents_t *extents)
+ {
+     cairo_int_status_t status;
+     cairo_matrix_t saved_font_matrix;
+     
+     if (gstate == NULL)
+ 	return CAIRO_INT_STATUS_NULL_POINTER;
+     
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+     
+     status = _cairo_font_font_extents (gstate->font, extents);
+ 
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);    
+     return status;
+ }
+ 
+ 
+ cairo_status_t
+ _cairo_gstate_set_font (cairo_gstate_t *gstate, 
+ 			cairo_font_t *font)
+ {
+     if (gstate->font != NULL)    
+ 	_cairo_font_fini (gstate->font);
+     gstate->font = font;
+     cairo_font_reference (gstate->font);
+     return CAIRO_STATUS_SUCCESS;
+ }
+ 
+ cairo_status_t
+ _cairo_gstate_text_extents (cairo_gstate_t *gstate,
+ 			    const unsigned char *utf8,
+ 			    cairo_text_extents_t *extents)
+ {
+     cairo_matrix_t saved_font_matrix;
+     cairo_status_t status;
+ 
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+ 
+     status = _cairo_font_text_extents (gstate->font,
+ 				       utf8, extents);
+ 
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+     return status;
+ }
+ 
+ cairo_status_t
+ _cairo_gstate_glyph_extents (cairo_gstate_t *gstate,
+ 			     cairo_glyph_t *glyphs, 
+ 			     int num_glyphs,
+ 			     cairo_text_extents_t *extents)
+ {
+     cairo_status_t status;
+     int i;
+     cairo_glyph_t *transformed_glyphs = NULL;
+     cairo_matrix_t saved_font_matrix;
+ 
+     transformed_glyphs = malloc (num_glyphs * sizeof(cairo_glyph_t));
+     if (transformed_glyphs == NULL)
+ 	return CAIRO_STATUS_NO_MEMORY;
+     
+     for (i = 0; i < num_glyphs; ++i)
+     {
+ 	transformed_glyphs[i] = glyphs[i];
+ 	cairo_matrix_transform_point (&gstate->ctm, 
+ 				      &(transformed_glyphs[i].x), 
+ 				      &(transformed_glyphs[i].y));
+     }
+ 
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+ 
+     status = _cairo_font_glyph_extents (gstate->font,
+ 					transformed_glyphs, num_glyphs,
+ 					extents);
+ 
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+ 
+     free (transformed_glyphs);
+     return status;
+ }
+ 
+ 
+ static cairo_status_t 
+ setup_text_rendering_context(cairo_gstate_t *gstate, 
+ 			     double *x, double *y,
+ 			     cairo_matrix_t *user_to_source)
+ {
+     cairo_status_t status;
+     cairo_matrix_t device_to_source;
+   
+     /* XXX: I believe this is correct, but it would be much more clear
+        to have some explicit current_point accesor functions, (one for
+        user- and one for device-space). */
+ 
+     if (gstate->has_current_point) {
+ 	*x = gstate->current_point.x;
+ 	*y = gstate->current_point.y;
+     } else {
+ 	*x = 0;
+ 	*y = 0;
+ 	cairo_matrix_transform_point (&gstate->ctm, x, y);
+     }
+   
+     status = _cairo_gstate_ensure_source (gstate);
+     if (status)
+ 	return status;
+   
+     /* XXX: This same source matrix manipulation code shows up in
+        about 3 or 4 places. We should move that into a shared function
+        or two. */
+     if (! gstate->source_is_solid) {
+ 	cairo_surface_get_matrix (gstate->source, user_to_source);
+ 	cairo_matrix_multiply (&device_to_source, &gstate->ctm_inverse, user_to_source);
+ 	cairo_surface_set_matrix (gstate->source, &device_to_source);
+     }
+     return CAIRO_STATUS_SUCCESS;
+ }
+ 
+ static void 
+ restore_text_rendering_context(cairo_gstate_t *gstate, 
+ 			       cairo_matrix_t *user_to_source)
+ {
+     /* restore the matrix originally in the source surface */
+     if (! gstate->source_is_solid)
+ 	cairo_surface_set_matrix (gstate->source, user_to_source);  
+ }
+ 
+ 
+ cairo_status_t
+ _cairo_gstate_show_text (cairo_gstate_t *gstate, 
+ 			 const unsigned char *utf8)
+ {
+     cairo_status_t status;
+     double x, y;
+     cairo_matrix_t user_to_source;
+     cairo_matrix_t saved_font_matrix;
+     
+     status = setup_text_rendering_context(gstate, &x, &y, &user_to_source);
+     if (status)
+ 	return status;
+     
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+ 
+     status = _cairo_font_show_text (gstate->font,
+ 				    gstate->operator, gstate->source,
+ 				    gstate->surface, x, y, utf8);
+     
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+     restore_text_rendering_context (gstate, &user_to_source);
+ 
+     return status;
+ }
+ 
+ 
+ cairo_status_t
+ _cairo_gstate_show_glyphs (cairo_gstate_t *gstate, 
+ 			   cairo_glyph_t *glyphs, 
+ 			   int num_glyphs)
+ {
+     cairo_status_t status;
+     double x, y;
+     cairo_matrix_t user_to_source;
+     cairo_matrix_t saved_font_matrix;
+     int i;
+     cairo_glyph_t *transformed_glyphs = NULL;
+ 
+     transformed_glyphs = malloc (num_glyphs * sizeof(cairo_glyph_t));
+     if (transformed_glyphs == NULL)
+ 	return CAIRO_STATUS_NO_MEMORY;
+     
+     for (i = 0; i < num_glyphs; ++i)
+     {
+ 	transformed_glyphs[i] = glyphs[i];
+ 	cairo_matrix_transform_point (&gstate->ctm, 
+ 				      &(transformed_glyphs[i].x), 
+ 				      &(transformed_glyphs[i].y));
+     }
+     
+     status = setup_text_rendering_context (gstate, &x, &y, &user_to_source);
+     if (status)
+ 	return status;
+     
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+ 
+     status = _cairo_font_show_glyphs (gstate->font, 
+ 				      gstate->operator, gstate->source,
+ 				      gstate->surface, x, y, 
+ 				      transformed_glyphs, num_glyphs);
+     
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+     restore_text_rendering_context (gstate, &user_to_source);
+ 
+     free (transformed_glyphs);
+     
+     return status;
+ 
+ }
+ 
+ 
+ cairo_status_t
+ _cairo_gstate_text_path (cairo_gstate_t *gstate, 
+ 			 const unsigned char *utf8)
+ {
+     cairo_status_t status;
+     cairo_matrix_t saved_font_matrix;
+ 
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+ 
+     status = _cairo_font_text_path (gstate->font, 
+ 				    &gstate->path,
+ 				    utf8);
+ 
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+     return status;
+ }
+ 
+ 
+ cairo_status_t
+ _cairo_gstate_glyph_path (cairo_gstate_t *gstate, 
+ 			  cairo_glyph_t *glyphs, 
+ 			  int num_glyphs)
+ {
+     cairo_status_t status;
+     int i;
+     cairo_glyph_t *transformed_glyphs = NULL;
+     cairo_matrix_t saved_font_matrix;
+ 
+     transformed_glyphs = malloc (num_glyphs * sizeof(cairo_glyph_t));
+     if (transformed_glyphs == NULL)
+ 	return CAIRO_STATUS_NO_MEMORY;
+     
+     for (i = 0; i < num_glyphs; ++i)
+     {
+ 	transformed_glyphs[i] = glyphs[i];
+ 	cairo_matrix_transform_point (&gstate->ctm, 
+ 				      &(transformed_glyphs[i].x), 
+ 				      &(transformed_glyphs[i].y));
+     }
+ 
+     cairo_matrix_copy (&saved_font_matrix, &gstate->font->matrix);
+     cairo_matrix_multiply (&gstate->font->matrix, &gstate->ctm, &gstate->font->matrix);
+ 
+     status = _cairo_font_glyph_path (gstate->font, 
+ 				     &gstate->path,
+ 				     transformed_glyphs, num_glyphs);
+ 
+     cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+     
+     free (transformed_glyphs);
+     return status;
+ }

Index: cairo_xlib_surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_xlib_surface.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** cairo_xlib_surface.c	23 Oct 2003 14:47:29 -0000	1.3
--- cairo_xlib_surface.c	23 Oct 2003 22:22:29 -0000	1.4
***************
*** 26,38 ****
   */
  
- #include <X11/Xft/Xft.h>
- 
  #include "cairoint.h"
  #include "cairo-xlib.h"
  #include <X11/Xlibint.h>
  
- static cairo_font_t *
- _cairo_xlib_font_create (Display *dpy);
- 
  void
  cairo_set_target_drawable (cairo_t	*cr,
--- 26,33 ----
***************
*** 43,47 ****
  
      if (cr->status && cr->status != CAIRO_STATUS_NO_TARGET_SURFACE)
! 	return;
  
      surface = cairo_xlib_surface_create (dpy, drawable,
--- 38,42 ----
  
      if (cr->status && cr->status != CAIRO_STATUS_NO_TARGET_SURFACE)
! 	    return;
  
      surface = cairo_xlib_surface_create (dpy, drawable,
***************
*** 55,60 ****
  
      cairo_set_target_surface (cr, surface);
-     cr->gstate->font = _cairo_xlib_font_create (dpy);
- 
      cairo_surface_destroy (surface);
  }
--- 50,53 ----
***************
*** 303,307 ****
  			      int			width,
  			      int			height,
! 			      int			stride)
  {
      XImage *image;
--- 296,301 ----
  			      int			width,
  			      int			height,
! 			      int			stride,
! 			      int			depth)
  {
      XImage *image;
***************
*** 311,317 ****
  	return CAIRO_STATUS_SUCCESS;
  
-     /* XXX: This is obviously bogus. depth needs to be figured out for real */
-     int depth = 32;
- 
      if (depth > 16)
  	bitmap_pad = 32;
--- 305,308 ----
***************
*** 343,347 ****
  
  static cairo_xlib_surface *
! _cairo_xlib_surface_clone_from (cairo_surface_t *src, cairo_xlib_surface *tmpl)
  {
      cairo_matrix_t matrix;
--- 334,339 ----
  
  static cairo_xlib_surface *
! _cairo_xlib_surface_clone_from (cairo_surface_t *src, cairo_xlib_surface *tmpl, 
!                                 cairo_format_t fmt, int depth)
  {
      cairo_matrix_t matrix;
***************
*** 350,354 ****
      _cairo_surface_pull_image (src);
  
!     src_on_server = _cairo_xlib_surface_create_similar (tmpl, CAIRO_FORMAT_ARGB32,
  							IcImageGetWidth (src->icimage),
  							IcImageGetHeight (src->icimage));
--- 342,346 ----
      _cairo_surface_pull_image (src);
  
!     src_on_server = _cairo_xlib_surface_create_similar (tmpl, fmt,
  							IcImageGetWidth (src->icimage),
  							IcImageGetHeight (src->icimage));
***************
*** 363,367 ****
  				  IcImageGetWidth (src->icimage),
  				  IcImageGetHeight (src->icimage),
! 				  IcImageGetStride (src->icimage));
      return src_on_server;
  }
--- 355,359 ----
  				  IcImageGetWidth (src->icimage),
  				  IcImageGetHeight (src->icimage),
! 				  IcImageGetStride (src->icimage), depth);
      return src_on_server;
  }
***************
*** 385,394 ****
  
      if (src->base.backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src = _cairo_xlib_surface_clone_from (&src->base, dst);
  	if (!src)
  	    return -1;
      }
      if (mask && (mask->base.backend != dst->base.backend || mask->dpy != dst->dpy)) {
! 	mask = _cairo_xlib_surface_clone_from (&mask->base, dst);
  	if (!mask)
  	    return -1;
--- 377,386 ----
  
      if (src->base.backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src = _cairo_xlib_surface_clone_from (&src->base, dst, CAIRO_FORMAT_ARGB32, 32);
  	if (!src)
  	    return -1;
      }
      if (mask && (mask->base.backend != dst->base.backend || mask->dpy != dst->dpy)) {
! 	mask = _cairo_xlib_surface_clone_from (&mask->base, dst, CAIRO_FORMAT_A8, 8);
  	if (!mask)
  	    return -1;
***************
*** 444,448 ****
  
      if (src->base.backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src = _cairo_xlib_surface_clone_from (&src->base, dst);
  	if (!src)
  	    return -1;
--- 436,440 ----
  
      if (src->base.backend != dst->base.backend || src->dpy != dst->dpy) {
! 	src = _cairo_xlib_surface_clone_from (&src->base, dst, CAIRO_FORMAT_ARGB32, 32);
  	if (!src)
  	    return -1;
***************
*** 457,460 ****
--- 449,454 ----
  }
  
+ 
+ 
  static const struct cairo_surface_backend cairo_xlib_surface_backend = {
      create_similar:		(void *) _cairo_xlib_surface_create_similar,
***************
*** 533,719 ****
  }
  DEPRECATE (cairo_surface_create_for_drawable, cairo_xlib_surface_create);
- 
- 
- typedef struct cairo_xlib_font {
-     cairo_font_t base;
- 
-     Display *dpy;
-     XftFont *xft_font;
- } cairo_xlib_font_t;
- 
- static cairo_font_t *
- _cairo_xlib_font_copy (cairo_xlib_font_t *other)
- {
-     cairo_xlib_font_t *font;
-     font = malloc (sizeof (cairo_xlib_font_t));
-     if (!font)
- 	return 0;
- 
-     if (_cairo_font_init_copy (&font->base, &other->base))
- 	goto abort;
- 
-     font->dpy = other->dpy;
- 
-     if (other->xft_font) {
- 	font->xft_font = XftFontCopy (other->dpy, other->xft_font);
- 	if (font->xft_font == NULL)
- 	    goto abort;
-     } else
- 	font->xft_font = NULL;
- 
-     return &font->base;
- 
- abort:
-     _cairo_font_fini (&font->base);
-     return 0;
- }
- 
- static void
- _cairo_xlib_font_close (cairo_xlib_font_t *font)
- {
-     if (font->xft_font)
- 	XftFontClose (font->dpy, font->xft_font);
-     font->xft_font = NULL;
- }
- 
- static cairo_status_t
- _cairo_xlib_font_resolve (cairo_xlib_font_t *font, cairo_matrix_t *ctm)
- {
-     FcPattern	*pattern;
-     FcPattern	*match;
-     FcResult	result;
-     cairo_matrix_t	matrix;
-     FcMatrix	fc_matrix;
-     double	expansion;
-     double	font_size;
-     
-     if (font->xft_font)
- 	return CAIRO_STATUS_SUCCESS;
-     
-     pattern = FcNameParse (font->base.key);
- 
-     matrix = *ctm;
-     cairo_matrix_multiply (&matrix, &font->base.matrix, &matrix);
- 
-     /* Pull the scale factor out of the final matrix and use it to set
-        the direct pixelsize of the font. This enables freetype to
-        perform proper hinting at any size. */
- 
-     /* XXX: The determinant gives an area expansion factor, so the
-        math below should be correct for the (common) case of uniform
-        X/Y scaling. Is there anything different we would want to do
-        for non-uniform X/Y scaling?
- 
-        XXX: Actually, the reasoning above is bogus. A transformation
-        such as scale (N, 1/N) will give an expansion_factor of 1. So,
-        with the code below we'll end up with font_size == 1 instead of
-        N, (so the hinting will be all wrong). I think we want to use
-        the maximum eigen value rather than the square root of the
-        determinant. */
-     _cairo_matrix_compute_determinant (&matrix, &expansion);
-     font_size = sqrt (fabs (expansion));
- 
-     FcPatternAddDouble (pattern, "pixelsize", font_size);
-     cairo_matrix_scale (&matrix, 1.0 / font_size, 1.0 / font_size);
- 
-     fc_matrix.xx = matrix.m[0][0];
-     fc_matrix.xy = matrix.m[0][1];
-     fc_matrix.yx = matrix.m[1][0];
-     fc_matrix.yy = matrix.m[1][1];
- 
-     FcPatternAddMatrix (pattern, "matrix", &fc_matrix);
- 
-     match = XftFontMatch (font->dpy, DefaultScreen (font->dpy), pattern, &result);
-     if (!match)
- 	return 0;
-     
-     font->xft_font = XftFontOpenPattern (font->dpy, match);
- 
-     FcPatternDestroy (pattern);
- 
-     return CAIRO_STATUS_SUCCESS;
- }
- 
- static cairo_status_t
- _cairo_xlib_font_text_extents (cairo_xlib_font_t *font,
- 			       cairo_matrix_t *ctm,
- 			       const unsigned char *utf8,
- 			       double *x, double *y,
- 			       double *width, double *height,
- 			       double *dx, double *dy)
- {
-     XGlyphInfo extents;
- 
-     _cairo_xlib_font_resolve (font, ctm);
- 
-     XftTextExtentsUtf8 (font->dpy,
- 			font->xft_font,
- 			utf8,
- 			strlen ((char *) utf8),
- 			&extents);
- 
-     /* XXX: What are the semantics of XftTextExtents? Specifically,
-        what does it do with x/y? I think we actually need to use the
-        gstate's current point in here somewhere. */
-     *x = extents.x;
-     *y = extents.y;
-     *width = extents.width;
-     *height = extents.height;
-     *dx = extents.xOff;
-     *dy = extents.yOff;
- 
-     return CAIRO_STATUS_SUCCESS;
- }
- 
- static cairo_status_t
- _cairo_xlib_font_show_text (cairo_xlib_font_t		*font,
- 			    cairo_matrix_t		*ctm,
- 			    cairo_operator_t		operator,
- 			    cairo_surface_t		*source,
- 			    cairo_surface_t		*surface,
- 			    double			x,
- 			    double			y,
- 			    const unsigned char	*utf8)
- {
-     Picture source_picture, surface_picture;
- 
-     _cairo_xlib_font_resolve (font, ctm);
- 
-     source_picture = _cairo_xlib_surface_get_picture (source);
-     surface_picture = _cairo_xlib_surface_get_picture (surface);
- 
-     XftTextRenderUtf8 (font->dpy,
- 		       operator,
- 		       source_picture,
- 		       font->xft_font,
- 		       surface_picture,
- 		       0, 0,
- 		       x, y,
- 		       utf8,
- 		       strlen ((char *) utf8));
- 
-     return CAIRO_STATUS_SUCCESS;
- }
- 
- static const struct cairo_font_backend cairo_xlib_font_backend = {
-     copy:		(void *) _cairo_xlib_font_copy,
-     close:		(void *) _cairo_xlib_font_close,
-     text_extents:	(void *) _cairo_xlib_font_text_extents,
-     show_text:		(void *) _cairo_xlib_font_show_text,
- };
- 
- static cairo_font_t *
- _cairo_xlib_font_create (Display *dpy)
- {
-     cairo_xlib_font_t *font;
-     font = malloc (sizeof (cairo_xlib_font_t));
-     if (!font)
- 	return 0;
- 
-     _cairo_font_init (&font->base, &cairo_xlib_font_backend);
- 
-     font->dpy = dpy;
-     font->xft_font = NULL;
- 
-     return &font->base;
- }
--- 527,528 ----

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** cairoint.h	23 Oct 2003 14:47:29 -0000	1.29
--- cairoint.h	23 Oct 2003 22:22:29 -0000	1.30
***************
*** 229,232 ****
--- 229,286 ----
  typedef struct cairo_color cairo_color_t;
  
+ struct cairo_font_backend {
+ 
+     cairo_status_t (*font_extents)   (cairo_font_t         *font,
+ 				      cairo_font_extents_t *extents);
+ 
+     cairo_status_t (*text_extents)   (cairo_font_t         *font,
+ 				      const unsigned char  *utf8,
+ 				      cairo_text_extents_t *extents);
+   
+     cairo_status_t (*glyph_extents)  (cairo_font_t         *font,
+ 				      cairo_glyph_t        *glyphs, 
+ 				      int                  num_glyphs,
+ 				      cairo_text_extents_t *extents);
+   
+     cairo_status_t (*show_text)      (cairo_font_t        *font,
+ 				      cairo_operator_t    operator,
+ 				      cairo_surface_t     *source,
+ 				      cairo_surface_t     *surface,
+ 				      double              x,
+ 				      double              y,
+ 				      const unsigned char *utf8);
+ 
+     cairo_status_t (*show_glyphs)    (cairo_font_t        *font,
+ 				      cairo_operator_t    operator,
+ 				      cairo_surface_t     *source,
+ 				      cairo_surface_t     *surface,
+ 				      double              x,
+ 				      double              y,
+ 				      const cairo_glyph_t *glyphs,
+ 				      int                 num_glyphs);
+   
+     cairo_status_t (*text_path)      (cairo_font_t        *font,
+ 				      cairo_path_t        *path, 
+ 				      const unsigned char *utf8);
+ 
+     cairo_status_t (*glyph_path)     (cairo_font_t        *font,
+ 				      cairo_path_t        *path, 
+ 				      cairo_glyph_t       *glyphs, 
+ 				      int                 num_glyphs);
+ 
+     cairo_font_t *(*create)          (const char          *family,
+ 				      cairo_font_slant_t  slant,
+ 				      cairo_font_weight_t weight);
+ 				    
+     cairo_font_t *(*copy)            (cairo_font_t        *other);
+ 
+     void (*close)                    (cairo_font_t        *font);
+   
+ };
+ 
+ /* concrete font backends */
+ extern const struct cairo_font_backend cairo_ft_font_backend;
+ 
+ 
  struct cairo_surface_backend {
      cairo_surface_t *(*create_similar) (cairo_surface_t	*surface,
***************
*** 264,267 ****
--- 318,322 ----
  				 cairo_trapezoid_t	*traps,
  				 int			num_traps);
+ 
  };
  
***************
*** 312,342 ****
  } cairo_traps_t;
  
! typedef struct cairo_font cairo_font_t;
! 
! struct cairo_font_backend {
!     cairo_font_t *(*copy) (cairo_font_t *other);
!     void (*close) (cairo_font_t *font);
!     cairo_status_t (*text_extents) (cairo_font_t *font,
! 				    cairo_matrix_t *ctm,
! 				    const unsigned char *utf8,
! 				    double *x, double *y,
! 				    double *width, double *height,
! 				    double *dx, double *dy);
!     cairo_status_t (*show_text) (cairo_font_t		*font,
! 				 cairo_matrix_t		*ctm,
! 				 cairo_operator_t	operator,
! 				 cairo_surface_t	*source,
! 				 cairo_surface_t	*surface,
! 				 double			x,
! 				 double			y,
! 				 const unsigned char	*utf8);
! };
! 
! #define CAIRO_FONT_KEY_DEFAULT		"serif"
  
  struct cairo_font {
!     unsigned char *key;
      cairo_matrix_t matrix;
! 
      const struct cairo_font_backend *backend;
  };
--- 367,380 ----
  } cairo_traps_t;
  
! #define CAIRO_FONT_FAMILY_DEFAULT  "serif"
! #define CAIRO_FONT_SLANT_DEFAULT   CAIRO_FONT_SLANT_NORMAL
! #define CAIRO_FONT_WEIGHT_DEFAULT  CAIRO_FONT_WEIGHT_NORMAL
  
  struct cairo_font {
!     int refcount;
!     unsigned char *family;
      cairo_matrix_t matrix;
!     cairo_font_slant_t slant;
!     cairo_font_weight_t weight;
      const struct cairo_font_backend *backend;
  };
***************
*** 632,660 ****
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_select_font (cairo_gstate_t *gstate, const char *key);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_scale_font (cairo_gstate_t *gstate, double scale);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_transform_font (cairo_gstate_t *gstate,
! 			      double a, double b,
! 			      double c, double d);
  
  extern cairo_status_t __internal_linkage
  _cairo_gstate_text_extents (cairo_gstate_t *gstate,
  			    const unsigned char *utf8,
! 			    double *x, double *y,
! 			    double *width, double *height,
! 			    double *dx, double *dy);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_show_text (cairo_gstate_t *gstate, const unsigned char *utf8);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_show_surface (cairo_gstate_t	*gstate,
! 			    cairo_surface_t	*surface,
! 			    int			width,
! 			    int			height);
  
  /* cairo_color.c */
--- 670,734 ----
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_show_surface (cairo_gstate_t	*gstate,
! 			    cairo_surface_t	*surface,
! 			    int			width,
! 			    int			height);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_select_font (cairo_gstate_t *gstate, 
! 			   char *family, 
! 			   cairo_font_slant_t slant, 
! 			   cairo_font_weight_t weight);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_scale_font (cairo_gstate_t *gstate, 
! 			  double scale);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_transform_font (cairo_gstate_t *gstate, 
! 			      cairo_matrix_t *matrix);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_current_font (cairo_gstate_t *gstate, 
! 			    cairo_font_t **font);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_current_font_extents (cairo_gstate_t *gstate, 
! 				    cairo_font_extents_t *extents);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_set_font (cairo_gstate_t *gstate, 
! 			cairo_font_t *font);
! 
  
  extern cairo_status_t __internal_linkage
  _cairo_gstate_text_extents (cairo_gstate_t *gstate,
  			    const unsigned char *utf8,
! 			    cairo_text_extents_t *extents);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_glyph_extents (cairo_gstate_t *gstate,
! 			     cairo_glyph_t *glyphs, 
! 			     int num_glyphs,
! 			     cairo_text_extents_t *extents);
  
  extern cairo_status_t __internal_linkage
! _cairo_gstate_show_text (cairo_gstate_t *gstate, 
! 			 const unsigned char *utf8);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_show_glyphs (cairo_gstate_t *gstate, 
! 			   cairo_glyph_t *glyphs, 
! 			   int num_glyphs);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_text_path (cairo_gstate_t *gstate, 
! 			 const unsigned char *utf8);
! 
! extern cairo_status_t __internal_linkage
! _cairo_gstate_glyph_path (cairo_gstate_t *gstate, 
! 			  cairo_glyph_t *glyphs, 
! 			  int num_glyphs);
! 
  
  /* cairo_color.c */
***************
*** 675,683 ****
  
  /* cairo_font.c */
! extern cairo_int_status_t __internal_linkage
! _cairo_font_init (cairo_font_t *font, const struct cairo_font_backend *backend);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_init_copy (cairo_font_t *font, cairo_font_t *other);
  
  extern cairo_font_t * __internal_linkage
--- 749,761 ----
  
  /* cairo_font.c */
! 
! extern cairo_font_t * __internal_linkage
! _cairo_font_create_font (char                 *family, 
! 			 cairo_font_slant_t   slant, 
! 			 cairo_font_weight_t  weight);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_init (cairo_font_t *font, 
! 		  const struct cairo_font_backend *backend);
  
  extern cairo_font_t * __internal_linkage
***************
*** 687,718 ****
  _cairo_font_fini (cairo_font_t *font);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_select (cairo_font_t *font, const char *key);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_scale (cairo_font_t *font, double scale);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_transform (cairo_font_t *font,
! 		       double a, double b,
! 		       double c, double d);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_text_extents (cairo_font_t *font,
! 			  cairo_matrix_t *ctm,
! 			  const unsigned char *utf8,
! 			  double *x, double *y,
! 			  double *width, double *height,
! 			  double *dx, double *dy);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_show_text (cairo_font_t		*font,
! 		       cairo_matrix_t		*ctm,
! 		       cairo_operator_t		operator,
! 		       cairo_surface_t		*source,
! 		       cairo_surface_t		*surface,
! 		       double			x,
! 		       double			y,
! 		       const unsigned char	*utf8);
  
  /* cairo_hull.c */
--- 765,821 ----
  _cairo_font_fini (cairo_font_t *font);
  
+ extern cairo_status_t __internal_linkage
+ _cairo_font_scale (cairo_font_t *font, double scale);
+ 
+ extern cairo_status_t __internal_linkage
+ _cairo_font_transform (cairo_font_t *font, cairo_matrix_t *matrix);
+ 
  extern cairo_int_status_t __internal_linkage
! _cairo_font_font_extents (cairo_font_t *font, 
! 			  cairo_font_extents_t *extents);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_text_extents (cairo_font_t *font,
!                           const unsigned char *utf8,
! 			  cairo_text_extents_t *extents);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_glyph_extents (cairo_font_t *font,
!                            cairo_glyph_t *glyphs,
!                            int num_glyphs,
! 			   cairo_text_extents_t *extents);
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_show_text (cairo_font_t             *font,
!                        cairo_operator_t         operator,
!                        cairo_surface_t          *source,
!                        cairo_surface_t          *surface,
!                        double                   x,
!                        double                   y,
!                        const unsigned char      *utf8);
! 
  
  extern cairo_int_status_t __internal_linkage
! _cairo_font_show_glyphs (cairo_font_t           *font,
!                          cairo_operator_t       operator,
!                          cairo_surface_t        *source,
!                          cairo_surface_t        *surface,
!                          double                 x,
!                          double                 y,
!                          cairo_glyph_t          *glyphs,
!                          int                    num_glyphs);
! 
! 
! extern cairo_int_status_t __internal_linkage
! _cairo_font_text_path (cairo_font_t             *font,
!                        cairo_path_t             *path,
!                        const unsigned char      *utf8);
! 
! extern cairo_int_status_t __internal_linkage
! _cairo_font_glyph_path (cairo_font_t            *font,
!                         cairo_path_t            *path,
!                         cairo_glyph_t           *glyphs, 
!                         int                     num_glyphs);
! 
  
  /* cairo_hull.c */
***************
*** 815,818 ****
--- 918,922 ----
  _cairo_surface_push_image (cairo_surface_t *surface);
  
+ 
  /* cairo_pen.c */
  extern cairo_status_t __internal_linkage





More information about the cairo-commit mailing list