librsvg r1160 - trunk



Author: hans
Date: Fri Apr 25 14:27:44 2008
New Revision: 1160
URL: http://svn.gnome.org/viewvc/librsvg?rev=1160&view=rev

Log:
2008-04-25  Hans Breuer  <hans breuer org>

	* rsvg-css.c : use HAVE_STRINGS_H
	* rsvg-path.c : #include "rsvg-private.h" to get common definitions
	* rsvg-text.c : make the text rendering capability depend on what 
	cairo provides. If there is no CAIRO_HAS_FT_FONT try to use 
	CAIRO_HAS_WIN32_FONT. Makes librsvg buildable on windows without 
	freetype dependency, bug #529889


Modified:
   trunk/ChangeLog
   trunk/rsvg-css.c
   trunk/rsvg-path.c
   trunk/rsvg-text.c

Modified: trunk/rsvg-css.c
==============================================================================
--- trunk/rsvg-css.c	(original)
+++ trunk/rsvg-css.c	Fri Apr 25 14:27:44 2008
@@ -32,7 +32,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_STRINGS_H
 #include <strings.h>
+#endif
 #include <errno.h>
 #include <math.h>
 

Modified: trunk/rsvg-path.c
==============================================================================
--- trunk/rsvg-path.c	(original)
+++ trunk/rsvg-path.c	Fri Apr 25 14:27:44 2008
@@ -31,6 +31,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "rsvg-private.h"
+
 /* This module parses an SVG path element into an RsvgBpathDef.
 
    At present, there is no support for <marker> or any other contextual

Modified: trunk/rsvg-text.c
==============================================================================
--- trunk/rsvg-text.c	(original)
+++ trunk/rsvg-text.c	Fri Apr 25 14:27:44 2008
@@ -32,11 +32,19 @@
 
 #include "rsvg-shapes.h"
 
+/* what we use for text rendering depends on what cairo has to offer */
+#include <pango/pangocairo.h>
+
+#if defined CAIRO_HAS_FT_FONT
 #include <ft2build.h>
 #include FT_GLYPH_H
 #include FT_OUTLINE_H
 
 #include <pango/pangoft2.h>
+#else if defined (CAIRO_HAS_WIN32_FONT)
+/* nothing more needed? */
+#include <cairo-win32.h>
+#endif
 
 typedef struct _RsvgNodeText RsvgNodeText;
 
@@ -398,6 +406,7 @@
     gdouble offset_y;
 };
 
+#ifdef CAIRO_HAS_FT_FONT
 typedef void (*RsvgTextRenderFunc) (PangoFont * font,
                                     PangoGlyph glyph,
                                     FT_Int32 load_flags, gint x, gint y, gpointer render_data);
@@ -409,6 +418,7 @@
 #ifndef FT_LOAD_TARGET_MONO
 #define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME
 #endif
+#endif /* CAIRO_HAS_FT_FONT */
 
 static RenderCtx *
 rsvg_render_ctx_new (void)
@@ -428,6 +438,7 @@
     g_free (ctx);
 }
 
+#ifdef CAIRO_HAS_FT_FONT
 static void
 rsvg_text_ft2_subst_func (FcPattern * pattern, gpointer data)
 {
@@ -471,6 +482,28 @@
 
     return context;
 }
+#else
+/* although the #if condtionalizes on FT2 here we try to use pure cairo */
+typedef void (*RsvgTextRenderFunc) (PangoFont * font,
+                                    PangoGlyph glyph,
+                                    gint x, gint y, gpointer render_data);
+
+static PangoContext *
+rsvg_text_get_pango_context (RsvgDrawingCtx * ctx)
+{
+    PangoContext *context;
+    PangoCairoFontMap *fontmap;
+    
+    fontmap = PANGO_CAIRO_FONT_MAP (pango_cairo_font_map_new ());
+    if (ctx->dpi_x != ctx->dpi_y)
+	g_warning ("asymmetric dpi not handled");
+    pango_cairo_font_map_set_resolution (fontmap, ctx->dpi_x);
+    context = pango_cairo_font_map_create_context (fontmap);
+    g_object_unref (fontmap);
+    
+    return context;
+}
+#endif /* #ifdef CAIRO_HAS_FT_FONT */
 
 static void
 rsvg_text_layout_free (RsvgTextLayout * layout)
@@ -552,6 +585,7 @@
     return layout;
 }
 
+#ifdef CAIRO_HAS_FT_FONT
 static FT_Int32
 rsvg_text_layout_render_flags (RsvgTextLayout * layout)
 {
@@ -747,6 +781,39 @@
 
     FT_Done_Glyph (glyph);
 }
+#else 
+static gint
+rsvg_text_layout_render_glyphs (RsvgTextLayout * layout,
+                                PangoFont * font,
+                                PangoGlyphString * glyphs,
+                                RsvgTextRenderFunc render_func,
+                                gint x, gint y, gpointer render_data)
+{
+    PangoGlyphInfo *gi;
+    gint i;
+    gint x_position = 0;
+    gint pos_x, pos_y;
+    
+    for (i = 0, gi = glyphs->glyphs; i < glyphs->num_glyphs; i++, gi++) {
+        if (gi->glyph) {
+            pos_x = x + x_position + gi->geometry.x_offset;
+            pos_y = y + gi->geometry.y_offset;
+
+            render_func (font, gi->glyph, pos_x, pos_y, render_data);
+        }
+
+        x_position += glyphs->glyphs[i].geometry.width;
+    }
+
+    return x_position;
+}
+
+static void
+rsvg_text_render_vectors (PangoFont * font,
+                          PangoGlyph pango_glyph, gint x, gint y, gpointer ud)
+{
+}
+#endif /* CAIRO_HAS_FT_FONT */
 
 static void
 rsvg_text_layout_render_line (RsvgTextLayout * layout,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]