[cairo-commit] cairo/src cairo-win32.h, 1.4, 1.5 cairo.h, 1.71, 1.72 cairo_font.c, 1.33, 1.34 cairo_gstate.c, 1.79, 1.80 cairo_win32_font.c, 1.5, 1.6

Owen Taylor commit at pdx.freedesktop.org
Wed Feb 2 23:14:57 PST 2005


Committed by: otaylor

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv9567/src

Modified Files:
	cairo-win32.h cairo.h cairo_font.c cairo_gstate.c 
	cairo_win32_font.c 
Log Message:
2005-02-03 Owen Taylor <otaylor at redhat.com>

        * src/cairo_font.c src/cairo.h doc/public/cairo-sections.txt:
        Add cairo_font_extents().

        * src/cairo_win32_font.c src/cairo-win32.h doc/public/cairo-sections.txt:
        Rename cairo_font_create_for_logfont() into
        cairo_font_create_for_logfontw() to make clear what it takes. 
        Don't add cairo_font_create_for_logfonta() for now.


Index: cairo-win32.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-win32.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cairo-win32.h	3 Feb 2005 02:57:40 -0000	1.4
+++ cairo-win32.h	3 Feb 2005 07:14:55 -0000	1.5
@@ -51,8 +51,8 @@
 cairo_win32_surface_create (HDC hdc);
 
 cairo_font_t *
-cairo_win32_font_create_for_logfont (LOGFONTW       *logfont,
-				     cairo_matrix_t *scale);
+cairo_win32_font_create_for_logfontw (LOGFONTW       *logfont,
+				      cairo_matrix_t *scale);
 
 cairo_status_t
 cairo_win32_font_select_font (cairo_font_t *font,

Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cairo.h	1 Feb 2005 23:06:36 -0000	1.71
+++ cairo.h	3 Feb 2005 07:14:55 -0000	1.72
@@ -97,6 +97,18 @@
 typedef struct _cairo_matrix cairo_matrix_t;
 typedef struct _cairo_pattern cairo_pattern_t;
 
+typedef enum cairo_status {
+    CAIRO_STATUS_SUCCESS = 0,
+    CAIRO_STATUS_NO_MEMORY,
+    CAIRO_STATUS_INVALID_RESTORE,
+    CAIRO_STATUS_INVALID_POP_GROUP,
+    CAIRO_STATUS_NO_CURRENT_POINT,
+    CAIRO_STATUS_INVALID_MATRIX,
+    CAIRO_STATUS_NO_TARGET_SURFACE,
+    CAIRO_STATUS_NULL_POINTER,
+    CAIRO_STATUS_INVALID_STRING
+} cairo_status_t;
+
 /* Functions for manipulating state objects */
 cairo_t *
 cairo_create (void);
@@ -584,6 +596,11 @@
 void
 cairo_font_destroy (cairo_font_t *font);
 
+cairo_status_t
+cairo_font_extents (cairo_font_t         *font,
+		    cairo_matrix_t       *font_matrix,
+		    cairo_font_extents_t *extents);
+
 void
 cairo_font_glyph_extents (cairo_font_t          *font,
 			  cairo_matrix_t        *font_matrix,
@@ -682,18 +699,6 @@
 
 /* Error status queries */
 
-typedef enum cairo_status {
-    CAIRO_STATUS_SUCCESS = 0,
-    CAIRO_STATUS_NO_MEMORY,
-    CAIRO_STATUS_INVALID_RESTORE,
-    CAIRO_STATUS_INVALID_POP_GROUP,
-    CAIRO_STATUS_NO_CURRENT_POINT,
-    CAIRO_STATUS_INVALID_MATRIX,
-    CAIRO_STATUS_NO_TARGET_SURFACE,
-    CAIRO_STATUS_NULL_POINTER,
-    CAIRO_STATUS_INVALID_STRING
-} cairo_status_t;
-
 cairo_status_t
 cairo_status (cairo_t *cr);
 

Index: cairo_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_font.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- cairo_font.c	27 Jan 2005 23:46:17 -0000	1.33
+++ cairo_font.c	3 Feb 2005 07:14:55 -0000	1.34
@@ -192,6 +192,50 @@
 }
 
 /**
+ * cairo_font_extents:
+ * @font: a #cairo_font_t
+ * @font_matrix: the font transformation for which this font was
+ *    created. (See cairo_transform_font()). This is needed
+ *    properly convert the metrics from the font into user space.
+ * @extents: a #cairo_font_extents_t which to store the retrieved extents.
+ * 
+ * Gets the metrics for a #cairo_font_t. 
+ * 
+ * Return value: %CAIRO_STATUS_SUCCESS on success. Otherwise, an
+ *  error such as %CAIRO_STATUS_NO_MEMORY.
+ **/
+cairo_status_t
+cairo_font_extents (cairo_font_t         *font,
+		    cairo_matrix_t       *font_matrix,
+		    cairo_font_extents_t *extents)
+{
+    cairo_int_status_t status;
+    double  font_scale_x, font_scale_y;
+
+    status = _cairo_font_font_extents (font, extents);
+
+    if (!CAIRO_OK (status))
+      return status;
+    
+    _cairo_matrix_compute_scale_factors (font_matrix,
+					 &font_scale_x, &font_scale_y,
+					 /* XXX */ 1);
+    
+    /* 
+     * The font responded in unscaled units, scale by the font
+     * matrix scale factors to get to user space
+     */
+    
+    extents->ascent *= font_scale_y;
+    extents->descent *= font_scale_y;
+    extents->height *= font_scale_y;
+    extents->max_x_advance *= font_scale_x;
+    extents->max_y_advance *= font_scale_y;
+      
+    return status;
+}
+
+/**
  * cairo_font_glyph_extents:
  * @font: a #cairo_font_t
  * @font_matrix: the font transformation for which this font was

Index: cairo_gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_gstate.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- cairo_gstate.c	1 Feb 2005 23:06:36 -0000	1.79
+++ cairo_gstate.c	3 Feb 2005 07:14:55 -0000	1.80
@@ -2254,31 +2254,13 @@
 _cairo_gstate_current_font_extents (cairo_gstate_t *gstate, 
 				    cairo_font_extents_t *extents)
 {
-    cairo_int_status_t status;
-    double  font_scale_x, font_scale_y;
-
-    status = _cairo_gstate_ensure_font (gstate);
+    cairo_status_t status = _cairo_gstate_ensure_font (gstate);
     if (status)
 	return status;
-    
-    status = _cairo_font_font_extents (gstate->font, extents);
 
-    _cairo_matrix_compute_scale_factors (&gstate->font_matrix,
-					 &font_scale_x, &font_scale_y,
-					 /* XXX */ 1);
-    
-    /* 
-     * The font responded in unscaled units, scale by the font
-     * matrix scale factors to get to user space
-     */
-      
-    extents->ascent *= font_scale_y;
-    extents->descent *= font_scale_y;
-    extents->height *= font_scale_y;
-    extents->max_x_advance *= font_scale_x;
-    extents->max_y_advance *= font_scale_y;
-    
-    return status;
+    return cairo_font_extents (gstate->font,
+			       &gstate->font_matrix,
+			       extents);
 }
 
 cairo_status_t

