Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why this script failed to generate ttf for oxygen-fonts? #1756

Closed
pnemade opened this issue Sep 29, 2014 · 22 comments · Fixed by #1765
Closed

why this script failed to generate ttf for oxygen-fonts? #1756

pnemade opened this issue Sep 29, 2014 · 22 comments · Fixed by #1765
Assignees

Comments

@pnemade
Copy link
Contributor

pnemade commented Sep 29, 2014

Please have a look at this repository
http://quickgit.kde.org/?p=oxygen-fonts.git&a=tree&hb=2be96834c4ef99b0470eb605fbe9ed0211b1d6a0&h=2092b587149fbdc6737d011b8cab6a7cf58c6b28

if above does not look correctly then I mean v5.0.2 version. The script generate-ttf.pe fails to generate sfd to ttf and segfaults.

Can someone look and provide information what can be wrong? Here is quick error on my machine

$ ./generate-ttf.pe src/OxygenMono-Regular.sfd
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
with many parts BSD http://fontforge.org/license.html. Please read LICENSE.
Based on sources from 04:56 UTC 24-Sep-2014-ML-D.
Based on source from git with hash:
strippedname:/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd
Segmentation fault (core dumped)

@adrientetar
Copy link
Member

If you want to post a stacktrace, here's a guide: http://designwithfontforge.com/en-US/When_Things_Go_Wrong_With_Fontforge_Itself.html.

@tshinnic
Copy link
Contributor

