[gl2ps] bug for opacity=0.5 and TextAsPath=1

Dan Lipsa dan.lipsa at kitware.com
Mon Feb 6 16:35:55 CET 2017


On Fri, Feb 3, 2017 at 5:06 PM, Christophe Geuzaine <cgeuzaine at ulg.ac.be>
wrote:

>
> Dear Dan,
>
> The patch looks OK to me: I merged a slightly modified version, that
> introduces a new function gl2psSpecialColor in order not to break the API
> of gl2psSpecial.
>


Christophe,
Sounds good. Thanks for reviewing and merging in the change.

Dan



>
> Thanks!
>
> Christophe
>
>
> > On 31 Jan 2017, at 16:33, Dan Lipsa <dan.lipsa at kitware.com> wrote:
> >
> > 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 gl2psPDFgroupListWriteMainStre
> am(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
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > gl2ps mailing list
> > gl2ps at geuz.org
> > http://www.geuz.org/mailman/listinfo/gl2ps
>
> --
> Prof. Christophe Geuzaine
> University of Liege, Electrical Engineering and Computer Science
> http://www.montefiore.ulg.ac.be/~geuzaine
>
> Free software: http://gmsh.info | http://getdp.info | http://onelab.info
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gl2ps/attachments/20170206/d02d6633/attachment.html>