python vector graphic library supporting opentype formats

Flavio Curella
16.May.2006 2.14pm
Flavio Curella's picture

I’m looking for a python vector graphic framework/library/module which supports opentype fonts.
I cant understand if ReportLab does it, neither PIDDLE. Maybe doesn’t exist, yet?



Miguel Sousa
16.May.2006 2.24pm
Miguel Sousa's picture

What exactly do you want it for?
Have you looked at RoboFab or at the Adobe FDK?


Flavio Curella
16.May.2006 2.34pm
Flavio Curella's picture

yes, but I don’t need a library for creating fonts, just a graphic library which can import them.
Specifically, what I’m trying to do is a Python script which can generate many variations of the same poster (or flyer, or business-cards, or whatever). Something like Fifteen’s posters.


Miguel Sousa
16.May.2006 2.55pm
Miguel Sousa's picture

Well, then ask LettError. I think they were the ones who did it for FontShop.


andyclymer
16.May.2006 3.10pm
andyclymer's picture

Flavio, if you’re on the Mac you might be interested in playing around with DrawBot, it’s a fun tool for drawing with Python and it has OTF support (but no feature support). Program the poster in DrawBot with whatever amount of Pythonic variation you want and then you can export each result as a PDF.


andyclymer
16.May.2006 3.14pm
andyclymer's picture

Or you could dig deep into CoreGraphics (though still Mac-centric)


gferreira
17.May.2006 7.24am
gferreira's picture

another alternative would be Scribus, the free software/open-source alternative to indesign/quark. it has a python scripting palette and can export pdfs, but doesn’t offer support to opentype features (yet).

cheers,
- gustavo.


Flavio Curella
17.May.2006 9.18am
Flavio Curella's picture

@andy:
DrawBot seems very cool, but unlucky it doesn’t work on my mac (tiger), it quits silently :(( (tiger: it quits silently).
CoreGraphics: I was searching out there while it seems all I need is already in my box :).

@gustavo: I’v tried to run scribus, after installing Fink, but doesn’t works.

@adobe: why Illustrator has not a python API? :P


twardoch
17.May.2006 4.44pm
twardoch's picture

You can automate InDesign and Illustrator on Windows from Python (using COM automation and the Python win32all package).

A.


Miguel Sousa
28.Jun.2006 2.25pm
Miguel Sousa's picture

I’ve just returned from the InDesign Conference Half-Day Tutorial: Automating Page Layout with InDesign Scripting talk given by Olav Martin Kvern, and I must say that it was simply brilliant.

As I understood, it is possible to script *any* task in InDesign (CS2), which is quite remarkable. His JavaScript demos were very insightful and easy to follow. (Like Python, JavaScript is an object-oriented language, so the two are quite similar in may aspects). The ExtendScript Toolkit application (that comes with the CS2 Suite) also makes scripting much simple.

I was simply amazed how one can enhance InDesign’s capabilities and batch process repetitive tasks quite easily. As anyone ever wished Photoshop’s Contact Sheets or Illustrator’s Crop Marks inside InDesign? Well, it’s actually all possible! Simply download these ready-made scripts and place them in [InDy folder]/Presets/Scripts/. Then it’s just a matter of bringing up the ’Scripts’ palette (Window->Automation->Scripts) and start clicking**. Definitely worth trying!

Also worth following:
http://jsid.blogspot.com/
http://www.indesignsecrets.com/

** The script “ImageCatalog.jsx” does the Photoshop-like function, and “CropMarks.jsx” the Illustrator-like one.


k.l.
28.Jun.2006 3.52pm
k.l.'s picture

In addition, there are some pretty useful ’third-party’ scripts.
Definitely I like Python more. Maybe the type department can convince the ID department that Python is worth being supported {natively}* too?  ;-)
Btw, the scripting reference mentions one OT feature which can be addressed by scripting but not by the UI. (Was it hist? Forgot which one, not at home yet to check.)

Big ’but’: Despite of all nice things that scripting allows for, some automation should be available to non-scripters too. Like the data merge function which I read about only last week, though maybe a bit more powerful than it is. One cannot expect that soon every designer will find the time to learn JavaScript (or Python). I say this with ID as well as FLS in mind.

