[cairo-commit] cairo/src cairo-font.c, 1.41, 1.42 cairo-gstate.c,
1.105, 1.106 cairo.c, 1.73, 1.74 cairo.h, 1.93,
1.94 cairoint.h, 1.121, 1.122
Owen Taylor
commit at pdx.freedesktop.org
Thu Apr 7 13:29:34 PDT 2005
Committed by: otaylor
Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv22152/src
Modified Files:
cairo-font.c cairo-gstate.c cairo.c cairo.h cairoint.h
Log Message:
2005-04-07 Owen Taylor <otaylor at redhat.com>
* src/cairo.[ch] src/cairoint.h src/cairo-gstate.c
docs/public/cairo-sections.txt:
cairo_select_font() => cairo_select_font_face()
cairo_scale_font() => cairo_set_font_size()
cairo_transform_font() => cairo_set_font_matrix()
Add cairo_get_font_matrix(). Make cairo_set_font_face()
not reset the font matrix. Default the font matrix
to SCALE(10). Document cairo_select_font_face().
* test/coverage.c (draw) test/text-cache-crash.c (draw)
test/text-rotate.c (draw): Use cairo_set_font_size().
* src/cairo-font.c src/cairo.h: Fix up some parameter
names for docs.
Index: cairo-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-font.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- cairo-font.c 7 Apr 2005 18:04:00 -0000 1.41
+++ cairo-font.c 7 Apr 2005 20:29:32 -0000 1.42
@@ -636,7 +636,7 @@
* font. In the simplest case of a N point font, this matrix is
* just a scale by N, but it can also be used to shear the font
* or stretch it unequally along the two axes. See
- * cairo_transform_font().
+ * cairo_set_font_matrix().
* @ctm: user to device transformation matrix with which the font will
* be used.
*
@@ -821,7 +821,7 @@
/**
* cairo_scaled_font_destroy:
- * @font: a #cairo_scaled_font_t
+ * @scaled_font: a #cairo_scaled_font_t
*
* Decreases the reference count on @font by one. If the result
* is zero, then @font and all associated resources are freed.
@@ -856,7 +856,7 @@
/**
* cairo_scaled_font_extents:
- * @font: a #cairo_scaled_font_t
+ * @scaled_font: a #cairo_scaled_font_t
* @extents: a #cairo_font_extents_t which to store the retrieved extents.
*
* Gets the metrics for a #cairo_scaled_font_t.
@@ -896,7 +896,7 @@
/**
* cairo_font_glyph_extents:
- * @font: a #cairo_scaled_font_t
+ * @scaled_font: a #cairo_scaled_font_t
* @glyphs: an array of glyph IDs with X and Y offsets.
* @num_glyphs: the number of glyphs in the @glyphs array
* @extents: a #cairo_text_extents_t which to store the retrieved extents.
Index: cairo-gstate.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-gstate.c,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- cairo-gstate.c 7 Apr 2005 19:56:43 -0000 1.105
+++ cairo-gstate.c 7 Apr 2005 20:29:32 -0000 1.106
@@ -97,6 +97,10 @@
gstate->scaled_font = NULL;
gstate->font_face = NULL;
+ cairo_matrix_init_scale (&gstate->font_matrix,
+ CAIRO_GSTATE_DEFAULT_FONT_SIZE,
+ CAIRO_GSTATE_DEFAULT_FONT_SIZE);
+
gstate->surface = NULL;
gstate->clip.region = NULL;
@@ -2118,10 +2122,10 @@
}
cairo_status_t
-_cairo_gstate_select_font (cairo_gstate_t *gstate,
- const char *family,
- cairo_font_slant_t slant,
- cairo_font_weight_t weight)
+_cairo_gstate_select_font_face (cairo_gstate_t *gstate,
+ const char *family,
+ cairo_font_slant_t slant,
+ cairo_font_weight_t weight)
{
cairo_font_face_t *font_face;
@@ -2136,32 +2140,32 @@
}
cairo_status_t
-_cairo_gstate_scale_font (cairo_gstate_t *gstate,
- double scale)
+_cairo_gstate_set_font_size (cairo_gstate_t *gstate,
+ double size)
{
_cairo_gstate_unset_font (gstate);
- cairo_matrix_scale (&gstate->font_matrix, scale, scale);
+ cairo_matrix_init_scale (&gstate->font_matrix, size, size);
return CAIRO_STATUS_SUCCESS;
}
cairo_status_t
-_cairo_gstate_transform_font (cairo_gstate_t *gstate,
- cairo_matrix_t *matrix)
+_cairo_gstate_set_font_matrix (cairo_gstate_t *gstate,
+ cairo_matrix_t *matrix)
{
- cairo_matrix_t tmp;
- double a, b, c, d, tx, ty;
-
_cairo_gstate_unset_font (gstate);
- cairo_matrix_get_affine (matrix, &a, &b, &c, &d, &tx, &ty);
- cairo_matrix_init (&tmp, a, b, c, d, 0, 0);
- cairo_matrix_multiply (&gstate->font_matrix, &gstate->font_matrix, &tmp);
+ gstate->font_matrix = *matrix;
return CAIRO_STATUS_SUCCESS;
}
+cairo_matrix_t
+_cairo_gstate_get_font_matrix (cairo_gstate_t *gstate)
+{
+ return gstate->font_matrix;
+}
cairo_status_t
_cairo_gstate_get_font_face (cairo_gstate_t *gstate,
@@ -2178,22 +2182,6 @@
return CAIRO_STATUS_SUCCESS;
}
-void
-_cairo_gstate_set_font_transform (cairo_gstate_t *gstate,
- cairo_matrix_t *matrix)
-{
- _cairo_gstate_unset_font (gstate);
-
- cairo_matrix_copy (&gstate->font_matrix, matrix);
-}
-
-void
-_cairo_gstate_get_font_transform (cairo_gstate_t *gstate,
- cairo_matrix_t *matrix)
-{
- cairo_matrix_copy (matrix, &gstate->font_matrix);
-}
-
/*
* Like everything else in this file, fonts involve Too Many Coordinate Spaces;
* it is easy to get confused about what's going on.
Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- cairo.c 7 Apr 2005 18:04:00 -0000 1.73
+++ cairo.c 7 Apr 2005 20:29:32 -0000 1.74
@@ -1516,17 +1516,32 @@
}
DEPRECATE (cairo_init_clip, cairo_reset_clip);
+/**
+ * cairo_select_font_face:
+ * @cr: a #cairo_t
+ * @family: a font family name, encoded in UTF-8
+ * @slant: the slant for the font
+ * @weight: the weight for the font
+ *
+ * Selects a family and style of font from a simplified description as
+ * a family name, slant and weight. This function is meant to be used
+ * only for applications with simple font needs: Cairo doesn't provide
+ * for operations such as listing all available fonts on the system,
+ * and it is expected that most applications will need to use a more
+ * comprehensive font handling and text layout library in addition to
+ * Cairo.
+ **/
void
-cairo_select_font (cairo_t *cr,
- const char *family,
- cairo_font_slant_t slant,
- cairo_font_weight_t weight)
+cairo_select_font_face (cairo_t *cr,
+ const char *family,
+ cairo_font_slant_t slant,
+ cairo_font_weight_t weight)
{
CAIRO_CHECK_SANITY (cr);
if (cr->status)
return;
- cr->status = _cairo_gstate_select_font (cr->gstate, family, slant, weight);
+ cr->status = _cairo_gstate_select_font_face (cr->gstate, family, slant, weight);
CAIRO_CHECK_SANITY (cr);
}
@@ -1599,46 +1614,64 @@
}
/**
- * cairo_scale_font:
+ * cairo_set_font_size:
* @cr: a #cairo_t
- * @scale: a scale factor
+ * @size: the new font size, in user space units
*
- * Scale the current font by the factor @scale. This function is
- * designed to work well with cairo_select_font(), and will usually be
- * called immediately afterwards to set the desired font size.
+ * Sets the current font matrix to a scale by a factor of @size, replacing
+ * any font matrix previously set with cairo_set_font_size() or
+ * cairo_set_font_matrix(). This results in a font size of @size user space
+ * units. (More precisely, this matrix will result in the font's
+ * em-square being a @size by @size square in user space.)
**/
void
-cairo_scale_font (cairo_t *cr, double scale)
+cairo_set_font_size (cairo_t *cr, double size)
{
CAIRO_CHECK_SANITY (cr);
if (cr->status)
return;
- cr->status = _cairo_gstate_scale_font (cr->gstate, scale);
+ cr->status = _cairo_gstate_set_font_size (cr->gstate, size);
CAIRO_CHECK_SANITY (cr);
}
/**
- * cairo_transform_font:
+ * cairo_set_font_matrix
* @cr: a #cairo_t
* @matrix: a #cairo_matrix_t describing a transform to be applied to
* the current font.
- *
- * Transform the current font according to @matrix. The transformation
- * is applied in addition to any previous transformations applied by
- * either cairo_transform_font() or cairo_scale_font().
*
- * This function is designed to work well with cairo_select_font().
+ * Sets the current font matrix to @matrix. The font matrix gives a
+ * transformation from the design space of the font (in this space,
+ * the em-square is 1 unit by 1 unit) to user space. Normally, a
+ * simple scale is used (see cairo_set_font_size()), but a more
+ * complex font matrix can be used to shear the font
+ * or stretch it unequally along the two axes
**/
void
-cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix)
+cairo_set_font_matrix (cairo_t *cr, cairo_matrix_t *matrix)
{
CAIRO_CHECK_SANITY (cr);
if (cr->status)
return;
- cr->status = _cairo_gstate_transform_font (cr->gstate, matrix);
+ cr->status = _cairo_gstate_set_font_matrix (cr->gstate, matrix);
+ CAIRO_CHECK_SANITY (cr);
+}
+
+/**
+ * cairo_get_font_matrix
+ * @cr: a #cairo_t
+ *
+ * Gets the current font matrix. See cairo_set_font_matrix()
+ *
+ * Return value: the current font matrix
+ **/
+cairo_matrix_t
+cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix)
+{
CAIRO_CHECK_SANITY (cr);
+ return _cairo_gstate_get_font_matrix (cr->gstate);
}
/**
Index: cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- cairo.h 7 Apr 2005 18:04:00 -0000 1.93
+++ cairo.h 7 Apr 2005 20:29:32 -0000 1.94
@@ -566,16 +566,20 @@
font object inside the the cairo_t. */
void
-cairo_select_font (cairo_t *cr,
- const char *family,
- cairo_font_slant_t slant,
- cairo_font_weight_t weight);
+cairo_select_font_face (cairo_t *cr,
+ const char *family,
+ cairo_font_slant_t slant,
+ cairo_font_weight_t weight);
void
-cairo_scale_font (cairo_t *cr, double scale);
+cairo_set_font_size (cairo_t *cr, double size);
void
-cairo_transform_font (cairo_t *cr, cairo_matrix_t *matrix);
+cairo_set_font_matrix (cairo_t *cr,
+ cairo_matrix_t *matrix);
+
+cairo_matrix_t
+cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix);
void
cairo_show_text (cairo_t *cr, const char *utf8);
@@ -627,17 +631,17 @@
cairo_matrix_t *ctm);
void
-cairo_scaled_font_reference (cairo_scaled_font_t *font);
+cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font);
void
-cairo_scaled_font_destroy (cairo_scaled_font_t *font);
+cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font);
cairo_status_t
-cairo_scaled_font_extents (cairo_scaled_font_t *font,
+cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font,
cairo_font_extents_t *extents);
void
-cairo_scaled_font_glyph_extents (cairo_scaled_font_t *font,
+cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font,
cairo_glyph_t *glyphs,
int num_glyphs,
cairo_text_extents_t *extents);
@@ -1108,6 +1112,9 @@
#define cairo_get_status cairo_get_status_DEPRECATED_BY_cairo_status
#define cairo_get_status_string cairo_get_status_string_DEPRECATED_BY_cairo_status_string
#define cairo_concat_matrix cairo_concat_matrix_DEPRECATED_BY_cairo_transform
+#define cairo_scale_font cairo_scale_font_DEPRECATED_BY_cairo_set_font_size
+#define cairo_select_font cairo_select_font_face_DEPRECATED_BY_cairo_select_font_face
+#define cairo_transform_font cairo_transform_font_DEPRECATED_BY_cairo_set_font_matrix
#define cairo_transform_point cairo_transform_point_DEPRECATED_BY_cairo_user_to_device
#define cairo_transform_distance cairo_transform_distance_DEPRECATED_BY_cairo_user_to_device_distance
#define cairo_inverse_transform_point cairo_inverse_transform_point_DEPRECATED_BY_cairo_device_to_user
@@ -1124,7 +1131,6 @@
#define cairo_current_path_flat cairo_get_path_flat
#define cairo_current_font cairo_get_font
#define cairo_current_font_extents cairo_font_extents
-#define cairo_get_font_extents cairo_font_extents
#define cairo_current_operator cairo_get_operator
#define cairo_current_rgb_color cairo_get_rgb_color
#define cairo_current_alpha cairo_get_alpha
@@ -1136,6 +1142,7 @@
#define cairo_current_line_join cairo_get_line_join
#define cairo_current_miter_limit cairo_get_miter_limit
#define cairo_current_target_surface cairo_get_target_surface
+#define cairo_get_font_extents cairo_font_extents
#define cairo_get_status cairo_status
#define cairo_get_status_string cairo_status_string
#define cairo_concat_matrix cairo_transform
@@ -1144,7 +1151,10 @@
#define cairo_inverse_transform_point cairo_device_to_user
#define cairo_inverse_transform_distance cairo_device_to_user_distance
#define cairo_init_clip cairo_reset_clip
+#define cairo_scale_font cairo_set_font_size
+#define cairo_select_font cairo_select_font_face
#define cairo_surface_create_for_image cairo_image_surface_create_for_data
+#define cairo_transform_font cairo_set_font_matrix
#define cairo_default_matrix cairo_identity_matrix
#define cairo_matrix_set_affine cairo_matrix_init
#define cairo_matrix_set_identity cairo_matrix_init_identity
Index: cairoint.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairoint.h,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- cairoint.h 7 Apr 2005 19:56:43 -0000 1.121
+++ cairoint.h 7 Apr 2005 20:29:32 -0000 1.122
@@ -818,6 +818,7 @@
#define CAIRO_GSTATE_LINE_CAP_DEFAULT CAIRO_LINE_CAP_BUTT
#define CAIRO_GSTATE_LINE_JOIN_DEFAULT CAIRO_LINE_JOIN_MITER
#define CAIRO_GSTATE_MITER_LIMIT_DEFAULT 10.0
+#define CAIRO_GSTATE_DEFAULT_FONT_SIZE 10.0
/* Need a name distinct from the cairo_clip function */
typedef struct _cairo_clip_rec {
@@ -1111,34 +1112,29 @@
int height);
cairo_private cairo_status_t
-_cairo_gstate_select_font (cairo_gstate_t *gstate,
- const char *family,
- cairo_font_slant_t slant,
- cairo_font_weight_t weight);
+_cairo_gstate_select_font_face (cairo_gstate_t *gstate,
+ const char *family,
+ cairo_font_slant_t slant,
+ cairo_font_weight_t weight);
cairo_private cairo_status_t
-_cairo_gstate_scale_font (cairo_gstate_t *gstate,
- double scale);
+_cairo_gstate_set_font_size (cairo_gstate_t *gstate,
+ double size);
+cairo_matrix_t
+_cairo_gstate_get_font_matrix (cairo_gstate_t *gstate);
+
cairo_private cairo_status_t
-_cairo_gstate_transform_font (cairo_gstate_t *gstate,
- cairo_matrix_t *matrix);
+_cairo_gstate_set_font_matrix (cairo_gstate_t *gstate,
+ cairo_matrix_t *matrix);
cairo_private cairo_status_t
_cairo_gstate_get_font_face (cairo_gstate_t *gstate,
cairo_font_face_t **font_face);
-cairo_private void
-_cairo_gstate_set_font_transform (cairo_gstate_t *gstate,
- cairo_matrix_t *matrix);
-
-cairo_private void
-_cairo_gstate_get_font_transform (cairo_gstate_t *gstate,
- cairo_matrix_t *matrix);
-
cairo_private cairo_status_t
_cairo_gstate_get_font_extents (cairo_gstate_t *gstate,
- cairo_font_extents_t *extents);
+ cairo_font_extents_t *extents);
cairo_private cairo_status_t
_cairo_gstate_set_font_face (cairo_gstate_t *gstate,
More information about the cairo-commit
mailing list