[cairo-commit] 2 commits - src/cairo-ft-font.c src/cairo-ps-surface.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Aug 15 05:33:36 PDT 2006


 src/cairo-ft-font.c    |   27 +++++++++++++++++----------
 src/cairo-ps-surface.c |   12 ++++++------
 2 files changed, 23 insertions(+), 16 deletions(-)

New commits:
diff-tree b7bc263842a798d657a95e539e1693372448837f (from d47388ad759b0a1a0869655a87d9b5eb6ae2445d)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Aug 15 08:33:20 2006 -0400

    [FreeType] Fix vertical metrics adjustment to work with non-identity shapes

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index e07a59f..4eb4ca7 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -98,6 +98,7 @@ struct _cairo_ft_unscaled_font {
     double y_scale;             /* Extracted Y scale factor */
     cairo_bool_t have_shape;	/* true if the current scale has a non-scale component*/
     cairo_matrix_t current_shape;
+    FT_Matrix Current_Shape;
 
     int lock;		/* count of how many times this font has been locked */
 
@@ -632,6 +633,7 @@ _cairo_ft_unscaled_font_set_scale (cairo
 			    mat.xy != 0x00000 ||
 			    mat.yy != 0x10000);
 
+    unscaled->Current_Shape = mat;
     cairo_matrix_init (&unscaled->current_shape,
 		       sf.shape[0][0], sf.shape[0][1],
 		       sf.shape[1][0], sf.shape[1][1],
@@ -1733,16 +1735,21 @@ _decompose_glyph_outline (FT_Face		  fac
  * Translate glyph to match its metrics.
  */
 static void
-_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (FT_GlyphSlot glyph)
+_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (void        *abstract_font,
+						    FT_GlyphSlot glyph)
 {
-    FT_Pos x = glyph->metrics.vertBearingX - glyph->metrics.horiBearingX;
-    FT_Pos y = -glyph->metrics.vertBearingY - glyph->metrics.horiBearingY;
+    cairo_ft_scaled_font_t *scaled_font = abstract_font;
+    FT_Vector vector;
+
+    vector.x = glyph->metrics.vertBearingX - glyph->metrics.horiBearingX;
+    vector.y = -glyph->metrics.vertBearingY - glyph->metrics.horiBearingY;
 
-    if (glyph->format == FT_GLYPH_FORMAT_OUTLINE)
-	FT_Outline_Translate(&glyph->outline, x, y);
-    else if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
-	glyph->bitmap_left += x / 64;
-	glyph->bitmap_top  += y / 64;
+    if (glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
+	FT_Vector_Transform (&vector, &scaled_font->unscaled->Current_Shape);
+	FT_Outline_Translate(&glyph->outline, vector.x, vector.y);
+    } else if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
+	glyph->bitmap_left += vector.x / 64;
+	glyph->bitmap_top  += vector.y / 64;
     }
 }
 
@@ -1803,7 +1810,7 @@ _cairo_ft_scaled_glyph_init (void			*abs
 #endif
 
     if (vertical_layout)
-	_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (glyph);
+	_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (scaled_font, glyph);
 
     if (info & CAIRO_SCALED_GLYPH_INFO_METRICS) {
 	/*
@@ -1940,7 +1947,7 @@ _cairo_ft_scaled_glyph_init (void			*abs
 		FT_GlyphSlot_Embolden (glyph);
 #endif
 	    if (vertical_layout)
-		_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (glyph);
+		_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (scaled_font, glyph);
 
 	}
 	if (glyph->format == FT_GLYPH_FORMAT_OUTLINE)
diff-tree d47388ad759b0a1a0869655a87d9b5eb6ae2445d (from 91eb56998c416cc21a1bbe2a6e66e85316ef4ddb)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Aug 15 07:29:18 2006 -0400

    [PS] Set correct ImageMatrix in _cairo_ps_surface_emit_bitmap_glyph_data
    which should be set to device_transform_inverse, not device_transform.
    Moreover, no negation is needed anymore, as that has been working around
    the inverse matrix :-).

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 10c9e6a..e809064 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -566,12 +566,12 @@ _cairo_ps_surface_emit_bitmap_glyph_data
 				 "   /BitsPerComponent 1\n",
 				 image->width,
 				 image->height,
-				 image->base.device_transform.xx,
-				 image->base.device_transform.yx,
-				 image->base.device_transform.xy,
-				 image->base.device_transform.yy,
-				 image->base.device_transform.x0,
-				 - image->base.device_transform.y0);
+				 image->base.device_transform_inverse.xx,
+				 image->base.device_transform_inverse.yx,
+				 image->base.device_transform_inverse.xy,
+				 image->base.device_transform_inverse.yy,
+				 image->base.device_transform_inverse.x0,
+				 image->base.device_transform_inverse.y0);
 
     _cairo_output_stream_printf (surface->final_stream,
 				 "   /DataSource   {<");


More information about the cairo-commit mailing list