diff options
-rw-r--r-- | xps/xpsglyphs.c | 38 | ||||
-rw-r--r-- | xps/xpspage.c | 15 | ||||
-rw-r--r-- | xps/xpspath.c | 88 | ||||
-rw-r--r-- | xps/xpsvisual.c | 1 |
4 files changed, 107 insertions, 35 deletions
diff --git a/xps/xpsglyphs.c b/xps/xpsglyphs.c index 1169a57ef..fc48e8094 100644 --- a/xps/xpsglyphs.c +++ b/xps/xpsglyphs.c @@ -502,41 +502,43 @@ xps_parse_glyphs(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) * Set up graphics state. */ - if (transform_att || transform_tag) + if (clip_att || clip_tag) { - gs_matrix transform; - - dputs("glyphs transform\n"); - if (!saved) { gs_gsave(ctx->pgs); saved = 1; } - if (transform_att) - xps_parse_render_transform(ctx, transform_att, &transform); - if (transform_tag) - xps_parse_matrix_transform(ctx, transform_tag, &transform); + dputs("glyphs clip\n"); - gs_concat(ctx->pgs, &transform); + if (clip_att) + xps_parse_abbreviated_geometry(ctx, clip_att); + if (clip_tag) + xps_parse_path_geometry(ctx, dict, clip_tag); + + gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); } - if (clip_att || clip_tag) + if (transform_att || transform_tag) { + gs_matrix transform; + + dputs("glyphs transform\n"); + if (!saved) { gs_gsave(ctx->pgs); saved = 1; } - dputs("glyphs clip\n"); + if (transform_att) + xps_parse_render_transform(ctx, transform_att, &transform); + if (transform_tag) + xps_parse_matrix_transform(ctx, transform_tag, &transform); - if (clip_att) - { - xps_parse_abbreviated_geometry(ctx, clip_att); - gs_clip(ctx->pgs); - } + gs_concat(ctx->pgs, &transform); } font_size = atof(font_size_att); @@ -592,6 +594,8 @@ xps_parse_glyphs(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) is_sideways, bidi_level, indices_att, unicode_att, 1); gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); + dputs("clip\n"); if (!strcmp(xps_tag(fill_tag), "ImageBrush")) diff --git a/xps/xpspage.c b/xps/xpspage.c index 3077b2d33..28e88e281 100644 --- a/xps/xpspage.c +++ b/xps/xpspage.c @@ -56,7 +56,20 @@ int xps_parse_canvas(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) xps_parse_matrix_transform(ctx, transform_tag, &transform); gs_concat(ctx->pgs, &transform); - // TODO: clip + if (clip_att) + { + xps_parse_abbreviated_geometry(ctx, clip_att); + gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); + } + + if (clip_tag) + { + xps_parse_path_geometry(ctx, dict, clip_tag); + gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); + } + // TODO: opacity // TODO: opacity_mask diff --git a/xps/xpspath.c b/xps/xpspath.c index c3fd5e158..88d8f9bcf 100644 --- a/xps/xpspath.c +++ b/xps/xpspath.c @@ -528,6 +528,8 @@ xps_parse_path(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) char *stroke_miter_limit_att; char *stroke_thickness_att; + gs_line_cap linecap; + gs_line_join linejoin; int saved = 0; /* @@ -595,31 +597,57 @@ xps_parse_path(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) stroke_tag = NULL; } + /* TODO: stroke_end_line_cap_att */ + /* TODO: stroke_dash_cap_att */ + + linecap = gs_cap_butt; + if (stroke_start_line_cap_att) + { + if (!strcmp(stroke_start_line_cap_att, "Flat")) linecap = gs_cap_butt; + if (!strcmp(stroke_start_line_cap_att, "Square")) linecap = gs_cap_square; + if (!strcmp(stroke_start_line_cap_att, "Round")) linecap = gs_cap_round; + if (!strcmp(stroke_start_line_cap_att, "Triangle")) linecap = gs_cap_triangle; + } + gs_setlinecap(ctx->pgs, linecap); + + linejoin = gs_join_miter; + if (stroke_line_join_att) + { + if (!strcmp(stroke_line_join_att, "Miter")) linejoin = gs_join_miter; + if (!strcmp(stroke_line_join_att, "Bevel")) linejoin = gs_join_bevel; + if (!strcmp(stroke_line_join_att, "Round")) linejoin = gs_join_round; + } + gs_setlinejoin(ctx->pgs, linecap); + if (stroke_miter_limit_att) gs_setmiterlimit(ctx->pgs, atof(stroke_miter_limit_att)); + if (stroke_thickness_att) gs_setlinewidth(ctx->pgs, atof(stroke_thickness_att)); - /* if we have a transform, push that on the gstate and remember to restore */ - - if (transform_att || transform_tag) + if (stroke_dash_array_att) { - gs_matrix transform; + float dash_array[100]; + float dash_offset = 0.0; + int dash_count = 0; - dputs(" path transform\n"); + if (stroke_dash_offset_att) + dash_offset = atof(stroke_dash_offset_att); - if (!saved) - { - gs_gsave(ctx->pgs); - saved = 1; - } + /* TODO: parse array of space separated numbers */ + dash_array[0] = 10.0; + dash_array[1] = 20.0; + dash_array[2] = 5.0; + dash_array[3] = 20.0; + dash_count = 4; - if (transform_att) - xps_parse_render_transform(ctx, transform_att, &transform); - if (transform_tag) - xps_parse_matrix_transform(ctx, transform_tag, &transform); + dputs(".... dashed line ....\n"); - gs_concat(ctx->pgs, &transform); + gs_setdash(ctx->pgs, dash_array, dash_count, dash_offset); + } + else + { + gs_setdash(ctx->pgs, NULL, 0, 0.0); } /* if we have a clip mask, push that on the gstate and remember to restore */ @@ -635,10 +663,34 @@ xps_parse_path(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) dputs(" path clip\n"); if (clip_att) - { xps_parse_abbreviated_geometry(ctx, clip_att); - gs_clip(ctx->pgs); + if (clip_tag) + xps_parse_path_geometry(ctx, dict, clip_tag); + + gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); + } + + /* if we have a transform, push that on the gstate and remember to restore */ + + if (transform_att || transform_tag) + { + gs_matrix transform; + + dputs(" path transform\n"); + + if (!saved) + { + gs_gsave(ctx->pgs); + saved = 1; } + + if (transform_att) + xps_parse_render_transform(ctx, transform_att, &transform); + if (transform_tag) + xps_parse_matrix_transform(ctx, transform_tag, &transform); + + gs_concat(ctx->pgs, &transform); } /* if it's a solid color brush fill/stroke do just that. */ @@ -693,6 +745,8 @@ xps_parse_path(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root) if (data_tag) xps_parse_path_geometry(ctx, dict, data_tag); gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); + dputs("clip\n"); if (fill_tag) diff --git a/xps/xpsvisual.c b/xps/xpsvisual.c index e079afb44..b7db253d4 100644 --- a/xps/xpsvisual.c +++ b/xps/xpsvisual.c @@ -117,6 +117,7 @@ xps_parse_visual_brush(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *roo gs_lineto(ctx->pgs, viewbox.q.x, viewbox.p.y); gs_closepath(ctx->pgs); gs_clip(ctx->pgs); + gs_newpath(ctx->pgs); if (!strcmp(xps_tag(visual_tag), "Path")) xps_parse_path(ctx, dict, visual_tag); |