[cairo-commit] src/cairo-ft-font.c src/cairoint.h src/cairo-matrix.c src/cairo-quartz-font.c src/cairo-scaled-font.c src/cairo-user-font.c src/cairo-win32-font.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Aug 27 17:09:15 PDT 2008


 src/cairo-ft-font.c     |    2 +-
 src/cairo-matrix.c      |   33 +++++++++++++++++++++++----------
 src/cairo-quartz-font.c |    6 +++---
 src/cairo-scaled-font.c |    2 +-
 src/cairo-user-font.c   |    2 +-
 src/cairo-win32-font.c  |    2 +-
 src/cairoint.h          |    2 +-
 7 files changed, 31 insertions(+), 18 deletions(-)

New commits:
commit 22552dae517c25e4eadd44e76d06469a4c95db93
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 27 20:08:49 2008 -0400

    Rename _cairo_matrix_compute_scale_factors to _cairo_matrix_compute_basis_scale_factors

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 8d5c2fd..99d5a1e 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -642,7 +642,7 @@ _compute_transform (cairo_ft_font_transform_t *sf,
      * freetype's transformation.
      */
 
-    status = _cairo_matrix_compute_scale_factors (scale,
+    status = _cairo_matrix_compute_basis_scale_factors (scale,
 						  &x_scale, &y_scale,
 						  1);
     if (status)
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
index 7676c50..9277e7c 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -524,10 +524,23 @@ _cairo_matrix_compute_determinant (const cairo_matrix_t *matrix)
     return a*d - b*c;
 }
 
-/* Compute the amount that each basis vector is scaled by. */
+/**
+ * _cairo_matrix_compute_basis_scale_factors:
+ * @matrix: a matrix
+ * @basis_scale: the scale factor in the direction of basis
+ * @normal_scale: the scale factor in the direction normal to the basis
+ * @x_basis: basis to use.  X basis if true, Y basis otherwise.
+ *
+ * Computes |Mv| and det(M)/|Mv| for v=[1,0] if x_basis is true, and v=[0,1]
+ * otherwise, and M is @matrix.
+ *
+ * Return value: the scale factor of @matrix on the height of the font,
+ * or 1.0 if @matrix is %NULL.
+ **/
 cairo_status_t
-_cairo_matrix_compute_scale_factors (const cairo_matrix_t *matrix,
-				     double *sx, double *sy, int x_major)
+_cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix,
+					   double *basis_scale, double *normal_scale,
+					   cairo_bool_t x_basis)
 {
     double det;
 
@@ -538,11 +551,11 @@ _cairo_matrix_compute_scale_factors (const cairo_matrix_t *matrix,
 
     if (det == 0)
     {
-	*sx = *sy = 0;
+	*basis_scale = *normal_scale = 0;
     }
     else
     {
-	double x = x_major != 0;
+	double x = x_basis != 0;
 	double y = x == 0;
 	double major, minor;
 
@@ -557,15 +570,15 @@ _cairo_matrix_compute_scale_factors (const cairo_matrix_t *matrix,
 	    minor = det / major;
 	else
 	    minor = 0.0;
-	if (x_major)
+	if (x_basis)
 	{
-	    *sx = major;
-	    *sy = minor;
+	    *basis_scale = major;
+	    *normal_scale = minor;
 	}
 	else
 	{
-	    *sx = minor;
-	    *sy = major;
+	    *basis_scale = minor;
+	    *normal_scale = major;
 	}
     }
 
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index c4df88a..c689800 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -390,7 +390,7 @@ _cairo_matrix_to_unit_quartz_matrix (const cairo_matrix_t *m, CGAffineTransform
     double xscale, yscale;
     cairo_status_t status;
 
-    status = _cairo_matrix_compute_scale_factors (m, &xscale, &yscale, 1);
+    status = _cairo_matrix_compute_basis_scale_factors (m, &xscale, &yscale, 1);
     if (status)
 	return status;
 
@@ -435,7 +435,7 @@ _cairo_quartz_init_glyph_metrics (cairo_quartz_scaled_font_t *font,
 	!CGFontGetGlyphBBoxesPtr (font_face->cgFont, &glyph, 1, &bbox))
 	goto FAIL;
 
-    status = _cairo_matrix_compute_scale_factors (&font->base.scale,
+    status = _cairo_matrix_compute_basis_scale_factors (&font->base.scale,
 						  &xscale, &yscale, 1);
     if (status)
 	goto FAIL;
@@ -632,7 +632,7 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font,
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
-    status = _cairo_matrix_compute_scale_factors (&font->base.scale,
+    status = _cairo_matrix_compute_basis_scale_factors (&font->base.scale,
 						  &xscale, &yscale, 1);
     if (status)
 	return status;
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 0adadfc..73d1eb4 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -681,7 +681,7 @@ _cairo_scaled_font_set_metrics (cairo_scaled_font_t	    *scaled_font,
     cairo_status_t status;
     double  font_scale_x, font_scale_y;
 
-    status = _cairo_matrix_compute_scale_factors (&scaled_font->font_matrix,
+    status = _cairo_matrix_compute_basis_scale_factors (&scaled_font->font_matrix,
 						  &font_scale_x, &font_scale_y,
 						  1);
     if (status)
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index 1949269..ebac53b 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -367,7 +367,7 @@ _cairo_user_font_face_scaled_font_create (void                        *abstract_
 	double fixed_scale, x_scale, y_scale;
 
 	user_scaled_font->extent_scale = user_scaled_font->base.scale_inverse;
-	status = _cairo_matrix_compute_scale_factors (&user_scaled_font->extent_scale,
+	status = _cairo_matrix_compute_basis_scale_factors (&user_scaled_font->extent_scale,
 						      &x_scale, &y_scale,
 						      1);
 	if (status == CAIRO_STATUS_SUCCESS) {
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 6d7485b..f82d528 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -197,7 +197,7 @@ _compute_transform (cairo_win32_scaled_font_t *scaled_font,
 		       sc->xx, sc->yx, sc->xy, sc->yy, 0, 0);
 
     if (!scaled_font->preserve_axes) {
-	status = _cairo_matrix_compute_scale_factors (&scaled_font->logical_to_device,
+	status = _cairo_matrix_compute_basis_scale_factors (&scaled_font->logical_to_device,
 						      &scaled_font->x_scale, &scaled_font->y_scale,
 						      TRUE);	/* XXX: Handle vertical text */
 	if (status)
diff --git a/src/cairoint.h b/src/cairoint.h
index 4b90353..d5515a4 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2137,7 +2137,7 @@ cairo_private double
 _cairo_matrix_compute_determinant (const cairo_matrix_t *matrix);
 
 cairo_private cairo_status_t
-_cairo_matrix_compute_scale_factors (const cairo_matrix_t *matrix,
+_cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix,
 				     double *sx, double *sy, int x_major);
 
 cairo_private cairo_bool_t


More information about the cairo-commit mailing list