Re: Merge point function crashes
Abraham Lee <[email protected]> Tue, 5 Mar 2019 09:21:43 -0700
| Newsgroups | gmane.comp.fonts.fontforge.devel |
|---|---|
| Message-ID | <CAHAQwh1GJpZ9zWMxJOZg1R-NHnALCPCCJHOpRoPf_eG0pbnrkQ@mail.gmail.com> |
--===============3643673904491823561== Content-Type: multipart/alternative; boundary="000000000000884f4d05835b4523" --000000000000884f4d05835b4523 Content-Type: text/plain; charset="UTF-8" Hey, Skef! Will do. Thanks for looking into it. Best, Abraham On Tue, Mar 5, 2019 at 9:15 AM Skef Iterum <[email protected]> wrote: > If you file an issue on github with easy steps to reproduce I'm likely to > look at it. I've been in the python code recently. > > Skef > On 3/5/19 8:06 AM, Abraham Lee wrote: > > Devs, > > I'm discovering more and more all the time how powerful the python > interface is. So, to anyone and everyone developing it, thank you! I've > been able to do some wonderful things with it both in standalone scripts > and in plugins while working in the GUI. > > The other day I ran into a crash while attempting to merge an on-curve > point. Let's say I create a contour in the following way: > > import fontforge, psMat > cntr = fontforge.contour() > cntr.moveTo(0, 100) > cntr.lineTo(100, 100) > cntr.cubicTo(120, 100, 140, 80, 140, 60) > cntr.cubicTo(140, 30,100, 0, 0, 0) > print cntr > > ... which shows this: > <Contour(cubic) > (0,100) on > (100,100) on > (120,100) off > (140,80) off > (140,60) on > (140,30) off > (100,0) off > (0,0) on > > > > There are several on-curve points with this simple contour. Now, let's say > the contour is transformed (e.g. skewed) and the points that were > previously extrema are no longer: > > ang = 8 # degrees, clockwise > angrad = ang*3.14159/180 > cntr.transform(psMat.skew(angrad)) > print cntr > > ... which shows this now: > <Contour(cubic) > (14.0537,100) on > (114.054,100) on > (134.054,100) off > (151.243,80) off > (148.433,60) on > (144.216,30) off > (100,0) off > (0,0) on > > > > There are no extrema points on the curves anymore. Now, let's add extrema > back onto the contour: > > cntr.addExtrema('all') > print cntr > > ... which now shows: > <Contour(cubic) > (14.0537,100) on > (114.054,100) on > (132.603,100) off > (148.735,82.7958) off > (148.735,64.3438) on > (148.735,62.901) off > (148.636,61.4505) off > (148.433,60) on > (144.216,30) off > (100,0) off > (0,0) on > > > > The on-curve point at (148.735,64.3438) is now the new extrema. I no > longer want the non-extrema on-curve point at (148.433, 60) anymore, so we > attempt to merge it: > > pos = 7 # this is the 0-based position > cntr.merge(pos) > > ... and then the crash happens. I haven't been able to narrow down, at > least on my input-side, what could be causing the full program crash. I > usually can find that I've done something non-obviously wrong with my code, > but this has me stumped. > > There's that problem, and then there's a follow on one. As described in > the docs, "merge" should be able to accept a single integer or a list of > integers. Looking at the source code for the function suggests similarly. > However, when a list (or an array of any kind, like tuple) is supplied, the > function throws an error saying that it accepts only a single integer. > > I searched the repo at the current master branch and also at the snapshot > commit of the current release of FF, but the code seems to be the same that > drives the merge function. So, I'm not sure how to proceed. I can try to > code up my own merge function, but I'd rather not if I can avoid it ;-) > > Any thoughts? > > Best, > Abraham > > > _______________________________________________ > fontforge-devel mailing [email protected]://lists.sourceforge.net/lists/listinfo/fontforge-develhttp://fontforge.10959.n7.nabble.com/Developer-f3.html > > _______________________________________________ > fontforge-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/fontforge-devel > http://fontforge.10959.n7.nabble.com/Developer-f3.html > --000000000000884f4d05835b4523 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr">Hey, Skef!</div><div dir=3D"ltr"><br></di= v><div>Will do. Thanks for looking into it.</div><div><br></div><div>Best,<= /div><div>Abraham</div><br><div class=3D"gmail_quote"><div dir=3D"ltr" clas= s=3D"gmail_attr">On Tue, Mar 5, 2019 at 9:15 AM Skef Iterum <<a href=3D"= mailto:[email protected]">[email protected]</a>> wrote:<br></div><blockquote= class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so= lid rgb(204,204,204);padding-left:1ex"> =20 =20 =20 <div bgcolor=3D"#FFFFFF"> <p>If you file an issue on github with easy steps to reproduce I'm likely to look at it. I've been in the python code recently. <br> </p> <p>Skef<br> </p> <div class=3D"gmail-m_-6749231042638885024moz-cite-prefix">On 3/5/19 8:= 06 AM, Abraham Lee wrote:<br> </div> <blockquote type=3D"cite"> =20 <div dir=3D"ltr"> <div dir=3D"ltr"> <div dir=3D"ltr"> <div dir=3D"ltr"> <div dir=3D"ltr"> <div dir=3D"ltr"> <div dir=3D"ltr">Devs, <div><br> </div> <div>I'm discovering more and more all the time how powerful the python interface is. So, to anyone and everyone developing it, thank you! I've been able to do some wonderful things with it both in standalone scripts and in plugins while working in the GUI.</div> <div><br> </div> <div>The other day I ran into a crash while attempting to merge an on-curve point. Let's say = I create a contour in the following way:</div> <div><br> </div> <div>import fontforge, psMat</div> <div>cntr =3D fontforge.contour()</div> <div>cntr.moveTo(0, 100)</div> <div>cntr.lineTo(100, 100)</div> <div>cntr.cubicTo(120, 100, 140, 80, 140, 60)</div> <div>cntr.cubicTo(140, 30,100, 0, 0, 0)</div> <div>print cntr</div> <div><br> </div> <div>... which shows this:</div> <div><Contour(cubic)</div> <div>=C2=A0 (0,100) on</div> <div>=C2=A0 (100,100) on</div> <div>=C2=A0 (120,100) off</div> <div>=C2=A0 (140,80) off</div> <div>=C2=A0 (140,60) on</div> <div>=C2=A0 (140,30) off</div> <div>=C2=A0 (100,0) off</div> <div>=C2=A0 (0,0) on</div> <div>></div> <div><br> </div> <div>There are several on-curve points with this simple contour. Now, let's say the contour is transformed (e.g. skewed) and the points that were previously extrema are no longer:</div> <div><br> </div> <div>ang =3D 8=C2=A0 # degrees, clockwise</div> <div>angrad =3D ang*3.14159/180</div> <div>cntr.transform(psMat.skew(angrad))</div> <div>print cntr</div> <div><br> </div> <div>... which shows this now:</div> <div> <div><Contour(cubic)</div> <div>=C2=A0 (14.0537,100) on</div> <div>=C2=A0 (114.054,100) on</div> <div>=C2=A0 (134.054,100) off</div> <div>=C2=A0 (151.243,80) off</div> <div>=C2=A0 (148.433,60) on</div> <div>=C2=A0 (144.216,30) off</div> <div>=C2=A0 (100,0) off</div> <div>=C2=A0 (0,0) on</div> <div>></div> </div> <div><br> </div> <div>There are no extrema points on the curves anymore. Now, let's add extrema back onto the contour:</div> <div><br> </div> <div>cntr.addExtrema('all')</div> <div>print cntr</div> <div><br> </div> <div>... which now shows:</div> <div> <div><Contour(cubic)</div> <div>=C2=A0 (14.0537,100) on</div> <div>=C2=A0 (114.054,100) on</div> <div>=C2=A0 (132.603,100) off</div> <div>=C2=A0 (148.735,82.7958) off</div> <div>=C2=A0 (148.735,64.3438) on</div> <div>=C2=A0 (148.735,62.901) off</div> <div>=C2=A0 (148.636,61.4505) off</div> <div>=C2=A0 (148.433,60) on</div> <div>=C2=A0 (144.216,30) off</div> <div>=C2=A0 (100,0) off</div> <div>=C2=A0 (0,0) on</div> <div>></div> </div> <div><br> </div> <div>The on-curve point at (148.735,64.3438) is now the new extrema. I no longer want the non-extrema on-curve point at (148.433, 60) anymore, so we attempt to merge it:</div> <div><br> </div> <div>pos=C2=A0 =3D 7 # this is the 0-based position</di= v> <div>cntr.merge(pos)</div> <div><br> </div> <div>... and then the crash happens. I haven't been able to narrow down, at least on my input-side, what could be causing the full program crash. I usually can find that I've done something non-obviously wrong with my code, but this has me stumped.=C2=A0</div> <div><br> </div> <div>There's that problem, and then there's a f= ollow on one. As described in the docs, "merge" s= hould be able to accept a single integer or a list of integers. Looking at the source code for the function suggests similarly. However, when a list (or an array of any kind, like tuple) is supplied, the function throws an error saying that it accepts only a single integer.</div> <div><br> </div> <div>I searched the repo at the current master branch and also at the snapshot commit of the current release of FF, but the code seems to be the same that drives the merge function. So, I'm not sure how to proceed. I can try to code up my own merge function, but I'd rather not if I can avoid it ;-)<br> </div> <div><br> </div> <div>Any thoughts?</div> <div><br> </div> <div>Best,</div> <div>Abraham</div> </div> </div> </div> </div> </div> </div> </div> <br> <fieldset class=3D"gmail-m_-6749231042638885024mimeAttachmentHeader">= </fieldset> <br> <fieldset class=3D"gmail-m_-6749231042638885024mimeAttachmentHeader">= </fieldset> <pre class=3D"gmail-m_-6749231042638885024moz-quote-pre">____________= ___________________________________ fontforge-devel mailing list <a class=3D"gmail-m_-6749231042638885024moz-txt-link-abbreviated" href=3D"m= ailto:[email protected]" target=3D"_blank">fontforge-de= [email protected]</a> <a class=3D"gmail-m_-6749231042638885024moz-txt-link-freetext" href=3D"http= s://lists.sourceforge.net/lists/listinfo/fontforge-devel" target=3D"_blank"= >https://lists.sourceforge.net/lists/listinfo/fontforge-devel</a> <a class=3D"gmail-m_-6749231042638885024moz-txt-link-freetext" href=3D"http= ://fontforge.10959.n7.nabble.com/Developer-f3.html" target=3D"_blank">http:= //fontforge.10959.n7.nabble.com/Developer-f3.html</a> </pre> </blockquote> </div> _______________________________________________<br> fontforge-devel mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">= [email protected]</a><br> <a href=3D"https://lists.sourceforge.net/lists/listinfo/fontforge-devel" re= l=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/list= info/fontforge-devel</a><br> <a href=3D"http://fontforge.10959.n7.nabble.com/Developer-f3.html" rel=3D"n= oreferrer" target=3D"_blank">http://fontforge.10959.n7.nabble.com/Developer= -f3.html</a><br> </blockquote></div></div> --000000000000884f4d05835b4523-- --===============3643673904491823561== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============3643673904491823561== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ fontforge-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fontforge-devel http://fontforge.10959.n7.nabble.com/Developer-f3.html --===============3643673904491823561==--