Primitive ps glyph support. Fix ps strokes to not leave path defined

This commit is contained in:
Keith Packard 2006-02-27 19:23:47 -08:00
parent 06b83b89fc
commit 59e4a32d55
3 changed files with 50 additions and 6 deletions

View file

@ -752,10 +752,18 @@ emit_image (cairo_ps_surface_t *surface,
cairo_matrix_init (&d2i, 1, 0, 0, 1, 0, 0);
cairo_matrix_multiply (&d2i, &d2i, matrix);
#if 1
/* Construct a string holding the entire image (!) */
_cairo_output_stream_printf (surface->stream, "/%sString %d string def\n",
name, (int) rgb_size);
_cairo_output_stream_printf (surface->stream,
"currentfile %sString readstring\n", name);
#else
/* Construct a reusable stream decoder holding the image */
_cairo_output_stream_printf (surface->stream, "/%sString <<\n", name);
/* intent = image data */
_cairo_output_stream_printf (surface->stream, "\t/Intent 0\n");
#endif
/* Compressed image data */
_cairo_output_stream_write (surface->stream, rgb, rgb_size);
@ -781,7 +789,7 @@ emit_image (cairo_ps_surface_t *surface,
d2i.xx, d2i.yx,
d2i.xy, d2i.yy,
d2i.x0, d2i.y0);
_cairo_output_stream_printf (surface->stream, "} def\n");
_cairo_output_stream_printf (surface->stream, "} bind def\n");
status = CAIRO_STATUS_SUCCESS;
@ -1200,6 +1208,8 @@ _cairo_ps_surface_stroke (void *abstract_surface,
info.output_stream = stream;
info.has_current_point = FALSE;
_cairo_output_stream_printf (stream,
"gsave\n");
status = _cairo_path_fixed_interpret (path,
CAIRO_DIRECTION_FORWARD,
_cairo_ps_surface_path_move_to,
@ -1211,8 +1221,6 @@ _cairo_ps_surface_stroke (void *abstract_surface,
/*
* Switch to user space to set line parameters
*/
_cairo_output_stream_printf (stream,
"gsave\n");
_cairo_output_stream_printf (stream,
"[%f %f %f %f 0 0] concat\n",
ctm->xx, ctm->yx, ctm->xy, ctm->yy);
@ -1301,6 +1309,41 @@ _cairo_ps_surface_fill (void *abstract_surface,
return status;
}
static cairo_int_status_t
_cairo_ps_surface_show_glyphs (void *abstract_surface,
cairo_operator_t op,
cairo_pattern_t *source,
const cairo_glyph_t *glyphs,
int num_glyphs,
cairo_scaled_font_t *scaled_font)
{
cairo_ps_surface_t *surface = abstract_surface;
cairo_output_stream_t *stream = surface->stream;
cairo_int_status_t status;
cairo_path_fixed_t *path;
if (surface->mode == CAIRO_PAGINATED_MODE_ANALYZE) {
if (!pattern_operation_supported (op, source))
return CAIRO_INT_STATUS_UNSUPPORTED;
return CAIRO_STATUS_SUCCESS;
}
if (surface->need_start_page)
_cairo_ps_surface_start_page (surface);
_cairo_output_stream_printf (stream,
"%% _cairo_ps_surface_show_glyphs\n");
path = _cairo_path_fixed_create ();
_cairo_scaled_font_glyph_path (scaled_font, glyphs, num_glyphs, path);
status = _cairo_ps_surface_fill (abstract_surface, op, source,
path, CAIRO_FILL_RULE_WINDING,
0.1, scaled_font->options.antialias);
_cairo_path_fixed_destroy (path);
return CAIRO_STATUS_SUCCESS;
}
static const cairo_surface_backend_t cairo_ps_surface_backend = {
NULL, /* create_similar */
_cairo_ps_surface_finish,
@ -1334,7 +1377,8 @@ static const cairo_surface_backend_t cairo_ps_surface_backend = {
NULL, /* mask */
_cairo_ps_surface_stroke,
_cairo_ps_surface_fill,
NULL /* show_glyphs */
_cairo_ps_surface_show_glyphs,
NULL, /* snapshot */
};
static void

View file

@ -1008,7 +1008,7 @@ _scaled_glyph_path_close_path (void *abstract_closure)
cairo_status_t
_cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
cairo_glyph_t *glyphs,
const cairo_glyph_t *glyphs,
int num_glyphs,
cairo_path_fixed_t *path)
{

View file

@ -1529,7 +1529,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font,
cairo_private cairo_status_t
_cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
cairo_glyph_t *glyphs,
const cairo_glyph_t *glyphs,
int num_glyphs,
cairo_path_fixed_t *path);