diff options
author | Dom Lachowicz <doml@src.gnome.org> | 2004-06-15 01:08:57 +0000 |
---|---|---|
committer | Dom Lachowicz <doml@src.gnome.org> | 2004-06-15 01:08:57 +0000 |
commit | 078169b972868240ff788aa104fa7eb61fb74863 (patch) | |
tree | 29e9cca64dc8a11140e58b4fa60ac8e034f13b0d | |
parent | 11fa691a1c8e5195e2d6d6208533d0b12a41a2d4 (diff) | |
download | librsvg-078169b972868240ff788aa104fa7eb61fb74863.tar.gz |
remove old text harness, solely use the vector/path based one
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | rsvg-css.c | 2 | ||||
-rw-r--r-- | rsvg-text-vectors.c | 30 | ||||
-rw-r--r-- | rsvg-text.c | 151 |
4 files changed, 11 insertions, 179 deletions
@@ -1,10 +1,15 @@ +2004-06-14 Dom Lachowicz <cinamod@hotmail.com> + + * rsvg-text.c: Removed old text harness, replaced entirely with vector + text. + 2004-06-15 Caleb Moore <c.moore@student.unsw.edu.au> * rsvg-text.c, rsvg-text-vectors.c: well, um, I've been doing a fair bit of tweaking. Mainly very late at night so my memory of it is far from complete. 2004-06-13 Caleb Moore <c.moore@student.unsw.edu.au> - * rsvg-shapes.c: Implemented markers for streight lines + * rsvg-shapes.c: Implemented markers for straight lines 2004-06-10 Dom Lachowicz <cinamod@hotmail.com> @@ -736,7 +736,7 @@ rsvg_css_parse_list(const char * in_str, guint * out_list_len) { /*the following code is defective because it creates blank entries when two splitting chars are next to each other*/ -#if 0//GLIB_CHECK_VERSION(2, 3, 2) +#if 0 /* GLIB_CHECK_VERSION(2, 3, 2) */ gchar ** string_array; guint n; diff --git a/rsvg-text-vectors.c b/rsvg-text-vectors.c index 3b29c053..9f6a450c 100644 --- a/rsvg-text-vectors.c +++ b/rsvg-text-vectors.c @@ -37,8 +37,6 @@ #include FT_GLYPH_H #include FT_OUTLINE_H -//#define RSVG_TEXT_DEBUG - typedef struct _RsvgTextLayout RsvgTextLayout; struct _RsvgTextLayout @@ -210,12 +208,12 @@ rsvg_text_layout_get_offsets (RsvgTextLayout *layout, static FT_Int32 rsvg_text_layout_render_flags (RsvgTextLayout *layout) { - gint flags; + gint flags = 0; if (ANTIALIAS_TEXT) - flags = FT_LOAD_NO_BITMAP; + flags |= FT_LOAD_NO_BITMAP; else - flags = FT_LOAD_TARGET_MONO; + flags |= FT_LOAD_TARGET_MONO; if (!HINT_TEXT) flags |= FT_LOAD_NO_HINTING; @@ -236,17 +234,6 @@ rsvg_text_vector_coords (RenderCtx *ctx, *y = ctx->offset_y - (double)vector->y / 64. + ctx->position_y; } -static void -print266 (FT_Vector *pnt, - gchar *msg) -{ -#ifdef RSVG_TEXT_DEBUG - fprintf (stderr, "%s Point (%d,%d)\n", - msg, (gint)pnt->x, - (gint)pnt->y); -#endif -} - static gint moveto (FT_Vector *to, gpointer data) @@ -257,8 +244,6 @@ moveto (FT_Vector *to, ctx = (RenderCtx *)data; - print266(to, "Moveto"); - if (ctx->wrote) g_string_append(ctx->path, "Z "); else @@ -288,8 +273,6 @@ lineto (FT_Vector *to, if (!ctx->wrote) return 0; - print266(to, "Lineto"); - g_string_append_c(ctx->path, 'L'); rsvg_text_vector_coords(ctx, to, &x, &y); @@ -315,9 +298,6 @@ conicto (FT_Vector *ftcontrol, if (!ctx->wrote) return 0; - print266(ftcontrol, "Conicto Control"); - print266(to, "Conicto"); - g_string_append_c(ctx->path, 'Q'); rsvg_text_vector_coords(ctx, ftcontrol, &x, &y); @@ -350,10 +330,6 @@ cubicto (FT_Vector *ftcontrol1, if (!ctx->wrote) return 0; - print266(ftcontrol1, "Cubicto Control1"); - print266(ftcontrol2, "Cubicto Control2"); - print266(to, "Cubicto"); - g_string_append_c(ctx->path, 'C'); rsvg_text_vector_coords(ctx, ftcontrol1, &x, &y); diff --git a/rsvg-text.c b/rsvg-text.c index 7fa21ab9..b2ff2cd6 100644 --- a/rsvg-text.c +++ b/rsvg-text.c @@ -86,152 +86,6 @@ rsvg_text_handler_free (RsvgSaxHandler *self) g_free (self); } -static void -rsvg_text_render_text_bitmap (RsvgHandle *ctx, - RsvgState *state, - const char *string, - const char *id) -{ - ArtRender *render; - GdkPixbuf *pixbuf; - gboolean has_alpha; - int opacity; - PangoLayout *layout; - PangoFontDescription *font; - PangoLayoutLine *line; - PangoRectangle ink_rect, line_ink_rect, logical_rect; - FT_Bitmap bitmap; - RsvgPSCtx gradctx; - int i; - - rsvg_push_discrete_layer(ctx); - - pixbuf = ctx->pixbuf; - if (pixbuf == NULL) - { - /* FIXME: What warning/GError here? */ - return; - } - - if (ctx->pango_context == NULL) - { - PangoFT2FontMap *fontmap; - - fontmap = PANGO_FT2_FONT_MAP (pango_ft2_font_map_new ()); - pango_ft2_font_map_set_resolution (fontmap, ctx->dpi, ctx->dpi); - - ctx->pango_context = pango_ft2_font_map_create_context (fontmap); - g_object_unref (fontmap); - } - - layout = pango_layout_new (ctx->pango_context); - pango_layout_set_text (layout, string, -1); - font = pango_font_description_copy (pango_context_get_font_description (ctx->pango_context)); - - /* we need to resize the font by our X or Y scale (ideally could stretch in both directions...) - which, though? Y for now */ - pango_font_description_set_size (font, state->font_size * PANGO_SCALE * state->affine[3]); - - if (state->font_family) - pango_font_description_set_family_static (font, state->font_family); - - pango_font_description_set_style (font, state->font_style); - pango_font_description_set_variant (font, state->font_variant); - pango_font_description_set_weight (font, state->font_weight); - pango_font_description_set_stretch (font, state->font_stretch); - pango_layout_set_alignment (layout, (state->text_dir == PANGO_DIRECTION_LTR || - state->text_dir == PANGO_DIRECTION_TTB_LTR) ? - PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT); - - pango_layout_set_font_description (layout, font); - pango_font_description_free (font); - - pango_layout_get_pixel_extents (layout, &ink_rect, NULL); - - line = pango_layout_get_line (layout, 0); - if (line == NULL) - line_ink_rect = ink_rect; /* nothing to draw anyway */ - else - pango_layout_line_get_pixel_extents (line, &line_ink_rect, NULL); - - bitmap.rows = ink_rect.height; - bitmap.width = ink_rect.width; - bitmap.pitch = bitmap.width; - bitmap.buffer = g_malloc0 (bitmap.rows * bitmap.pitch); - bitmap.num_grays = 256; - bitmap.pixel_mode = ft_pixel_mode_grays; - - pango_ft2_render_layout (&bitmap, layout, -ink_rect.x, -ink_rect.y); - pango_layout_get_pixel_extents (layout, NULL, &logical_rect); - if ((state->text_dir == PANGO_DIRECTION_RTL) || - (state->text_dir == PANGO_DIRECTION_LTR)) { - switch (state->text_anchor) { - case TEXT_ANCHOR_MIDDLE: - logical_rect.width /= 2; - break; - case TEXT_ANCHOR_END: - break; - default: - logical_rect.width = 0; - break; - } - logical_rect.height = 0; - } else { - switch (state->text_anchor) { - case TEXT_ANCHOR_MIDDLE: - logical_rect.height /= 2; - break; - case TEXT_ANCHOR_END: - break; - default: - logical_rect.height = 0; - break; - } - logical_rect.width = 0; - } - g_object_unref (layout); - has_alpha = gdk_pixbuf_get_has_alpha (pixbuf); - render = art_render_new (0, 0, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - gdk_pixbuf_get_pixels (pixbuf), - gdk_pixbuf_get_rowstride (pixbuf), - gdk_pixbuf_get_n_channels (pixbuf) - - (has_alpha ? 1 : 0), - gdk_pixbuf_get_bits_per_sample (pixbuf), - has_alpha ? ART_ALPHA_SEPARATE : ART_ALPHA_NONE, - NULL); - - gradctx.x0 = line_ink_rect.x; - gradctx.y0 = line_ink_rect.y; - gradctx.x1 = line_ink_rect.x + logical_rect.width; - gradctx.y1 = line_ink_rect.y + logical_rect.height; - gradctx.ctx = ctx; - for (i = 0; i < 6; i++) - gradctx.affine[i] = state->affine[i]; - - rsvg_render_paint_server (render, state->fill, &gradctx); - - opacity = state->fill_opacity * state->opacity; - opacity = opacity + (opacity >> 7) + (opacity >> 14); - - art_render_mask_solid (render, opacity); - art_render_mask (render, - state->affine[4] + line_ink_rect.x + state->text_offset - logical_rect.width, - state->affine[5] + line_ink_rect.y - logical_rect.height, - state->affine[4] + line_ink_rect.x + bitmap.width + state->text_offset - logical_rect.width, - state->affine[5] + line_ink_rect.y + bitmap.rows - logical_rect.height, - bitmap.buffer, bitmap.pitch); - art_render_invoke (render); - - g_free (bitmap.buffer); - - state->text_offset += line_ink_rect.width; - - rsvg_pop_discrete_layer(ctx); - -} - static void rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) { @@ -278,10 +132,7 @@ rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len) string = tmp; } - if(g_getenv("RSVG_TEXT_VECTORS")) - rsvg_text_render_text (ctx, state, string, NULL, z->x, z->y); - else - rsvg_text_render_text_bitmap (ctx, state, string, NULL); + rsvg_text_render_text (ctx, state, string, NULL, z->x, z->y); g_free (string); } |