[cairo-commit] cairo/src cairo.c,1.31,1.32 cairo.h,1.38,1.39 cairo_ft_font.c,1.16,1.17 cairo_gstate.c,1.39,1.40 cairoint.h,1.48,1.49

Carl Worth commit at pdx.freedesktop.org
Tue Dec 16 07:20:22 PST 2003


Committed by: cworth

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

Modified Files:
	cairo.c cairo.h cairo_ft_font.c cairo_gstate.c cairoint.h 
Log Message:

        * configure.in: Bump version to 0.1.17 for new functions:
        cairo_text_extents, cairo_glyph_extents, cairo_text_path,
        cairo_glyph_path.

        * src/cairo.h:
        * src/cairo.c (cairo_text_path):
        (cairo_glyph_path): Re-enable cairo_text_path and cairo_glyph_path.

        * src/cairo_gstate.c (_cairo_gstate_glyph_path): Add missing
        transformation.

        * src/cairo_ft_font.c (_move_to):
        (_line_to):
        (_conic_to):
        (_cubic_to):
        (_cairo_ft_font_glyph_path): Initial implementation of glyph_path.


Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** cairo.c	16 Dec 2003 02:26:51 -0000	1.31
--- cairo.c	16 Dec 2003 15:20:20 -0000	1.32
***************
*** 707,711 ****
  }
  
- 
  void
  cairo_text_extents (cairo_t                *cr,
--- 707,710 ----
***************
*** 750,754 ****
  }
  
- /* XXX: NYI
  void
  cairo_text_path  (cairo_t *cr, const unsigned char *utf8)
--- 749,752 ----
***************
*** 768,772 ****
      cr->status = _cairo_gstate_glyph_path (cr->gstate, glyphs, num_glyphs);  
  }
- */
  
  void
--- 766,769 ----

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** cairo.h	16 Dec 2003 03:00:15 -0000	1.38
--- cairo.h	16 Dec 2003 15:20:20 -0000	1.39
***************
*** 419,424 ****
  		     cairo_text_extents_t  *extents);
  
- /* XXX: NYI
- 
  extern void __external_linkage
  cairo_text_path  (cairo_t *ct, const unsigned char *utf8);
--- 419,422 ----
***************
*** 427,433 ****
  cairo_glyph_path (cairo_t *ct, cairo_glyph_t *glyphs, int num_glyphs);
  
- */
- 
- 
  /* Portable interface to general font features. */
    
--- 425,428 ----
***************
*** 468,475 ****
  cairo_ft_font_pattern (cairo_font_t  *ft_font);
  
- 
- 
  /* Image functions */
  
  extern void __external_linkage
  cairo_show_surface (cairo_t		*cr,
--- 463,469 ----
  cairo_ft_font_pattern (cairo_font_t  *ft_font);
  
  /* Image functions */
  
+ /* XXX: Eliminate width/height here */
  extern void __external_linkage
  cairo_show_surface (cairo_t		*cr,

Index: cairo_ft_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_ft_font.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** cairo_ft_font.c	16 Dec 2003 14:58:10 -0000	1.16
--- cairo_ft_font.c	16 Dec 2003 15:20:20 -0000	1.17
***************
*** 590,608 ****
  }
  
  
  static cairo_status_t 
! _cairo_ft_font_glyph_path (void			*font,
                             cairo_glyph_t	*glyphs, 
                             int			num_glyphs,
                             cairo_path_t		*path)
  {
!     cairo_status_t status = CAIRO_STATUS_SUCCESS;
!     cairo_ft_font_t *ft;
!     
!     ft = (cairo_ft_font_t *)font;
!     
!     /* XXX: lift code from xft to do this */
      
!     return status;
  }
  
--- 590,699 ----
  }
  
+ static int
+ _move_to (FT_Vector *to, void *closure)
+ {
+     cairo_path_t *path = closure;
+ 
+     _cairo_path_close_path (path);
+     _cairo_path_move_to (path,
+ 			 DOUBLE_FROM_26_6(to->x),
+ 			 DOUBLE_FROM_26_6(to->y));
+ 
+     return 0;
+ }
+ 
+ static int
+ _line_to (FT_Vector *to, void *closure)
+ {
+     cairo_path_t *path = closure;
+ 
+     _cairo_path_line_to (path,
+ 			 DOUBLE_FROM_26_6(to->x),
+ 			 DOUBLE_FROM_26_6(to->y));
+ 
+     return 0;
+ }
+ 
+ static int
+ _conic_to (FT_Vector *control, FT_Vector *to, void *closure)
+ {
+     cairo_path_t *path = closure;
+ 
+     double x1, y1;
+     double x2 = DOUBLE_FROM_26_6(control->x);
+     double y2 = DOUBLE_FROM_26_6(control->y);
+     double x3 = DOUBLE_FROM_26_6(to->x);
+     double y3 = DOUBLE_FROM_26_6(to->y);
+ 
+     _cairo_path_current_point (path, &x1, &y1);
+ 
+     _cairo_path_curve_to (path,
+ 			  x1 + 2.0/3.0 * (x2 - x1), y1 + 2.0/3.0 * (y2 - y1),
+ 			  x3 + 2.0/3.0 * (x2 - x3), y3 + 2.0/3.0 * (y2 - y3),
+ 			  x3, y3);
+ 
+     return 0;
+ }
+ 
+ static int
+ _cubic_to (FT_Vector *control1, FT_Vector *control2, FT_Vector *to, void *closure)
+ {
+     cairo_path_t *path = closure;
+ 
+     _cairo_path_curve_to (path, 
+ 			  DOUBLE_FROM_26_6(control1->x), DOUBLE_FROM_26_6(control1->y),
+ 			  DOUBLE_FROM_26_6(control2->x), DOUBLE_FROM_26_6(control2->y),
+ 			  DOUBLE_FROM_26_6(to->x), DOUBLE_FROM_26_6(to->y));
+ 
+     return 0;
+ }
  
  static cairo_status_t 
