[gl2ps] bug for opacity=0.5 and TextAsPath=1
Dan Lipsa
dan.lipsa at kitware.com
Tue Jan 31 16:33:54 CET 2017
Hi all,
Could someone review my gl2ps changes to our version of gl2ps and hopefully
merge them into master?
I described the bug this fixes in a previous email sent to the list. Let me
know if you need more information.
The changes follow.
Thanks,
Dan
diff --git a/ThirdParty/gl2ps/vtkgl2ps/gl2ps.c
b/ThirdParty/gl2ps/vtkgl2ps/gl2ps.c
index 5ed8773..27fe82d 100644
--- a/ThirdParty/gl2ps/vtkgl2ps/gl2ps.c
+++ b/ThirdParty/gl2ps/vtkgl2ps/gl2ps.c
@@ -3506,8 +3506,9 @@ static void gl2psPutPDFText(GL2PSstring *text, int
cnt, GLfloat x, GLfloat y)
}
}
-static void gl2psPutPDFSpecial(GL2PSstring *text)
+static void gl2psPutPDFSpecial(int prim, int sec, GL2PSstring *text)
{
+ gl2ps->streamlength += gl2psPrintf("/GS%d%d gs\n", prim, sec);
gl2ps->streamlength += gl2psPrintf("%s\n", text->str);
}
@@ -3703,7 +3704,7 @@ static void
gl2psSortOutTrianglePDFgroup(GL2PSpdfgroup *gro)
static void gl2psPDFgroupListWriteMainStream(void)
{
- int i, j, lastel;
+ int i, j, lastel, count;
GL2PSprimitive *prim = NULL, *prev = NULL;
GL2PSpdfgroup *gro;
GL2PStriangle t;
@@ -3711,7 +3712,9 @@ static void gl2psPDFgroupListWriteMainStream(void)
if(!gl2ps->pdfgrouplist)
return;
- for(i = 0; i < gl2psListNbr(gl2ps->pdfgrouplist); ++i){
+ count = gl2psListNbr(gl2ps->pdfgrouplist);
+
+ for(i = 0; i < count; ++i){
gro = (GL2PSpdfgroup*)gl2psListPointer(gl2ps->pdfgrouplist, i);
lastel = gl2psListNbr(gro->ptrlist) - 1;
@@ -3882,9 +3885,13 @@ static void gl2psPDFgroupListWriteMainStream(void)
}
break;
case GL2PS_SPECIAL:
+ lastel = gl2psListNbr(gro->ptrlist) - 1;
+ if(lastel < 0)
+ continue;
+
for(j = 0; j <= lastel; ++j){
prim = *(GL2PSprimitive**)gl2psListPointer(gro->ptrlist, j);
- gl2psPutPDFSpecial(prim->data.text);
+ gl2psPutPDFSpecial(i, j, prim->data.text);
}
default:
break;
@@ -6000,9 +6029,9 @@ GL2PSDLL_API GLint gl2psText(const char *str, const
char *fontname, GLshort font
NULL);
}
-GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str)
+GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str, GL2PSrgba
rgba)
{
- return gl2psAddText(GL2PS_SPECIAL, str, "", 0, format, 0.0F, NULL);
+ return gl2psAddText(GL2PS_SPECIAL, str, "", 0, format, 0.0F, rgba);
}
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height,
diff --git a/ThirdParty/gl2ps/vtkgl2ps/gl2ps.h
b/ThirdParty/gl2ps/vtkgl2ps/gl2ps.h
index 7258061..dd9368a 100644
--- a/ThirdParty/gl2ps/vtkgl2ps/gl2ps.h
+++ b/ThirdParty/gl2ps/vtkgl2ps/gl2ps.h
@@ -203,7 +203,7 @@ GL2PSDLL_API GLint gl2psTextOpt(const char *str, const
char *fontname,
GL2PSDLL_API GLint gl2psTextOptColor(const char *str, const char *fontname,
GLshort fontsize, GLint align,
GLfloat angle,
GL2PSrgba color);
-GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str);
+GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str, GL2PSrgba
rgba);
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height,
GLint xorig, GLint yorig,
GLenum format, GLenum type, const void
*pixels);
On Mon, Dec 19, 2016 at 4:49 PM, Dan Lipsa <dan.lipsa at kitware.com> wrote:
> Hi all,
> We have a merge request in VTK which includes a fix to gl2ps.
>
> https://gitlab.kitware.com/vtk/vtk/merge_requests/2277
>
> The test we use is:
> https://gitlab.kitware.com/vtk/vtk/blob/6d51efa1f268b7cec5dc0ce1e195db
> 4f1c812a23/Rendering/GL2PS/Testing/Cxx/TestGL2PSTextOpacity.cxx
>
> If we set for text the opacity to 0.5 and TextAsPath to 1 we get an
> invalid PDF (text_bad.pdf). After our fix we get an valid PDF (text.pdf).
> See attached files.
>
> Would you please review our changes and once approved include them in
> future versions of gl2ps.
> Changes to a2ps are listed as the last two files in the list of changes:
>
> https://gitlab.kitware.com/vtk/vtk/merge_requests/2277/diffs
>
>
> Thank you,
>
> Dan
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gl2ps/attachments/20170131/93a3a788/attachment.html>