Pickled data too sour?

    tom@tlsu144a:~/study/fonts/FF/oxygen-fonts$ 
    fontforge -script generate-ttf.pe oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd
    Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
     License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
     with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
     Based on sources from 14:19 CDT 29-Aug-2014-ML-D.
     Based on source from git with hash:e6745b193724da53c59c751f46834dcc0228d2f3
    strippedname:/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd
    Segmentation fault (core dumped)


    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
    Core was generated by `fontforge -script generate-ttf.pe oxygen-fonts/mono-400/src/OxygenMono-Regular.'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x00007faadffe543b in PyImport_GetModuleDict ()
       from /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
    (gdb) bt
    #0  0x00007faadffe543b in PyImport_GetModuleDict ()
       from /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
    #1  0x00007faadfe3837c in PyImport_AddModuleObject ()
       from /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
    #2  0x00007faadfe3843a in PyImport_AddModule ()
       from /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
    #3  0x00007faadfff8138 in PyRun_SimpleStringFlags ()
       from /usr/lib/x86_64-linux-gnu/libpython3.4m.so.1.0
    #4  0x00007faadf35aa02 in PyFF_PicklerInit () at python.c:17839
    #5  0x00007faadf35abb2 in PyFF_UnPickleMeToObjects (
        str=0x1a57d60 "(dp1\nS'com.typemytype.robofont.foreground.layerStrokeColor'\np2\n(F0.5\nF0\nF0.5\nF0.6", '9' <repeats 15 times>, "6\ntp3\nsS'com.typemytype.robofont.b.layerStrokeColor'\np4\n(F0.5\nF1\nF0\nF0.6", '9' <repeats 15 times>, "6\ntp5\nsS'com.type"...) at python.c:17873
    #6  0x00007faadf3c024a in SFDUnPickle (sfd=0x1a57140, python_data_has_lists=0)
        at sfd.c:1323
    #7  0x00007faadf3e0f69 in SFD_GetFont (sfd=0x1a57140, cidmaster=0x0,
        tok=0x7fff0fcd4130 "PickledData:", fromdir=0,
        dirname=0x1a56460 "/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", sfdversion=3) at sfd.c:8446
    #8  0x00007faadf3e262c in SFD_Read (
        filename=0x1a56460 "/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", sfd=0x1a57140, fromdir=0) at sfd.c:8716
    #9  0x00007faadf3e2844 in _SFDRead (
        filename=0x1a56460 "/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", sfd=0x1a57140) at sfd.c:8749
    #10 0x00007faadf403da0 in _ReadSplineFont (file=0x1a57140,
        filename=0x1a56400 "/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", openflags=(unknown: 0)) at splinefont.c:1132
    #11 0x00007faadf404dad in ReadSplineFont (
        filename=0x1a56400 "/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", openflags=(unknown: 0)) at splinefont.c:1269
    #12 0x00007faadf405079 in LoadSplineFont (
        filename=0x1a56380 "oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd",
        openflags=(unknown: 0)) at splinefont.c:1327
    #13 0x00007faadf3692d6 in bOpen (c=0x7fff0fcd4f20) at scripting.c:1811



      42 MarkAttachClasses: 1
      43 DEI: 91125
      44 LangName: 1033 "" "" "" "newtypography : Oxygen Mono" "" "Version 0.2" "" "
      45 PickledData: "(dp1
      46 S'com.typemytype.robofont.foreground.layerStrokeColor'
      47 p2

     847 S'threesuperior'
     848 S'twosuperior'
     849 tp30
     850 s."
     851 Encoding: Custom
     852 UnicodeInterp: none

There were 70+ "PickledData:" sections in the SFD file. When those lines were experimentally removed, the SFD could be read and TTF file generated. Something's wrong with eating those pickles.... (I'm out of time to investigate more at the moment)

@pnemade
Copy link
Contributor Author

pnemade commented Sep 29, 2014

(gdb) r generate-ttf.pe src/OxygenMono-Regular.sfd 
Starting program: /usr/bin/fontforge generate-ttf.pe src/OxygenMono-Regular.sfd
Got object file from memory but can't read symbols: File truncated.
Missing separate debuginfos, use: debuginfo-install glibc-2.20-4.fc21.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Based on sources from 04:56 UTC 24-Sep-2014-ML-D.
 Based on source from git with hash:
strippedname:/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd

Program received signal SIGSEGV, Segmentation fault.
0x00000038196f27cb in PyImport_GetModuleDict () at /usr/src/debug/Python-2.7.8/Python/import.c:395
395     PyInterpreterState *interp = PyThreadState_GET()->interp;
(gdb) bt
#0  0x00000038196f27cb in PyImport_GetModuleDict () at /usr/src/debug/Python-2.7.8/Python/import.c:395
#1  0x00000038196f2f1c in PyImport_AddModule (name=name@entry=0x381973e289 "__main__") at /usr/src/debug/Python-2.7.8/Python/import.c:634
#2  0x00000038196ff0f8 in PyRun_SimpleStringFlags (command=command@entry=0x381834fc68 "import cPickle;\nimport __FontForge_Internals___;\n__FontForge_Internals___.initPickles(cPickle.dumps,cPickle.loads);", flags=flags@entry=0x0) at /usr/src/debug/Python-2.7.8/Python/pythonrun.c:985
#3  0x00000038181c978e in PyFF_UnPickleMeToObjects () at python.c:17834
#4  0x00000038181c978e in PyFF_UnPickleMeToObjects (str=0x67fe10 "(dp1\nS'com.typemytype.robofont.foreground.layerStrokeColor'\np2\n(F0.5\nF0\nF0.5\nF0.6", '9' <repeats 15 times>, "6\ntp3\nsS'com.typemytype.robofont.b.layerStrokeColor'\np4\n(F0.5\nF1\nF0\nF0.6", '9' <repeats 15 times>, "6\ntp5\nsS'com.type"...) at python.c:17868
#5  0x000000381809705a in SFDUnPickle (sfd=sfd@entry=0x67f210, python_data_has_lists=0) at sfd.c:1323
#6  0x0000003818224488 in SFD_GetFont (sfd=sfd@entry=0x67f210, cidmaster=cidmaster@entry=0x0, tok=<optimized out>, 
    tok@entry=0x7fffffffa440 "PickledData:", fromdir=fromdir@entry=0, dirname=dirname@entry=0x67ef20 "/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", sfdversion=<optimized out>) at sfd.c:8446
#7  0x0000003818224e57 in SFD_Read (filename=filename@entry=0x67ef20 "/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", sfd=sfd@entry=0x67f210, fromdir=fromdir@entry=0) at sfd.c:8716
#8  0x0000003818225067 in _SFDRead (filename=filename@entry=0x67ef20 "/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", sfd=sfd@entry=0x67f210)
    at sfd.c:8749
#9  0x000000381823c925 in _ReadSplineFont (file=0x67f210, file@entry=0x0, filename=<optimized out>, 
    filename@entry=0x67eec0 "/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", openflags=openflags@entry=(unknown: 0)) at splinefont.c:1132
#10 0x000000381823d00c in ReadSplineFont (filename=filename@entry=0x67eec0 "/home/parag/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd", openflags=openflags@entry=(unknown: 0)) at splinefont.c:1269
#11 0x000000381823d22d in LoadSplineFont (filename=filename@entry=0x67ebd0 "src/OxygenMono-Regular.sfd", openflags=openflags@entry=(unknown: 0)) at splinefont.c:1327
#12 0x00000038181e76cf in bOpen (c=0x7fffffffb110) at scripting.c:1811
#13 0x00000038181ea04c in docall (c=c@entry=0x7fffffffb8e0, name=name@entry=0x7fffffffb380 "Open", val=val@entry=0x7fffffffb790) at scripting.c:9265
#14 0x00000038181ea6ce in handlename (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9357
#15 0x00000038181eba02 in term (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9600
#16 0x00000038181ebbf5 in mul (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9745
#17 0x00000038181ebe09 in add (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9790
#18 0x00000038181ec189 in comp (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9865
#19 0x00000038181ec3fb in _and (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9908
#20 0x00000038181ec59d in assign (val=0x7fffffffb790, c=0x7fffffffb8e0) at scripting.c:9939
#21 0x00000038181ec59d in assign (c=c@entry=0x7fffffffb8e0, val=val@entry=0x7fffffffb790) at scripting.c:9971
#22 0x00000038181e945c in ff_statement (val=0x7fffffffb790, c=0x7fffffffb8e0) at scripting.c:10049
#23 0x00000038181e945c in ff_statement (c=c@entry=0x7fffffffb8e0) at scripting.c:10258
#24 0x00000038181ecf67 in ProcessNativeScript (argc=argc@entry=3, argv=argv@entry=0x7fffffffddf8, script=script@entry=0x0) at scripting.c:10404
#25 0x00000038181ed9e2 in CheckIsScript (argv=0x7fffffffddf8, argc=3) at scripting.c:10496
#26 0x00000038181ed9e2 in CheckIsScript (argc=argc@entry=3, argv=argv@entry=0x7fffffffddf8) at scripting.c:10533
#27 0x00000038177c21f8 in fontforge_main (argc=3, argv=0x7fffffffddf8) at startui.c:1041
#28 0x000000380e61ffe0 in __libc_start_main () at /lib64/libc.so.6
#29 0x00000000004008ee in _start ()
(gdb) 

@ghost
Copy link

ghost commented Sep 29, 2014

On Mon, 29 Sep 2014, Parag Nemade wrote:

Can someone look and provide information what can be wrong? Here is quick
error on my machine

$ ./generate-ttf.pe src/OxygenMono-Regular.sfd

Your script requires two command-line parameters and you appear to have
given it only one. Of course that should produce a more graceful result
than a segfault, but I think that's the origin of the problem.

Matthew Skala
mskala@ansuz.sooke.bc.ca People before principles.
http://ansuz.sooke.bc.ca/

@tshinnic
Copy link
Contributor

It is interesting that this crashes using both Python 2.7.8 (as seen in pnemade's dump) and using Python 3.4.0 (as seen in my dump).

Oh, and I put one PickledData: section (a simple small one) back into a character definition in a test SFD file and it crashed again.

I'm tempted to grab one of the pickled strings and see if I can unpickle in a test Python script. Hmmm...

@tshinnic
Copy link
Contributor

Hmm, no, the pickled data works just fine in isolated Python scripts. Tried with both Python 2.7.6 and 3.4.0:

      samples = (
        b"(dp1\nS'com.typemytype.robofont.layerData'\np2\n(dp3\ns.",
        b"(dp1\nS'com.typemytype.robofont.foreground.layerStrokeColor'\np2\n(F0.5\nF0\nF....
      )
      for sample in samples:
        thingy1 = pickle.loads(sample)
        print("    Result: '{}'".format(thingy1))
      Doing  pickle.loads(sample) ...
      After pickle.loads(sample) ...
        Result: '{'com.typemytype.robofont.layerData': {}}'
      Doing  pickle.loads(sample) ...
      After pickle.loads(sample) ...
        Result: '{'com.typemytype.robofont.foreground.layerStrokeColor': (0.5, 0.0,

Using the UI I read the original font file and then wrote to a copy using "SaveAs...". The form of the pickled data did change a bit after passing through FontForge UI, but when using that new SFD copy with the scripted Open() it crashed again.

@ghost
Copy link

ghost commented Sep 30, 2014

SFDUnPickle calls nlgetc, but SFDUnPickle and nlgetc each attempt to remove one level of backslash quoting. Only one level was applied by SFDPickleMe, so the data will be corrupted if it literally contains anything that looks like backslash quoting.

We ought to be using UTF7 for this instead of backslashes, as is done with FontLog values. Then each field value would fit on a single line, making scanning easier; and the file format would be more consistent.

@pnemade
Copy link
Contributor Author

pnemade commented Sep 30, 2014

I am not familiar with fontforge coding. Can someone able to confirm if its a fontforge issue or font sfd issue? I created ttf->sfd using fontforge UI and then used script as given above and it worked!!

Btw anyone knows if there is any scripting available that will convert ttf to sfd?

Thanks.

@tshinnic
Copy link
Contributor

@pnemade, it is okay, some of the above messages are where we are discussing what is going on inside FontForge. It is a FontForge issue.

Yes, when you wrote an .sfd file from FontForge, it did not contain any of that extra PickledData: information mentioned above, and so it worked just fine. Apparently the RoboFont (?) program used this FontForge feature when it wrote those .sfd files you are having trouble with.

Later today I'll see if I can come up with a simple awk/sed/Perl script to remove the PickledData: sections from those Oxygen .sfd files, so you can use them while we try to figure out how to fix this.

Converting any font file (like TTF) into the intermediate SFD file form can be done just like that script you were using, except instead of using the Generate() function you use Save(), e.g.

fontforge -script ttf_sfd.pe test.ttf test.sfd
cat ttf_sfd.pe
#!/usr/bin/fontforge
Open($1);
Save($2);

There are lots of things you can do with scripting and functions

@tshinnic
Copy link
Contributor

@pnemade, for now, use this on .sfd files that hit this bug.

perl -wne 'print unless /^PickledData:/.../.*"$/;' OxygenMono-Regular.sfd >OxygenMono-Regular.cleaned.sfd

This removes just the PickledData: sections that are causing us trouble with this bug. This workaround will get you working again, until we can figure out the fix.

@pnemade
Copy link
Contributor Author

pnemade commented Sep 30, 2014

@tshinnic thanks 👍

@tshinnic
Copy link
Contributor

tshinnic commented Oct 2, 2014

Finally remembered to retry with the 2012 packaged FF and that doesn't fail.

Debugged some more, and for me (as above) it is actually dying trying to call Python API PyRun_SimpleString() from fontforge/python.c PyFF_PicklerInit(). I never even get to the 'unpickle' code!

But... I use Python 3... I'm going to rebuild recent master and build using Python 2, and then retest.

BTW: Tried to find the shortest simplest Python pickled string, and "(t." unpickles into an empty tuple. No magic characters or embedded control characters!

@tshinnic
Copy link
Contributor

tshinnic commented Oct 2, 2014

So recent source dies built with Python 2 also, in PyFF_PicklerInit() also.

Then brilliant idea! Change the native script into equivalent Python script. That way we know that Python has been fully initialized. And that script runs just fine.

                                                 vv
  fontforge -quiet          -script generate-ttf.pe ./oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd test.ttf
  strippedname:/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd
  Segmentation fault (core dumped)

                                                 vv
  fontforge -quiet          -script generate-ttf.py ./oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd test.ttf
  strippedname:/home/tom/study/fonts/FF/oxygen-fonts/oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd
      -rw-rw-r-- 1 tom tom 21756 Oct  2 07:32 test.ttf

                   vvvvvvvv                      vv
  fontforge -quiet -lang=ff -script generate-ttf.py ./oxygen-fonts/mono-400/src/OxygenMono-Regular.sfd test.ttf
  generate-ttf.py line: 2 Undefined variable: import

The Python initialization when not running Python scripts is broken somehow.

Note mention in #1713 and almost direct description in #1687, which inspired the third test above, which has me rolling my eyes...

@adrientetar
Copy link
Member

Finally remembered to retry with the 2012 packaged FF and that doesn't fail.

We should add unit tests when fixing scripting bugs.

@tshinnic
Copy link
Contributor

tshinnic commented Oct 2, 2014

Haha! I started weeks ago, got up to 3K+ lines on one small related set of
topics, and got seriously bogged down. It's why sometimes it will take me
a couple days instead of one to work through a set of fixes - I'm actually
verifying what is / is not broken by exercising code from scripts.

But one area where I got bogged down was trying to figure out if the
existing Python test frameworks could help organize added FF tests. Once
you start trying to do lots of tests it gets ugly real fast.

But for sure this has been a real deficiency - testing. Add in the
missing identified collection of the many type of font files and things
will sneak up on us. ( e.g., .ttc)

Coming from the Perl world it is surprizing. It is almost a religion there

  • every package has extensive tests you can invoke at any point.
    On Oct 2, 2014 9:41 AM, "Adrien Tétar" notifications@github.com wrote:

Finally remembered to retry with the 2012 packaged FF and that doesn't
fail.

We should add unit tests when fixing scripting bugs.


Reply to this email directly or view it on GitHub
#1756 (comment)
.

@davelab6
Copy link
Member

davelab6 commented Oct 3, 2014

George Williams made FF as a fun retirement project, and writing tests wasn't fun for him.

@adrientetar
Copy link
Member

Segfaults are more enjoyable I reckon. ;)

@tshinnic
Copy link
Contributor

tshinnic commented Oct 3, 2014

@davelab6, the starting nature of the project, and the generous motivation to provide something 'useful' to other people where there was a gap, has been understood. And appreciated! So much code and so many features!

However, there might also have been a generational difference? I know that when I began coding, stuff either worked or it didn't. When it worked (at that moment) and processed the known data (of that moment) it was releasable. Over the decades, though, that stance became... less satisfactory. Nervousness over the likelihood that new work was breaking old was 'rewarded' by example after example of that happening. Own extra work to "avoid future problems" was rewarded differently, in positive ways. :)

So it has become an article of belief for me that code should have tests of at least some small degree of thoroughness, giving you some degree of comfort upon changing code. And that the strange new data files that showed the need for new code or fixes should somehow be retained for those needed tests.

And so perhaps also we see a change in needs simply because the project has broadened out away from the one man organization? Which I see as making it even more desirable that other people have some comfort that person XYZ wasn't just having a really bad day when they dropped some code in.

Heck, I haven't submitted half the changes worked out that seem warranted by things like the Coverity reports, because I have no way to test those changes. When I found that mind-boggling PDF parsing table bug in the Coverity report, it took a lot of work to verify - to find suitable data files. And since there weren't "before results" to check against, I still don't know if correctly fixing that bug might still not break someone's prior usage!

Anyway, I've already apologized privately to @adrientetar for the tone of the above. Perhaps I can ask for forbearance from all, when I start submitting some really ugly test code? I know I scared @frank-trampe months ago when I went Rambo trying to test the overlap/simplify code. :-)

@tshinnic tshinnic self-assigned this Oct 4, 2014
@davelab6
Copy link
Member

davelab6 commented Oct 4, 2014

I am reaching the conclusion i should help make a release of FF and abandon
it. It's not maintainable or extensible enough. 6 monyhs ago i thought
UfoJS and opentype.js are a better platform for new development, but maybe
the python stuff is better... Will see how Adrien fares ;)

@pnemade
Copy link
Contributor Author

pnemade commented Oct 4, 2014

No doubt FF python scripts have become very useful resource as they provide a way to build a binary font from sfd file. This is very useful for distributions like Fedora which like to promote to build a font package from source font file if its available in upstream tarball.

@tshinnic
Copy link
Contributor

tshinnic commented Oct 4, 2014

@davelab6
As always, it is a question of suitability. If your needs are narrow enough, fit into the unique vision of a particular package, and will never grow outside the range of what the package has to offer (or is willing to change to offer), you're good to go.

For instance, take pdf.js from the Mozilla people, which I again used as reference material just lately. It's new, modern, developed with good methods and technologies, has all those test thingies I rant about :) , has both own development people and outside contributors, and is widely used and thus is well-exercised. It is marvelous!

Unless you wanted to do more than view PDF files. If you want to interact with them, modify and rewrite PDF files, that's too bad. Out of scope. All that beauty, 'unusable'. Other packages can update PDF files, but they don't have the correctness of pdf.js.

In my case Inkscape was similarly marvelous. It allowed me to explore the subject area and experiment with ideas. I familiarized myself with concepts and manipulations of shapes. It served well as a test platform. It would be enough for most people.

But I found I needed more. I needed to mechanically transform hundreds of shapes. I had to export a few thousand SVG-generated glyphs into a variety of exported font files. And use ligatures/mark2base or some such on ~800 of those glyphs, which would be much more pleasurable if done using scripts. And Inkscape glyph/curve simplification stunk so badly.

After checking out a number of packages (more than 5) and some web sites that purported to handle SVG to font translation/transformations, and submitting bug reports and fixes to a few of those, I gave up on those incomplete packages and landed at FF.

Weight has advantages and disadvantages. FF has depth in a number of areas. However it is hard to pick up and move in new directions...

Breadth has advantages and disadvantages. FF tries to provide so many possibilities it has something to offer to everyone. But pulling it out from the bushes/trees into the clear light needs a tractor...

A large awkward aged source package resulting from many spurts of disconnected activity, trying to bridge several functional domains, is a sight to behold. But as an all-around tool for things font-related it seems the better fit for the audience.

Small package, more lacks. Huge package, more cracks. But which is more likely to be of service to more people?

(Oh, and one-line fix for this issue coming next)

tshinnic added a commit to tshinnic/fontforge that referenced this issue Oct 4, 2014
This change fixes the issue fontforge#1756 "why this script failed to generate
ttf for oxygen-fonts?"

There are a number of ways that embedded Python is used from FontForge,
such as script files, source from STDIN, entered via UI dialog, and
even via a socket (!?).  And also it can be used as part of a convenient
way to encode/decode complex object data through SFD files, in font and
glyph `PickledData:` sections.

When native scripts were used with FontForge, the embedded Python was not
initialized for running, because it wasn't going to be used. :)  Except,
if the script was opening SFD files that happened to contain `PickledData:`
sections, fontforge/sfd.c `SFD_GetFont()` and `SFDGetChar()` routines
would call `SFDUnPickle()` and thence `PyFF_UnPickleMeToObjects()`.
Trying to use the Python pickle/unpickle APIs without having initialized
Python would then crash.

This change simply adds a call to `FontForge_InitializeEmbeddedPython()`
to the initialization of the FF pickle/unpickle routines.  It does not
address when the now needed Python cleanup at program end should happen.

This change should logically also address part of issue fontforge#1687, but it
seems that the problem there is not completely covered by this fix.

Tested with both Python 2 and 3, with native and Python scripts, and
using the UI.
tshinnic added a commit to tshinnic/fontforge that referenced this issue Oct 4, 2014
This change fixes the issue fontforge#1756 "why this script failed to generate
ttf for oxygen-fonts?"

There are a number of ways that embedded Python is used from FontForge,
such as script files, source from STDIN, entered via UI dialog, and
even via a socket (!?).  And also it can be used as part of a convenient
way to encode/decode complex object data through SFD files, in font and
glyph `PickledData:` sections.

When native scripts were used with FontForge, the embedded Python was not
initialized for running, because it wasn't going to be used. :)  Except,
if the script was opening SFD files that happened to contain `PickledData:`
sections, fontforge/sfd.c `SFD_GetFont()` and `SFDGetChar()` routines
would call `SFDUnPickle()` and thence `PyFF_UnPickleMeToObjects()`.
Trying to use the Python pickle/unpickle APIs without having initialized
Python would then crash.

This change simply adds a call to `FontForge_InitializeEmbeddedPython()`
to the initialization of the FF pickle/unpickle routines.  It does not
address when the now needed Python cleanup at program end should happen.

This change should logically also address part of issue fontforge#1687, but it
seems that the problem there is not completely covered by this fix.

Tested with both Python 2 and 3, with native and Python scripts, and
using the UI.
tshinnic added a commit to tshinnic/fontforge that referenced this issue Oct 5, 2014
Noticed redundant #ifndef's during investigation of fontforge#1756.  Since almost
all code within fontforge/python.c is surrounded by `#ifndef _NO_PYTHON`
it was strange to see individual bits of code surrounded by additional
such `#ifndefs`

