[cairo-commit] 6 commits - doc/public src/cairo.c src/cairo-gstate.c src/cairo.h src/cairoint.h src/cairo-quartz-surface.c src/cairo-scaled-font.c test/font-face-get-type.c TODO

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Feb 27 17:22:13 PST 2007


 TODO                          |    2 
 doc/public/cairo-sections.txt |   34 +++++++++++-----
 src/cairo-gstate.c            |   15 +++++++
 src/cairo-quartz-surface.c    |   24 +++++------
 src/cairo-scaled-font.c       |    2 
 src/cairo.c                   |   87 ++++++++++++++++++++++++++++--------------
 src/cairo.h                   |   23 ++++++-----
 src/cairoint.h                |    6 ++
 test/font-face-get-type.c     |   14 +++++-
 9 files changed, 141 insertions(+), 66 deletions(-)

New commits:
diff-tree d30178b3dcebcdd89dc773881fc1b9097f1f50a7 (from ef53465a032a74fd50b7edaef19cae08586f44d4)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 27 20:22:05 2007 -0500

    [doc] Add new APIs to cairo-sections.txt

diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index 79524f3..c144281 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -112,22 +112,23 @@ cairo_svg_version_to_string 
 cairo_surface_t
 cairo_content_t
 cairo_surface_create_similar
+cairo_surface_reference
 cairo_surface_destroy
+cairo_surface_status
 cairo_surface_finish
 cairo_surface_flush
 cairo_surface_get_font_options
 cairo_surface_get_content
-cairo_surface_set_user_data
-cairo_surface_get_user_data
 cairo_surface_mark_dirty
 cairo_surface_mark_dirty_rectangle
-cairo_surface_reference
 cairo_surface_set_device_offset
 cairo_surface_get_device_offset
 cairo_surface_set_fallback_resolution
-cairo_surface_status
 cairo_surface_type_t
 cairo_surface_get_type
+cairo_surface_get_reference_count
+cairo_surface_set_user_data
+cairo_surface_get_user_data
 </SECTION>
 
 <SECTION>
@@ -160,8 +161,8 @@ cairo_pattern_create_linear
 cairo_pattern_get_linear_points
 cairo_pattern_create_radial
 cairo_pattern_get_radial_circles
-cairo_pattern_destroy
 cairo_pattern_reference
+cairo_pattern_destroy
 cairo_pattern_status
 cairo_extend_t
 cairo_pattern_set_extend
@@ -173,6 +174,9 @@ cairo_pattern_set_matrix
 cairo_pattern_get_matrix
 cairo_pattern_type_t
 cairo_pattern_get_type
+cairo_pattern_get_reference_count
+cairo_pattern_set_user_data
+cairo_pattern_get_user_data
 </SECTION>
 
 <SECTION>
@@ -208,10 +212,11 @@ cairo_font_face_t
 cairo_font_face_reference
 cairo_font_face_destroy
 cairo_font_face_status
-cairo_font_face_get_user_data
-cairo_font_face_set_user_data
 cairo_font_type_t
 cairo_font_face_get_type
+cairo_font_face_get_reference_count
+cairo_font_face_set_user_data
+cairo_font_face_get_user_data
 </SECTION>
 
 <SECTION>
@@ -232,6 +237,9 @@ cairo_scaled_font_get_font_options
 cairo_scaled_font_get_font_matrix
 cairo_scaled_font_get_ctm
 cairo_scaled_font_get_type
+cairo_scaled_font_get_reference_count
+cairo_scaled_font_set_user_data
+cairo_scaled_font_get_user_data
 </SECTION>
 
 <SECTION>
@@ -385,7 +393,7 @@ cairo_reset_clip
 cairo_rectangle_t
 cairo_rectangle_list_t
 cairo_rectangle_list_destroy
-cairo_copy_clip_rectangles
+cairo_copy_clip_rectangle_list
 cairo_fill
 cairo_fill_preserve
 cairo_fill_extents
@@ -400,6 +408,9 @@ cairo_stroke_extents
 cairo_in_stroke
 cairo_copy_page
 cairo_show_page
+cairo_get_reference_count
+cairo_set_user_data
+cairo_get_user_data
 <SUBSECTION Private>
 cairo_public
 CAIRO_BEGIN_DECLS
diff-tree ef53465a032a74fd50b7edaef19cae08586f44d4 (from ed75e24898a5ccd7836596122b9a801294122874)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 27 20:18:16 2007 -0500

    Slim-hidden cairo_scale()

diff --git a/src/cairo.c b/src/cairo.c
index 1999d4a..d522032 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -1126,6 +1126,7 @@ cairo_scale (cairo_t *cr, double sx, dou
     if (cr->status)
 	_cairo_set_error (cr, cr->status);
 }
