summaryrefslogtreecommitdiff
path: root/rsvg-text.c
diff options
context:
space:
mode:
authorHans Breuer <hans@breuer.org>2008-04-25 14:27:44 +0000
committerHans Breuer <hans@src.gnome.org>2008-04-25 14:27:44 +0000
commit4999aab0cc7c29423ea7935001e5c7edce003559 (patch)
treec5788f9ceb8a501f855332b822de7446f5791ecd /rsvg-text.c
parenteab26f6f761aaef363e332cff48c7a908020a62e (diff)
downloadlibrsvg-4999aab0cc7c29423ea7935001e5c7edce003559.tar.gz
use HAVE_STRINGS_H #include "rsvg-private.h" to get common definitions
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 svn path=/trunk/; revision=1160
Diffstat (limited to 'rsvg-text.c')
-rw-r--r--rsvg-text.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/rsvg-text.c b/rsvg-text.c
index fc1da72c..f9ddfd53 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -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 @@ struct _RenderCtx {
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 @@ typedef void (*RsvgTextRenderFunc) (PangoFont * font,
#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 @@ rsvg_render_ctx_free (RenderCtx * ctx)
g_free (ctx);
}
+#ifdef CAIRO_HAS_FT_FONT
static void
rsvg_text_ft2_subst_func (FcPattern * pattern, gpointer data)
{
@@ -471,6 +482,28 @@ rsvg_text_get_pango_context (RsvgDrawingCtx * ctx)
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 @@ rsvg_text_layout_new (RsvgDrawingCtx * ctx, RsvgState * state, const char *text)
return layout;
}
+#ifdef CAIRO_HAS_FT_FONT
static FT_Int32
rsvg_text_layout_render_flags (RsvgTextLayout * layout)
{
@@ -747,6 +781,39 @@ rsvg_text_render_vectors (PangoFont * font,
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,