! _cairo_ft_font_glyph_path (void			*abstract_font,
                             cairo_glyph_t	*glyphs, 
                             int			num_glyphs,
                             cairo_path_t		*path)
  {
!     int i;
!     cairo_ft_font_t *font = abstract_font;
!     FT_GlyphSlot glyph;
!     FT_Error error;
!     FT_Outline_Funcs outline_funcs = {
! 	_move_to,
! 	_line_to,
! 	_conic_to,
! 	_cubic_to,
! 	0, /* shift */
! 	0, /* delta */
!     };
! 
!     glyph = font->face->glyph;
!     _install_font_matrix (&font->base.matrix, font->face);
! 
!     for (i = 0; i < num_glyphs; i++)
!     {
! 	FT_Matrix invert_y = {
! 	    DOUBLE_TO_16_16 (1.0), 0,
! 	    0, DOUBLE_TO_16_16 (-1.0),
! 	};
! 
! 	error = FT_Load_Glyph (font->face, glyphs[i].index, FT_LOAD_DEFAULT);
! 	/* XXX: What to do in this error case? */
! 	if (error)
! 	    continue;
! 	/* XXX: Do we want to support bitmap fonts here? */
! 	if (glyph->format == ft_glyph_format_bitmap)
! 	    continue;
! 
! 	/* Font glyphs have an inverted Y axis compared to cairo. */
! 	FT_Outline_Transform (&glyph->outline, &invert_y);
! 	FT_Outline_Translate (&glyph->outline,
! 			      DOUBLE_TO_26_6(glyphs[i].x),
! 			      DOUBLE_TO_26_6(glyphs[i].y));
! 	FT_Outline_Decompose (&glyph->outline, &outline_funcs, path);
!     }
!     _cairo_path_close_path (path);
      
!     return CAIRO_STATUS_SUCCESS;
  }
  
***************
*** 629,633 ****
  }
  
- 
  cairo_font_t *
  cairo_ft_font_create_for_ft_face (FT_Face face)
--- 720,723 ----
***************
*** 652,656 ****
  }
  
- 
  const struct cairo_font_backend cairo_ft_font_backend = {
      _cairo_ft_font_create,
--- 742,745 ----

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** cairo_gstate.c	16 Dec 2003 15:10:48 -0000	1.39
--- cairo_gstate.c	16 Dec 2003 15:20:20 -0000	1.40
***************
*** 1647,1651 ****
      }
  
!     status = setup_text_rendering_context(gstate, &user_to_source);
      if (status)
  	return status;
--- 1647,1651 ----
      }
  
!     status = setup_text_rendering_context (gstate, &user_to_source);
      if (status)
  	return status;
***************
*** 1745,1749 ****
  
  cairo_status_t
! _cairo_gstate_glyph_path (cairo_gstate_t *gstate, 
  			  cairo_glyph_t *glyphs, 
  			  int num_glyphs)
--- 1745,1749 ----
  
  cairo_status_t
! _cairo_gstate_glyph_path (cairo_gstate_t *gstate,
  			  cairo_glyph_t *glyphs, 
  			  int num_glyphs)
***************
*** 1752,1755 ****
--- 1752,1756 ----
      int i;
      cairo_glyph_t *transformed_glyphs = NULL;
+     cairo_matrix_t user_to_source;
      cairo_matrix_t saved_font_matrix;
  
***************
*** 1766,1769 ****
--- 1767,1774 ----
      }
  
+     status = setup_text_rendering_context (gstate, &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);
***************
*** 1774,1777 ****
--- 1779,1783 ----
  
      cairo_matrix_copy (&gstate->font->matrix, &saved_font_matrix);
+     restore_text_rendering_context (gstate, &user_to_source);
      
      free (transformed_glyphs);

Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** cairoint.h	16 Dec 2003 15:10:48 -0000	1.48
--- cairoint.h	16 Dec 2003 15:20:20 -0000	1.49
***************
*** 262,266 ****
  
      void (*destroy)		     (void			*font);
!   
      cairo_status_t (*font_extents)   (void			*font,
  				      cairo_font_extents_t	*extents);
--- 262,266 ----
  
      void (*destroy)		     (void			*font);
! 
      cairo_status_t (*font_extents)   (void			*font,
  				      cairo_font_extents_t	*extents);
***************
*** 300,304 ****
  				      int			num_glyphs,
  				      cairo_path_t		*path);
- 
  } cairo_font_backend_t;
  
--- 300,303 ----





More information about the cairo-commit mailing list