Karsten

* {edit: To my understanding, scripting InDesign in Python is kind of an add-on, which requires different solutions on Win and Mac (here it’s kind of Python ’clothes’ around AppleScript), and such Python scripts are not altogether platform compatible — which I would consider a must for a cross-platform application like InDesign.}


Miguel Sousa
28.Jun.2006 5.05pm
Miguel Sousa's picture

> Maybe the type department can convince the ID department that Python is worth being supported {natively}* too? ;-)

I asked Olav Kvern about it. He said that the commitment is to support each platform’s native scripting language — AppleScript/Mac, VBScript/Windows — and one cross-platform language (JavaScript). Nonetheless, his opinion is that more languages should be supported, rather than less. His goal is to allow people to script in whichever language they’re more comfortable with. So, stay tuned :)

> Btw, the scripting reference mentions one OT feature which can be addressed by scripting but not by the UI.

This one, I believe:
http://partners.adobe.com/public/developer/opentype/index_tag6.html#hlig

> Big ‘but’: Despite of all nice things that scripting allows for, some automation should be available to non-scripters too.

Well, that’s debatable. We still don’t have real artificial intelligence, or computers that can read the ideas we have on our minds and simply execute them, so people will still have to do some of the work. The way things are made available (documentation, samples, drag-and-drop, double-clicking, code hinting, etc) effectively simplify a lot of the stuff, even for ’native’ non-scripters.

I just think that people relate the word ’scripting’ to something that only computer scientists can do. While that was very true some time ago, nowadays things are much much simpler. People just haven’t got around to become aware of that, and to realise that a simple 5-line script, for example, can have a big impact on their daily work.

Edit:
Hundreds of free scripts here http://share.studio.adobe.com/axBrowseSubmit.asp?t=54


twardoch
28.Jun.2006 5.29pm
twardoch's picture

I’m glad to inform you that the Python Imaging Library version 1.1.6b1 now correctly supports Unicode-compatible text rendering using Type 1, TrueType and OpenType fonts. You cannot access OpenType Layout features, just plain Unicode codepoints, and of course you can only render bitmaps, not vectors. But it’s quite powerful and works really nice.

I’ve worked with the library’s author Fredrik Lundh on a fix of a problem that causes PIL to crash on quite many fonts. The good news is that recently released version 1.1.6b1 does not have the problem anymore!

You can get the newest build of PIL at:
http://effbot.org/zone/pil-changes-116.htm

Regards,
Adam


k.l.
29.Jun.2006 9.37am
k.l.'s picture

Miguel Sousa wrote:
We still don’t have real artificial intelligence, or computers that can read the ideas we have on our minds and simply execute them, so people will still have to do some of the work. The way things are made available (documentation, samples, drag-and-drop, double-clicking, code hinting, etc) effectively simplify a lot of the stuff, even for ‘native’ non-scripters.
I just think that people relate the word ‘scripting’ to something that only computer scientists can do. While that was very true some time ago, nowadays things are much much simpler. People just haven’t got around to become aware of that, and to realise that a simple 5-line script, for example, can have a big impact on their daily work.

Oh, I don’t expect any intelligence from the applications’ side!

Yet, one has to understand how scripting is supposed to work. On two levels, the scripting language, and the application’s own peculiarities. (InDesign example for the latter: deal with script UI and defaults in units other than inch/point.) If it just were: grab some elements and copy/paste, this would be nice. But, despite some great sources, this is not really possible.

One obstacle may indeed be designers’ fear of scripting. Maybe fear of working systematically, too?  ;-)

Karsten


Miguel Sousa
29.Jun.2006 12.18pm
Miguel Sousa's picture

> (InDesign example for the latter: deal with script UI and defaults in units other than inch/point.) If it just were: grab some elements and copy/paste, this would be nice. But, despite some great sources, this is not really possible.

I’m sorry, but I don’t understand your point here.

BTW, shall we start our own thread? We’re deviating quite a lot from the initial title.