[cairo] Problems printing dotted/dashed lines - cairo_set_dash working?
Andrea Canciani
ranma42 at gmail.com
Mon Feb 14 01:11:20 PST 2011
On Fri, Feb 11, 2011 at 1:13 AM, Ian Puleston
<ian at underpressuredivers.com> wrote:
> Hi,
>
> I'm cross-posting this from the GTK list, so apologies to anyone on both
> lists.
>
> I'm have an application that uses GTK and print pages to a printer with text
> overlaid in a grid using pango/cairo and GtkPrintOperation etc. This works
> great, but I am currently updating it to do some more with that and have hit
> a couple of problems with things that don't seem to be working as they
> should. These are happening with a Windows build with GTK 2.22.1, Pango
> 1.28.3 and Cairo 1.10.2 - I haven't tried to see if the same happens in a
> Linux build.
>
> This is the first of them:
>
> I want to print a line of the grid dotted or dashed. I found some info on
> how to do this as follows:
>
> This is my existing code that prints a line of the grid:
>
> cairo_t *cr = gtk_print_context_get_cairo_context(context);
> ...
> cairo_move_to(cr, start, currPos_y);
> cairo_line_to(cr, end, currPos_y);
> cairo_stroke(cr);
>
> And I added these two lines before the "cairo_move_to":
>
> static const double dotted[] = {1.0};
> cairo_set_dash(cr, dotted, 1, 0);
>
> This had no effect and the line is still printed solid. The same happened
> when I tried this instead:
>
> static const double dashed[] = {4.0, 1.0}; /* dash on len, dash off len
> */
> cairo_set_dash(cr, dashed, 2, 0);
>
> Anyone know if cairo_set_dash should work OK in a Windows build?
It looks like cairo-win32-printing-surfaces should support "native"
dashing if the offset is 0 and fallback if the offset is != 0.
Can you please check if setting a small dash offset causes the line
to appear dashed? It might be useful to locate the problem with
more accuracy.
Andrea
More information about the cairo
mailing list