Also, one copy-n-paste was one line too low, with an `exit(0)` before it.

And just happened to notice an extra unneeded declaration in
fontforgeexe/startui.c  Do modern C compilers just drop those?  And wow,
Coverity didn't complain either.
@davelab6
Copy link
Member

davelab6 commented Oct 5, 2014

Eloquent as always Thomas :) My point remains, that I think the lacks are
easier to solve than the cracks.
On 4 Oct 2014 19:25, "tshinnic" notifications@github.com wrote:

@davelab6 https://github.com/davelab6
As always, it is a question of suitability. If your needs are narrow
enough, fit into the unique vision of a particular package, and will never
grow outside the range of what the package has to offer (or is willing to
change to offer), you're good to go.

For instance, take pdf.js from the Mozilla people, which I again used as
reference material just lately. It's new, modern, developed with good
methods and technologies, has all those test thingies I rant about :) , has
both own development people and outside contributors, and is widely used
and thus is well-exercised. It is marvelous!

Unless you wanted to do more than view PDF files. If you want to interact
with them, modify and rewrite PDF files, that's too bad. Out of scope. All
that beauty, 'unusable'. Other packages can update PDF files, but they
don't have the correctness of pdf.js.

In my case Inkscape was similarly marvelous. It allowed me to explore the
subject area and experiment with ideas. I familiarized myself with concepts
and manipulations of shapes. It served well as a test platform. It would be
enough for most people.

But I found I needed more. I needed to mechanically transform hundreds of
shapes. I had to export a few thousand SVG-generated glyphs into a variety
of exported font files. And use ligatures/mark2base or some such on ~800 of
those glyphs, which would be much more pleasurable if done using scripts.
And Inkscape glyph/curve simplification stunk so badly.

After checking out a number of packages (more than 5) and some web sites
that purported to handle SVG to font translation/transformations, and
submitting bug reports and fixes to a few of those, I gave up on those
incomplete packages and landed at FF.

Weight has advantages and disadvantages. FF has depth in a number of
areas. However it is hard to pick up and move in new directions...

Breadth has advantages and disadvantages. FF tries to provide so many
possibilities it has something to offer to everyone. But pulling it out
from the bushes/trees into the clear light needs a tractor...

A large awkward aged source package resulting from many spurts of
disconnected activity, trying to bridge several functional domains, is a
sight to behold. But as an all-around tool for things font-related it seems
the better fit for the audience.

Small package, more lacks. Huge package, more cracks. But which is more
likely to be of service to more people?

(Oh, and one-line fix for this issue coming next)


Reply to this email directly or view it on GitHub
#1756 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants