diff options
author | Dom Lachowicz <doml@src.gnome.org> | 2004-01-06 02:54:58 +0000 |
---|---|---|
committer | Dom Lachowicz <doml@src.gnome.org> | 2004-01-06 02:54:58 +0000 |
commit | 8693d3cc30a70886c83f3bcafd0c45c189126a40 (patch) | |
tree | 067e8770ab76d314ee500633dc1ed46e8a6e701b | |
parent | e46c6d6b0e6684ad81ddd5783739afcf76fc4c39 (diff) | |
download | librsvg-8693d3cc30a70886c83f3bcafd0c45c189126a40.tar.gz |
factor out vector vs raster text routines
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Makefile.am | 95 | ||||
-rw-r--r-- | rsvg-shapes.c | 5 | ||||
-rw-r--r-- | rsvg-shapes.h | 1 | ||||
-rw-r--r-- | rsvg-text-vectors.c | 12 | ||||
-rw-r--r-- | rsvg-text.c | 144 | ||||
-rw-r--r-- | rsvg-text.h | 6 |
7 files changed, 132 insertions, 136 deletions
@@ -1,3 +1,8 @@ +2004-01-05 Dom Lachowicz <cinamod@hotmail.com> + + * rsvg-text.c: + * rsvg-text-vectors.c: Factor out bitmap vs. vector text routines + 2004-01-04 Dom Lachowicz <cinamod@hotmail.com> * rsvg-text-vectors.c: Start of work toward representing text as diff --git a/Makefile.am b/Makefile.am index c614f06d..7ce48b8d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,66 +19,71 @@ else libm = -lm endif -EXTRA_DIST =\ - COPYING.LIB \ - librsvg.spec.in \ - librsvg-2.0.pc.in \ - librsvg-zip.in \ - rsvg-gz.c \ - rsvg-gz.h \ +EXTRA_DIST = \ + COPYING.LIB \ + librsvg.spec.in \ + librsvg-2.0.pc.in \ + librsvg-zip.in \ + rsvg-gz.c \ + rsvg-gz.h \ $(man_MANS) lib_LTLIBRARIES = librsvg-2.la -librsvg_2_la_SOURCES = $(GSFSOURCES) \ - librsvg-features.c \ - rsvg-bpath-util.c \ - rsvg-bpath-util.h \ - rsvg-css.c \ - rsvg-css.h \ - rsvg-defs.c \ - rsvg-defs.h \ - rsvg-paint-server.c \ - rsvg-paint-server.h \ - rsvg-path.c \ - rsvg-path.h \ - rsvg-private.h \ - rsvg-file-util.c \ - rsvg-shapes.c \ - rsvg-shapes.h \ - rsvg-styles.c \ - rsvg-styles.h \ - rsvg-text.c \ - rsvg-text.h \ +librsvg_2_la_SOURCES = \ + $(GSFSOURCES) \ + librsvg-features.c \ + rsvg-bpath-util.c \ + rsvg-bpath-util.h \ + rsvg-css.c \ + rsvg-css.h \ + rsvg-defs.c \ + rsvg-defs.h \ + rsvg-paint-server.c \ + rsvg-paint-server.h \ + rsvg-path.c \ + rsvg-path.h \ + rsvg-private.h \ + rsvg-file-util.c \ + rsvg-shapes.c \ + rsvg-shapes.h \ + rsvg-styles.c \ + rsvg-styles.h \ + rsvg-text.c \ + rsvg-text-vectors.c \ + rsvg-text.h \ rsvg.c librsvg_2_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined -export-dynamic librsvg_2_la_LIBADD = $(LIBRSVG_LIBS) $(LIBGSF_LIBS) $(LIBCROCO_LIBS) librsvgincdir = $(includedir)/librsvg-2/librsvg -librsvginc_HEADERS = $(GSFHEADERS) \ - rsvg.h \ +librsvginc_HEADERS = \ + $(GSFHEADERS) \ + rsvg.h \ librsvg-features.h -INCLUDES =$(LIBGSF_CFLAGS)\ - $(LIBCROCO_CFLAGS)\ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(LIBRSVG_CFLAGS) \ - $(GTK_CFLAGS) \ - -DG_LOG_DOMAIN=\"librsvg\" \ - -DG_DISABLE_DEPRECATED \ - -DPANGO_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ +INCLUDES = \ + $(LIBGSF_CFLAGS) \ + $(LIBCROCO_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(LIBRSVG_CFLAGS) \ + $(GTK_CFLAGS) \ + -DG_LOG_DOMAIN=\"librsvg\" \ + -DG_DISABLE_DEPRECATED \ + -DPANGO_DISABLE_DEPRECATED \ + -DGDK_DISABLE_DEPRECATED \ + -DGDK_PIXBUF_DISABLE_DEPRECATED \ + -DGTK_DISABLE_DEPRECATED \ -DDATADIR="\"$(datadir)\"" DEPS = $(top_builddir)/librsvg-2.la -LDADDS =$(LIBGSF_LIBS)\ - $(LIBCROCO_LIBS)\ - $(top_builddir)/librsvg-2.la \ - $(LIBRSVG_LIBS) \ +LDADDS = \ + $(LIBGSF_LIBS) \ + $(LIBCROCO_LIBS) \ + $(top_builddir)/librsvg-2.la \ + $(LIBRSVG_LIBS) \ $(POPT_LIBS) rsvg_SOURCES=test-rsvg.c diff --git a/rsvg-shapes.c b/rsvg-shapes.c index ca591d13..4de9508a 100644 --- a/rsvg-shapes.c +++ b/rsvg-shapes.c @@ -336,10 +336,7 @@ rsvg_defs_path_free (RsvgDefVal *self) g_free (z); } -/** - * Todo: Possibly publicly export this (for text) - */ -static void +void rsvg_handle_path (RsvgHandle *ctx, const char * d, const char * id) { if (!ctx->in_defs) diff --git a/rsvg-shapes.h b/rsvg-shapes.h index 2530eea7..8aa0a1a7 100644 --- a/rsvg-shapes.h +++ b/rsvg-shapes.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS +void rsvg_handle_path (RsvgHandle *ctx, const char * d, const char * id); void rsvg_render_path (RsvgHandle *ctx, const char *d); void rsvg_start_path (RsvgHandle *ctx, const xmlChar **atts); void rsvg_start_polygon (RsvgHandle *ctx, const xmlChar **atts); diff --git a/rsvg-text-vectors.c b/rsvg-text-vectors.c index 93af5eb9..1c0281d2 100644 --- a/rsvg-text-vectors.c +++ b/rsvg-text-vectors.c @@ -24,6 +24,7 @@ #include "rsvg-private.h" #include "rsvg-text.h" +#include "rsvg-shapes.h" #include "rsvg-css.h" #include <libart_lgpl/art_affine.h> @@ -35,14 +36,6 @@ #include FT_GLYPH_H #include FT_OUTLINE_H -#include "rsvg-shapes.h" - -void -rsvg_text_render_text (RsvgHandle *ctx, - RsvgState *state, - const char *text, - const char *id); - typedef struct _RsvgTextLayout RsvgTextLayout; struct _RsvgTextLayout @@ -497,6 +490,9 @@ rsvg_text_render_text (RsvgHandle *ctx, rsvg_text_layout_render (layout, rsvg_text_render_vectors, (gpointer)render); + + /* Only a debugging message for now */ + g_print("%s\n", render->path->str); rsvg_handle_path (ctx, render->path->str, id); diff --git a/rsvg-text.c b/rsvg-text.c index 3419f89e..dd4d4325 100644 --- a/rsvg-text.c +++ b/rsvg-text.c @@ -36,30 +36,7 @@ #include "rsvg-shapes.h" -#if 0 - -static void -rsvg_draw_hline (RsvgHandle *ctx, double x, double w, double y) -{ - char buf [G_ASCII_DTOSTR_BUF_SIZE]; - - /* ("M %f %f L %f %f", x, y, x+w, y) */ - GString * d = g_string_new ("M "); - - g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x)); - g_string_append_c (d, ' '); - g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y)); - g_string_append (d, " L "); - g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), x+w)); - g_string_append_c (d, ' '); - g_string_append (d, g_ascii_dtostr (buf, sizeof (buf), y)); - - rsvg_render_path (ctx, d->str); - - g_string_free (d, TRUE); -} - -#endif +#define NO_VECTOR_TEXT char * make_valid_utf8 (const char *str) @@ -108,14 +85,14 @@ rsvg_text_handler_free (RsvgSaxHandler *self) g_free (self); } -static void -rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) +#ifdef NO_VECTOR_TEXT + +static void +rsvg_text_render_text_bitmap (RsvgHandle *ctx, + RsvgState *state, + const char *string, + const char *id) { - RsvgSaxHandlerText *z = (RsvgSaxHandlerText *)self; - RsvgHandle *ctx = z->ctx; - char *string, *tmp; - int beg, end; - RsvgState *state; ArtRender *render; GdkPixbuf *pixbuf; gboolean has_alpha; @@ -127,14 +104,6 @@ rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) FT_Bitmap bitmap; RsvgPSCtx gradctx; int i; - - state = rsvg_state_current (ctx); - if (state->fill == NULL && state->font_size <= 0) - return; - - /* not quite up to spec, but good enough */ - if (!state->visible) - return; pixbuf = ctx->pixbuf; if (pixbuf == NULL) @@ -142,36 +111,7 @@ rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) /* FIXME: What warning/GError here? */ return; } - - /* Copy ch into string, chopping off leading and trailing whitespace */ - for (beg = 0; beg < len; beg++) - if (!g_ascii_isspace (ch[beg])) - break; - - for (end = len; end > beg; end--) - if (!g_ascii_isspace (ch[end - 1])) - break; - - if (end - beg == 0) - { - /* TODO: be smarter with some "last was space" logic */ - end = 1; beg = 0; - string = g_strdup (" "); - } - else - { - string = g_malloc (end - beg + 1); - memcpy (string, ch + beg, end - beg); - string[end - beg] = 0; - } - - if (!g_utf8_validate (string, -1, NULL)) - { - tmp = make_valid_utf8 (string); - g_free (string); - string = tmp; - } - + if (ctx->pango_context == NULL) { PangoFT2FontMap *fontmap; @@ -283,19 +223,65 @@ rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) art_render_invoke (render); g_free (bitmap.buffer); - g_free (string); -#if 0 - /* TODO: store the various line widths for these */ - if (state->font_decor & TEXT_OVERLINE) - rsvg_draw_hline (ctx, state->text_offset, line_ink_rect.width, -line_ink_rect.y + line_ink_rect.height); - if (state->font_decor & TEXT_UNDERLINE) - rsvg_draw_hline (ctx, state->text_offset, line_ink_rect.width, -line_ink_rect.y); - if (state->font_decor & TEXT_STRIKE) - rsvg_draw_hline (ctx, state->text_offset, ink_rect.width, -line_ink_rect.y - (line_ink_rect.height/2)); + state->text_offset += line_ink_rect.width; +} + #endif + +static void +rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) +{ + RsvgSaxHandlerText *z = (RsvgSaxHandlerText *)self; + RsvgHandle *ctx = z->ctx; + char *string, *tmp; + int beg, end; + RsvgState *state; - state->text_offset += line_ink_rect.width; + state = rsvg_state_current (ctx); + if (state->fill == NULL && state->font_size <= 0) + return; + + /* not quite up to spec, but good enough */ + if (!state->visible) + return; + + /* Copy ch into string, chopping off leading and trailing whitespace */ + for (beg = 0; beg < len; beg++) + if (!g_ascii_isspace (ch[beg])) + break; + + for (end = len; end > beg; end--) + if (!g_ascii_isspace (ch[end - 1])) + break; + + if (end - beg == 0) + { + /* TODO: be smarter with some "last was space" logic */ + end = 1; beg = 0; + string = g_strdup (" "); + } + else + { + string = g_malloc (end - beg + 1); + memcpy (string, ch + beg, end - beg); + string[end - beg] = 0; + } + + if (!g_utf8_validate (string, -1, NULL)) + { + tmp = make_valid_utf8 (string); + g_free (string); + string = tmp; + } + +#ifdef NO_VECTOR_TEXT + rsvg_text_render_text_bitmap (ctx, state, string, NULL); +#else + rsvg_text_render_text (ctx, state, string, NULL); +#endif + + g_free (string); } void diff --git a/rsvg-text.h b/rsvg-text.h index 1890e18b..8c244197 100644 --- a/rsvg-text.h +++ b/rsvg-text.h @@ -34,6 +34,12 @@ void rsvg_start_text (RsvgHandle *ctx, const xmlChar **atts); void rsvg_start_tspan (RsvgHandle *ctx, const xmlChar **atts); char * make_valid_utf8 (const char *str); +void +rsvg_text_render_text (RsvgHandle *ctx, + RsvgState *state, + const char *text, + const char *id); + G_END_DECLS #endif /* RSVG_TEXT_H */ |