[cairo-commit] libsvg-cairo/src svg_cairo.c,1.40,1.41

Keith Packard commit at pdx.freedesktop.org
Tue Jul 19 09:57:19 PDT 2005


Committed by: keithp

Update of /cvs/cairo/libsvg-cairo/src
In directory gabe:/tmp/cvs-serv27675/src

Modified Files:
	svg_cairo.c 
Log Message:
2005-07-19  Keith Packard  <keithp at keithp.com>

	* src/svg_cairo.c: (_svg_cairo_get_text_anchor),
	(_svg_cairo_render_text):
	Kludge - pull text_anchor out of backend as it's stacked there.
	Ignore it in the backend as it's done already in libsvg.


Index: svg_cairo.c
===================================================================
RCS file: /cvs/cairo/libsvg-cairo/src/svg_cairo.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- svg_cairo.c	18 Jul 2005 21:55:59 -0000	1.40
+++ svg_cairo.c	19 Jul 2005 16:57:17 -0000	1.41
@@ -129,6 +129,9 @@
 _svg_cairo_set_text_anchor (void *closure, svg_text_anchor_t text_anchor);
 
 static svg_status_t
+_svg_cairo_get_text_anchor (void *closure, svg_text_anchor_t *text_anchor);
+
+static svg_status_t
 _svg_cairo_transform (void *closure,
 		      double a, double b,
 		      double c, double d,
@@ -256,6 +259,7 @@
     _svg_cairo_render_image,
     _svg_cairo_text_extents,
     _svg_cairo_measure_position,
+    _svg_cairo_get_text_anchor,
 };
 
 svg_cairo_status_t
@@ -1034,6 +1038,16 @@
 }
 
 static svg_status_t
+_svg_cairo_get_text_anchor (void *closure, svg_text_anchor_t *text_anchor)
+{
+    svg_cairo_t *svg_cairo = closure;
+
+    *text_anchor = svg_cairo->state->text_anchor;
+
+    return SVG_STATUS_SUCCESS;
+}
+
+static svg_status_t
 _svg_cairo_transform (void *closure,
 		  double a, double b,
 		  double c, double d,
@@ -1205,7 +1219,6 @@
     svg_cairo_t *svg_cairo = closure;
     svg_status_t status;
     svg_paint_t *fill_paint, *stroke_paint;
-    double rel_x = 0, rel_y = 0;
 #if HAVE_PANGOCAIRO
     PangoLayout *layout;
     PangoLayoutLine *line;
@@ -1230,33 +1243,6 @@
     _svg_cairo_select_font (svg_cairo);
 #endif
 
-    if (svg_cairo->state->text_anchor != SVG_TEXT_ANCHOR_START) {
-#if HAVE_PANGOCAIRO
-	PangoRectangle log;
-	pango_layout_get_extents (layout, NULL, &log);
-#else
-	cairo_text_extents_t extents;
-	cairo_text_extents (svg_cairo->cr, utf8, &extents);
-#endif
-
-	if (svg_cairo->state->text_anchor == SVG_TEXT_ANCHOR_END) {
-#if HAVE_PANGOCAIRO
-	    rel_x = -(double)log.width / PANGO_SCALE;    
-#else
-	    rel_x = -extents.x_advance;
-	    rel_y = -extents.y_advance;
-#endif
-	} else if (svg_cairo->state->text_anchor == SVG_TEXT_ANCHOR_MIDDLE) {
-#if HAVE_PANGOCAIRO
-	    rel_x = -((double)log.width / PANGO_SCALE) / 2.0;
-#else
-	    rel_x = -extents.x_advance / 2.0;
-	    rel_y = -extents.y_advance / 2.0;
-#endif
-	}
-    }
-    cairo_rel_move_to (svg_cairo->cr, rel_x, rel_y);
-
     if (fill_paint->type) {
 	if (stroke_paint->type)
 	    cairo_save (svg_cairo->cr);




More information about the cairo-commit mailing list