diff --git a/latex-output/latex-output.c b/latex-output/latex-output.c index 618d4ff..2b85056 100644 --- a/latex-output/latex-output.c +++ b/latex-output/latex-output.c @@ -18,6 +18,7 @@ */ #include "latex-output.h" +#include #define WRITEOUT_BUFFER(buff) fwrite((buff)->str, sizeof(char), (buff)->len, tex_file) @@ -87,8 +88,7 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt struct gds_graphics *gfx; struct gds_point *pt; GdkRGBA color; - int width; - gchar *red, *green, *blue, *opacity; + static const char *line_caps[] = {"butt", "round", "rect"}; for (temp = graphics; temp != NULL; temp = temp->next) { gfx = (struct gds_graphics *)temp->data; @@ -108,9 +108,22 @@ static void generate_graphics(FILE *tex_file, GList *graphics, GList *linfo, GSt g_string_printf(buffer, "cycle;\n"); WRITEOUT_BUFFER(buffer); } else if(gfx->gfx_type == GRAPHIC_PATH) { - g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}] ", - gfx->width_absolute/1000.0, gfx->layer, gfx->layer, color.alpha); + + if (g_list_length(gfx->vertices) < 2) { + printf("Cannot write path with less than 2 points\n"); + break; + } + + if (gfx->path_render_type < 0 || gfx->path_render_type > 2) { + printf("Path type unrecognized. Setting to 'flushed'\n"); + gfx->path_render_type = 0; + } + + g_string_printf(buffer, "\\draw[line width=%lf pt, draw={c%d}, opacity={%lf}, cap=%s] ", + gfx->width_absolute/1000.0, gfx->layer, color.alpha, + line_caps[gfx->path_render_type]); WRITEOUT_BUFFER(buffer); + /* Append vertices */ for (temp_vertex = gfx->vertices; temp_vertex != NULL; temp_vertex = temp_vertex->next) { pt = (struct gds_point *)temp_vertex->data; diff --git a/test-data/path.gds b/test-data/path.gds index 7c21667..7599be9 100644 Binary files a/test-data/path.gds and b/test-data/path.gds differ diff --git a/test-data/path.pdf b/test-data/path.pdf index 3947238..078a01a 100644 Binary files a/test-data/path.pdf and b/test-data/path.pdf differ diff --git a/test-data/path.tex b/test-data/path.tex index 8646f0d..805b2fa 100644 --- a/test-data/path.tex +++ b/test-data/path.tex @@ -18,7 +18,25 @@ \ifcreatepdflayers \begin{scope}[ocg={ref=1, status=visible,name={TOP-Layer}}] \fi] -\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}] (-1.218000 pt, 0.711000 pt) -- (-0.197000 pt, 0.425000 pt) -- (-0.027000 pt, -0.046000 pt) -- (0.919000 pt, -0.304000 pt); +\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}, cap=rect] (-1.108000 pt, 0.589000 pt) -- (-0.498000 pt, 0.589000 pt) -- (-0.255000 pt, 0.343000 pt); +\ifcreatepdflayers +\end{scope} +\fi +\end{pgfonlayer} +\begin{pgfonlayer}{l1} +\ifcreatepdflayers +\begin{scope}[ocg={ref=1, status=visible,name={TOP-Layer}}] +\fi] +\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}, cap=butt] (-1.031000 pt, 0.326000 pt) -- (-1.028000 pt, 0.093000 pt) -- (-0.282000 pt, -0.019000 pt); +\ifcreatepdflayers +\end{scope} +\fi +\end{pgfonlayer} +\begin{pgfonlayer}{l1} +\ifcreatepdflayers +\begin{scope}[ocg={ref=1, status=visible,name={TOP-Layer}}] +\fi] +\draw[line width=0.300000 pt, draw={c1}, opacity={1.000000}, cap=round] (0.076000 pt, 0.059000 pt) -- (0.660000 pt, 0.027000 pt) -- (0.871000 pt, 0.599000 pt); \ifcreatepdflayers \end{scope} \fi