+slim_hidden_def (cairo_scale);
 
 /**
  * cairo_rotate:
diff --git a/src/cairoint.h b/src/cairoint.h
index 09d55ab..2233c9c 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2541,6 +2541,7 @@ slim_hidden_proto (cairo_push_group_with
 slim_hidden_proto (cairo_rel_line_to);
 slim_hidden_proto (cairo_restore);
 slim_hidden_proto (cairo_save);
+slim_hidden_proto (cairo_scale);
 slim_hidden_proto (cairo_scaled_font_create);
 slim_hidden_proto (cairo_scaled_font_destroy);
 slim_hidden_proto (cairo_scaled_font_extents);
diff-tree ed75e24898a5ccd7836596122b9a801294122874 (from d64b194a45d90b24d1cc01de0fa2cb4edc3a240b)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 27 20:09:22 2007 -0500

    Implement cairo_get_scaled_font()

diff --git a/TODO b/TODO
index 4e99fc8..6558edb 100644
--- a/TODO
+++ b/TODO
@@ -81,8 +81,6 @@ Other changes (this text used to be in R
 	http://lists.freedesktop.org/archives/cairo/2007-January/009372.html
      cairo_font_metrics_t
 	http://lists.freedesktop.org/archives/cairo/2007-January/009373.html
-     cairo_get_scaled_font()
-	http://lists.freedesktop.org/archives/cairo/2007-January/009374.html
      User-font API---a couple of threads of interest:
 	http://lists.freedesktop.org/archives/cairo/2007-February/009539.html
         http://lists.freedesktop.org/archives/cairo/2006-May/006893.html
diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index c79453f..79524f3 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -322,12 +322,13 @@ cairo_set_font_matrix
 cairo_get_font_matrix
 cairo_set_font_options
 cairo_get_font_options
+cairo_set_font_face
+cairo_get_font_face
+cairo_set_scaled_font
+cairo_get_scaled_font
 cairo_show_text
 cairo_show_glyphs
-cairo_get_font_face
 cairo_font_extents
-cairo_set_font_face
-cairo_set_scaled_font
 cairo_text_extents
 cairo_glyph_extents
 </SECTION>
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 18dabd9..f2d9280 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1271,6 +1271,21 @@ _cairo_gstate_get_font_face (cairo_gstat
     return CAIRO_STATUS_SUCCESS;
 }
 
+cairo_status_t
+_cairo_gstate_get_scaled_font (cairo_gstate_t       *gstate,
+			       cairo_scaled_font_t **scaled_font)
+{
+    cairo_status_t status;
+
+    status = _cairo_gstate_ensure_scaled_font (gstate);
+    if (status)
+	return status;
+
+    *scaled_font = gstate->scaled_font;
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
 /*
  * Like everything else in this file, fonts involve Too Many Coordinate Spaces;
  * it is easy to get confused about what's going on.
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 4020acf..c792a4f 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -71,7 +71,7 @@ _cairo_scaled_glyph_destroy (void *abstr
     free (scaled_glyph);
 }
 
-static const cairo_scaled_font_t _cairo_scaled_font_nil = {
+const cairo_scaled_font_t _cairo_scaled_font_nil = {
     { 0 },			/* hash_entry */
     CAIRO_STATUS_NO_MEMORY,	/* status */
     CAIRO_REF_COUNT_INVALID,	/* ref_count */