Index: cairo_win32_font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo_win32_font.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo_win32_font.c	3 Feb 2005 03:52:23 -0000	1.5
+++ cairo_win32_font.c	3 Feb 2005 07:14:55 -0000	1.6
@@ -55,6 +55,7 @@
     cairo_font_t base;
 
     LOGFONTW logfont;
+
     BYTE quality;
 
     /* We do drawing and metrics computation in a "logical space" which
@@ -1124,7 +1125,7 @@
 /* implement the platform-specific interface */
 
 /**
- * cairo_win32_font_create:
+ * cairo_win32_font_create_for_logfontw:
  * @logfont: A #LOGFONTW structure specifying the font to use.
  *   The lfHeight, lfWidth, lfOrientation and lfEscapement
  *   fields of this structure are ignored; information from
@@ -1143,8 +1144,8 @@
  *  cairo_font_destroy() when you are done using it.
  **/
 cairo_font_t *
-cairo_win32_font_create_for_logfont (LOGFONTW       *logfont,
-				     cairo_matrix_t *scale)
+cairo_win32_font_create_for_logfontw (LOGFONTW       *logfont,
+				      cairo_matrix_t *scale)
 {
     cairo_font_scale_t sc;
     
@@ -1159,7 +1160,7 @@
 /**
  * cairo_win32_font_select_font:
  * @font: A #cairo_font_t from the Win32 font backend. Such an
- *   object can be created with cairo_win32_font_create_for_logfont().
+ *   object can be created with cairo_win32_font_create_for_logfontw().
  * @hdc: a device context
  *
  * Selects the font into the given device context and changes the




More information about the cairo-commit mailing list