[cairo-commit] src/cairo-svg-surface.c

Emmanuel Pacaud emmanuel at kemper.freedesktop.org
Fri Jun 23 11:16:40 PDT 2006


 src/cairo-svg-surface.c |   55 ++++++++++++++++++++----------------------------
 1 files changed, 23 insertions(+), 32 deletions(-)

New commits:
diff-tree 3a313070e5b5a1168225dec008f63ff68ed20559 (from 8b6fcaf8ff17786ab5394a4aa2d6289f5d9601c2)
Author: Emmanuel Pacaud <emmanuel.pacaud at free.fr>
Date:   Fri Jun 23 20:13:58 2006 +0200

    SVG: fix bit order for bitmap font data and use a group with matrix
    
    transformation instead of applying the same matrix on each rect
    coordinates.

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 71ce573..aa26730 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -403,6 +403,21 @@ _cairo_svg_surface_create_for_stream_int
     return surface;
 }
 
+static void
+emit_transform (cairo_output_stream_t *output,
+		char const *attribute_str,
+		char const *trailer,
+		cairo_matrix_t *matrix)
+{
+    _cairo_output_stream_printf (output,
+				 "%s=\"matrix(%f,%f,%f,%f,%f,%f)\"%s",
+				 attribute_str,
+				 matrix->xx, matrix->yx,
+				 matrix->xy, matrix->yy,
+				 matrix->x0, matrix->y0,
+				 trailer);
+}
+
 typedef struct
 {
     cairo_output_stream_t *output;
@@ -536,10 +551,7 @@ _cairo_svg_document_emit_bitmap_glyph_da
     cairo_image_surface_t *image;
     cairo_scaled_glyph_t *scaled_glyph;
     cairo_status_t status;
-    cairo_matrix_t *matrix;
     unsigned char *row, *byte;
-    double pixel_height, pixel_width;
-    double pixel_x, pixel_y;
     int rows, cols, bytes_per_row;
     int x, y, bit;
 
@@ -554,29 +566,23 @@ _cairo_svg_document_emit_bitmap_glyph_da
     image = scaled_glyph->surface;
     assert (image->format == CAIRO_FORMAT_A1);
 
-    matrix = &image->base.device_transform;
-    pixel_height = 1;
-    pixel_width = 1;
-    cairo_matrix_transform_distance (matrix, &pixel_width, &pixel_height);
+    _cairo_output_stream_printf (document->xml_node_glyphs, "<g");
+    emit_transform (document->xml_node_glyphs, " transform", ">/n", &image->base.device_transform);
 
     bytes_per_row = (image->width + 7) / 8;
     for (y = 0, row = image->data, rows = image->height; rows; row += image->stride, rows--, y++) {
 	for (x = 0, byte = row, cols = (image->width + 7) / 8; cols; byte++, cols--) {
-	    unsigned char output_byte = *byte;
-	    for (bit = 0; bit < 8 && x < image->width; bit++, x++) {
-		if (output_byte & 1) {
-		    pixel_x = x;
-		    pixel_y = y;
-		    cairo_matrix_transform_point (matrix, &pixel_x, &pixel_y);
+	    unsigned char output_byte = CAIRO_BITSWAP8_IF_LITTLE_ENDIAN (*byte);
+	    for (bit = 7; bit >= 0 && x < image->width; bit--, x++) {
+		if (output_byte & (1 << bit)) {
 		    _cairo_output_stream_printf (document->xml_node_glyphs,
-						 "<rect x=\"%f\" y=\"%f\" width=\"%f\" height=\"%f\"/>\n",
-						 pixel_x, pixel_y, pixel_width, pixel_height);
+						 "<rect x=\"%d\" y=\"%d\" width=\"1\" height=\"1\"/>\n",
+						 x, y);
 		}
-		output_byte = output_byte >> 1;
 	    }
 	}
     }
-
+    _cairo_output_stream_printf (document->xml_node_glyphs, "</g>\n");
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -725,21 +731,6 @@ emit_alpha_filter (cairo_svg_document_t 
     document->alpha_filter = TRUE;
 }
 
-static void
-emit_transform (cairo_output_stream_t *output,
-		char const *attribute_str,
-		char const *trailer,
-		cairo_matrix_t *matrix)
-{
-    _cairo_output_stream_printf (output,
- 				 "%s=\"matrix(%f,%f,%f,%f,%f,%f)\"%s",
- 				 attribute_str,
- 				 matrix->xx, matrix->yx,
- 				 matrix->xy, matrix->yy,
- 				 matrix->x0, matrix->y0,
- 				 trailer);
-}
-
 typedef struct {
     cairo_output_stream_t *output;
     unsigned int in_mem;


More information about the cairo-commit mailing list