diff --git a/src/cairo.c b/src/cairo.c
index 08dfc0e..1999d4a 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2595,6 +2595,36 @@ BAIL:
 }
 
 /**
+ * cairo_get_scaled_font:
+ * @cr: a #cairo_t
+ *
+ * Gets the current font face for a #cairo_t.
+ *
+ * Return value: the current font object. Can return %NULL
+ *   on out-of-memory or if the context is already in
+ *   an error state. This object is owned by cairo. To keep
+ *   a reference to it, you must call cairo_font_face_reference().
+ *
+ * Since: 1.4
+ **/
+cairo_scaled_font_t *
+cairo_get_scaled_font (cairo_t *cr)
+{
+    cairo_scaled_font_t *scaled_font;
+
+    if (cr->status)
+	return (cairo_scaled_font_t *)&_cairo_scaled_font_nil;
+
+    cr->status = _cairo_gstate_get_scaled_font (cr->gstate, &scaled_font);
+    if (cr->status) {
+	_cairo_set_error (cr, cr->status);
+	return (cairo_scaled_font_t *)&_cairo_scaled_font_nil;
+    }
+
+    return scaled_font;
+}
+
+/**
  * cairo_text_extents:
  * @cr: a #cairo_t
  * @utf8: a string of text, encoded in UTF-8
diff --git a/src/cairo.h b/src/cairo.h
index ebe82c7..430dcfe 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -950,6 +950,9 @@ cairo_public void
 cairo_set_scaled_font (cairo_t                   *cr,
 		       const cairo_scaled_font_t *scaled_font);
 
+cairo_public cairo_scaled_font_t *
+cairo_get_scaled_font (cairo_t *cr);
+
 cairo_public void
 cairo_show_text (cairo_t *cr, const char *utf8);
 
diff --git a/src/cairoint.h b/src/cairoint.h
index eff8344..09d55ab 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1499,6 +1499,10 @@ _cairo_gstate_get_font_face (cairo_gstat
 			     cairo_font_face_t **font_face);
 
 cairo_private cairo_status_t
+_cairo_gstate_get_scaled_font (cairo_gstate_t       *gstate,
+			       cairo_scaled_font_t **scaled_font);
+
+cairo_private cairo_status_t
 _cairo_gstate_get_font_extents (cairo_gstate_t *gstate,
 				cairo_font_extents_t *extents);
 
@@ -1592,6 +1596,7 @@ _cairo_scaled_font_set_error (cairo_scal
 			      cairo_status_t status);
 
 extern const cairo_private cairo_font_face_t _cairo_font_face_nil;
+extern const cairo_private cairo_scaled_font_t _cairo_scaled_font_nil;
 
 cairo_private void
 _cairo_font_face_init (cairo_font_face_t               *font_face,
diff --git a/test/font-face-get-type.c b/test/font-face-get-type.c
index 86f5769..57cc859 100644
--- a/test/font-face-get-type.c
+++ b/test/font-face-get-type.c
@@ -31,6 +31,7 @@ main (void)
     cairo_surface_t *surface;
     cairo_t *cr;
     cairo_font_face_t *font_face;
+    cairo_scaled_font_t *scaled_font;
 
     cairo_test_init ("font-face-get-type");
 
@@ -43,16 +44,25 @@ main (void)
 			    CAIRO_FONT_SLANT_NORMAL,
 			    CAIRO_FONT_WEIGHT_NORMAL);
 
-    font_face = cairo_get_font_face (cr);
-
     cairo_test_log ("Testing return value of cairo_font_face_get_type\n");
 
+    font_face = cairo_get_font_face (cr);
+
     if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_TOY) {
 	cairo_test_log ("Unexpected value %d from cairo_font_face_get_type (expected %d)\n",
 			cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_TOY);
 	return CAIRO_TEST_FAILURE;
     }
 
+    cairo_test_log ("Testing return value of cairo_get_scaled_font\n");
+
+    scaled_font = cairo_get_scaled_font (cr);
+
+    if (cairo_scaled_font_get_font_face (scaled_font) != font_face) {
+	cairo_test_log ("Font face returned from the scaled font is different from that returned by the context\n");
+	return CAIRO_TEST_FAILURE;
+    }
+
     cairo_destroy (cr);
     cairo_surface_destroy (surface);
 
diff-tree d64b194a45d90b24d1cc01de0fa2cb4edc3a240b (from 65ab63cb8dc1da949dc831691cf1db5b6b92d749)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 27 20:03:26 2007 -0500

    [quartz] Remove comment syntax that is recognized by gtkdoc from regular comments

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 04710f1..cd35088 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -91,9 +91,9 @@ CG_EXTERN CGImageRef CGBitmapContextCrea
 #endif
 
 
-/**
- ** Utility functions
- **/
+/*
+ * Utility functions
+ */
 
 void nquartz_surface_to_png (cairo_nquartz_surface_t *nq, char *dest);
 void nquartz_image_to_png (CGImageRef, char *dest);
@@ -294,9 +294,9 @@ _cairo_nquartz_cairo_matrix_to_quartz (c
     dst->ty = src->y0;
 }
 
-/**
- ** Source -> Quartz setup and finish functions
- **/
+/*
+ * Source -> Quartz setup and finish functions
+ */
 
 static void
 ComputeGradientValue (void *info, const float *in, float *out)
@@ -736,9 +736,9 @@ _cairo_nquartz_teardown_source (cairo_nq
     }
 }
 
-/**
- ** get source/dest image implementation
- **/
+/*
+ * get source/dest image implementation
+ */
 
 static void
 ImageDataReleaseFunc(void *info, const void *data, size_t size)
@@ -828,9 +828,9 @@ _cairo_nquartz_get_image (cairo_nquartz_
     return CAIRO_STATUS_SUCCESS;
 }
 
-/**
- ** Cairo surface backend implementations
- **/
+/*
+ * Cairo surface backend implementations
+ */
 
 static cairo_status_t
 _cairo_nquartz_surface_finish (void *abstract_surface)
diff-tree 65ab63cb8dc1da949dc831691cf1db5b6b92d749 (from ed933a199c07997cf1dfb5ef2e345d754e2433f3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 27 19:45:10 2007 -0500

    [cairo.c] Reorder some function implementations for clarity

diff --git a/src/cairo.c b/src/cairo.c
index 36fd07b..08dfc0e 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2382,34 +2382,6 @@ cairo_select_font_face (cairo_t         
 }
 
 /**
- * cairo_get_font_face:
- * @cr: a #cairo_t
- *
- * Gets the current font face for a #cairo_t.
- *
- * Return value: the current font object. Can return %NULL
- *   on out-of-memory or if the context is already in
- *   an error state. This object is owned by cairo. To keep
- *   a reference to it, you must call cairo_font_face_reference().
- **/
-cairo_font_face_t *
-cairo_get_font_face (cairo_t *cr)
-{
-    cairo_font_face_t *font_face;
-
-    if (cr->status)
-	return (cairo_font_face_t*) &_cairo_font_face_nil;
-
-    cr->status = _cairo_gstate_get_font_face (cr->gstate, &font_face);
-    if (cr->status) {
-	_cairo_set_error (cr, cr->status);
-	return (cairo_font_face_t*) &_cairo_font_face_nil;
-    }
-
-    return font_face;
-}
-
-/**
  * cairo_font_extents:
  * @cr: a #cairo_t
  * @extents: a #cairo_font_extents_t object into which the results
@@ -2451,6 +2423,34 @@ cairo_set_font_face (cairo_t           *
 }
 
 /**
+ * cairo_get_font_face:
+ * @cr: a #cairo_t
+ *
+ * Gets the current font face for a #cairo_t.
+ *
+ * Return value: the current font object. Can return %NULL
+ *   on out-of-memory or if the context is already in
+ *   an error state. This object is owned by cairo. To keep
+ *   a reference to it, you must call cairo_font_face_reference().
+ **/
+cairo_font_face_t *
+cairo_get_font_face (cairo_t *cr)
+{
+    cairo_font_face_t *font_face;
+
+    if (cr->status)
+	return (cairo_font_face_t*) &_cairo_font_face_nil;
+
+    cr->status = _cairo_gstate_get_font_face (cr->gstate, &font_face);
+    if (cr->status) {
+	_cairo_set_error (cr, cr->status);
+	return (cairo_font_face_t*) &_cairo_font_face_nil;
+    }
+
+    return font_face;
+}
+
+/**
  * cairo_set_font_size:
  * @cr: a #cairo_t
  * @size: the new font size, in user space units
diff-tree ed933a199c07997cf1dfb5ef2e345d754e2433f3 (from 153465bfe5346b9e1ebdbd4f794bd11868ee7458)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Feb 27 19:43:18 2007 -0500

    [cairo.h] Reorder function prototypes a bit for clarity

diff --git a/src/cairo.h b/src/cairo.h
index ba5ead6..ebe82c7 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -941,6 +941,12 @@ cairo_get_font_options (cairo_t         
 			cairo_font_options_t *options);
 
 cairo_public void
+cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
+
+cairo_public cairo_font_face_t *
+cairo_get_font_face (cairo_t *cr);
+
+cairo_public void
 cairo_set_scaled_font (cairo_t                   *cr,
 		       const cairo_scaled_font_t *scaled_font);
 
@@ -950,15 +956,11 @@ cairo_show_text (cairo_t *cr, const char
 cairo_public void
 cairo_show_glyphs (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
 
-cairo_public cairo_font_face_t *
-cairo_get_font_face (cairo_t *cr);
-
 cairo_public void
-cairo_font_extents (cairo_t              *cr,
-		    cairo_font_extents_t *extents);
+cairo_text_path  (cairo_t *cr, const char *utf8);
 
 cairo_public void
-cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
+cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
 
 cairo_public void
 cairo_text_extents (cairo_t              *cr,
@@ -972,10 +974,8 @@ cairo_glyph_extents (cairo_t            
 		     cairo_text_extents_t  *extents);
 
 cairo_public void
-cairo_text_path  (cairo_t *cr, const char *utf8);
-
-cairo_public void
-cairo_glyph_path (cairo_t *cr, const cairo_glyph_t *glyphs, int num_glyphs);
+cairo_font_extents (cairo_t              *cr,
+		    cairo_font_extents_t *extents);
 
 /* Generic identifier for a font style */
 


More information about the cairo-commit mailing list