[cairo-commit] cairo/src cairo_font.c,1.12,1.13 cairo_gstate.c,1.21,1.22 cairoint.h,1.30,1.31

Carl Worth commit at pdx.freedesktop.org
Fri Oct 24 10:01:36 PDT 2003


Committed by: cworth

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

Modified Files:
	cairo_font.c cairo_gstate.c cairoint.h 
Log Message:
Create a font by default.
Remove bogus NULL_POINTER status errors leaking to the outside.

Index: cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_font.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** cairo_font.c	23 Oct 2003 22:22:28 -0000	1.12
--- cairo_font.c	24 Oct 2003 17:01:34 -0000	1.13
***************
*** 28,38 ****
  #include "cairoint.h"
  
! 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)
--- 28,45 ----
  #include "cairoint.h"
  
! cairo_font_t *
! _cairo_font_create (char                 *family, 
! 		    cairo_font_slant_t   slant, 
! 		    cairo_font_weight_t  weight)
! {
!     const struct cairo_font_backend *backend = CAIRO_FONT_BACKEND_DEFAULT;
! 
!     return backend->create (family, slant, weight);
! }
! 
! cairo_status_t
  _cairo_font_init (cairo_font_t *font, 
  		  const struct cairo_font_backend *backend)
  {
      font->family = (unsigned char *) strdup (CAIRO_FONT_FAMILY_DEFAULT);
      if (font->family == NULL)
***************
*** 100,106 ****
  _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);
  }
--- 107,110 ----
***************
*** 109,131 ****
  _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,
--- 113,129 ----
  _cairo_font_transform (cairo_font_t *font, cairo_matrix_t *matrix)
  {
      return cairo_matrix_multiply (&font->matrix, matrix, &font->matrix);
  }
  
  
! cairo_status_t
  _cairo_font_text_extents (cairo_font_t *font,
  			  const unsigned char *utf8,
  			  cairo_text_extents_t *extents)
  {
      return font->backend->text_extents(font, utf8, extents);
  }
  
! cairo_status_t
  _cairo_font_glyph_extents (cairo_font_t *font,
                             cairo_glyph_t *glyphs,
***************
*** 133,144 ****
  			   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,
--- 131,139 ----
  			   cairo_text_extents_t *extents)
  {
      return font->backend->glyph_extents(font, glyphs, num_glyphs, extents);
  }
  
  
! cairo_status_t
  _cairo_font_show_text (cairo_font_t		*font,
  		       cairo_operator_t		operator,
***************
*** 149,160 ****
  		       const unsigned char	*utf8)
  {
-     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,
--- 144,152 ----
  		       const unsigned char	*utf8)
  {
      return font->backend->show_text(font, operator, source, 
  				    surface, x, y, utf8);
  }
  
! cairo_status_t
  _cairo_font_show_glyphs (cairo_font_t           *font,
                           cairo_operator_t       operator,
***************
*** 166,188 ****
                           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,
--- 158,174 ----
                           int                    num_glyphs)
  {
      return font->backend->show_glyphs(font, operator, source, 
  				      surface, x, y, glyphs, num_glyphs);
  }
  
! cairo_status_t
  _cairo_font_text_path (cairo_font_t             *font,
                         cairo_path_t             *path,
                         const unsigned char      *utf8)
  {
      return font->backend->text_path(font, path, utf8);
  }
  
! cairo_status_t
  _cairo_font_glyph_path (cairo_font_t            *font,
                          cairo_path_t            *path,
***************
*** 190,224 ****
                          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 */
  
--- 176,190 ----
                          int                     num_glyphs)
  {
      return font->backend->glyph_path(font, path, 
  				     glyphs, num_glyphs);
  }
  
! cairo_status_t
  _cairo_font_font_extents (cairo_font_t *font,
  			  cairo_font_extents_t *extents)
  {
      return font->backend->font_extents(font, extents);
  }
  
  /* public font interface follows */
  

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** cairo_gstate.c	23 Oct 2003 22:22:29 -0000	1.21
--- cairo_gstate.c	24 Oct 2003 17:01:34 -0000	1.22
***************
*** 75,79 ****
      gstate->dash_offset = 0.0;
  
!     gstate->font = NULL;
  
      gstate->surface = NULL;
--- 75,81 ----
      gstate->dash_offset = 0.0;
  
!     gstate->font = _cairo_font_create (CAIRO_FONT_FAMILY_DEFAULT,
! 				       CAIRO_FONT_SLANT_DEFAULT,
! 				       CAIRO_FONT_WEIGHT_DEFAULT);
  
      gstate->surface = NULL;
***************
*** 1424,1430 ****
  	_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;
--- 1426,1430 ----
  	_cairo_font_fini (gstate->font);
  
!     gstate->font = _cairo_font_create (family, slant, weight);
    
      return CAIRO_STATUS_SUCCESS;
***************
*** 1449,1456 ****
  			    cairo_font_t **font)
  {
-     if (font == NULL)
- 	return CAIRO_INT_STATUS_NULL_POINTER;
-   
      *font = gstate->font;
      return CAIRO_STATUS_SUCCESS;
  }
--- 1449,1454 ----
  			    cairo_font_t **font)
  {
      *font = gstate->font;
+ 
      return CAIRO_STATUS_SUCCESS;
  }
***************
*** 1463,1469 ****
      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);
--- 1461,1464 ----

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** cairoint.h	23 Oct 2003 22:22:29 -0000	1.30
--- cairoint.h	24 Oct 2003 17:01:34 -0000	1.31
***************
*** 130,134 ****
  typedef enum cairo_int_status {
      CAIRO_INT_STATUS_DEGENERATE = 1000,
-     CAIRO_INT_STATUS_NULL_POINTER
  } cairo_int_status_t;
  
--- 130,133 ----
***************
*** 371,374 ****
--- 370,376 ----
  #define CAIRO_FONT_WEIGHT_DEFAULT  CAIRO_FONT_WEIGHT_NORMAL
  
+ /* XXX: Platform-specific. Other platforms may want a different default */
+ #define CAIRO_FONT_BACKEND_DEFAULT &cairo_ft_font_backend
+ 
  struct cairo_font {
      int refcount;
***************
*** 751,757 ****
  
  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
--- 753,759 ----
  
  extern cairo_font_t * __internal_linkage
! _cairo_font_create (char                 *family, 
! 		    cairo_font_slant_t   slant, 
! 		    cairo_font_weight_t  weight);
  
  extern cairo_int_status_t __internal_linkage





More information about the cairo-commit mailing list