Python-fontforge is definitely a godsend
After the Robothon, and being very impressed with the power of Robofab and its
associated toys, i was looking for a similar toolkit for GNU/Linux systems.
Didn’t have to look very hard — actually, only had to look back: i had dabbled
with the **python-fontforge library** some months ago while building
[Lettersoup][ls].
The fontforge Python module is a beautiful hidden treasure in the turf of FLOSS
typography. Going along with George Williams’s characteristic [subtlety and low
profile][gw], it’s hard to find any mention of it anywhere, even inside the
free software press.
Given the excitement surrounding Robofab, it’s only fitting that the FLOSS
typography camp takes the time to rear its head towards python-fontforge.
Actually, there’s a few reasons for it to be of interest to anyone remotely
interested in coding type, even those who are used to FontLab for that; here’s
a few reasons why:
* It snugly ties the loose ends to form a truly **free, non-proprietary
toolchain** for type design work. The Fontforge application is already a
wonderful and complete editor. With python-fontforge, scripting is no longer an
exclusive of FontLab.
* Unlike Python scripting in FontLab, scripts written using the fontforge
module can be run **independently of the GUI application**. No dialogues, no
drop-down menus, no chrome in the way — just as scripting should be.
* The **[documentation][doc]** is dense, packed into one big HTML page, but
very rich and complete; if one knows what’s needed but can’t find the right
command, it’s surely in there (and if not, the [fontforge-devel][ml] mailing
list will be quick to enlighten you).
* It’s totally ready to work with **Spiro splines**, a wonderful alternative to
bézier curves to design type and lots of other beautiful shapes. If you haven’t
heard of them, you [totally need to][spiro]. I mean, right now.
* There’s an embrionary **[repository][scripts]** of python-fontforge scripts
over at SourceForge. Hopefully, it will grow as more people notice the power of
this hidden gem.
Some months ago, i hastily made a script to turn a set of SVG files (named
[a-z].svg) into a .ttf file. Here’s the code, for what it might be worth.
#!/usr/bin/env python
# svg2ttf v0.1
#
# copyleft 2008-2009 ricardo lafuente
#
# generate a .ttf file from a set of .svg files with the lowercase alphabet
#
# before running this script, create a blank font file in Fontforge
# (make a New font and save it as it is) and change the BLANK_FONT location
#
# you might also want to edit the metadata (title, license, etc.) before
# saving it, or just edit the blank.sfd file afterwards
#
# finally, change the LETTERS_DIR value to the folder where your .svg
# files are; they ought to be named [a-z].svg
LETTERS_DIR = ‘~/Desktop/svgletters/’
BLANK_FONT = ‘~/Desktop/blank.sfd’
letters = ‘abcdefghijklmnopqrstuvwxyz’
# right-o, here we go
import fontforge
# open a blank font template
# TODO: dynamically generate the space character
font = fontforge.open(BLANK_FONT)
for letter in letters:
# make new glyph
font.createMappedChar(letter)
# import outline file
# notice that font[glyphname] returns the appropriate glyph
# fontforge is awesome :o)
font[letter].importOutlines(LETTERS_DIR + ‘/’ + letter + ‘.svg’)
# same spacing for each letter, this is a hack after all
font[letter].left_side_bearing = 15
font[letter].right_side_bearing = 15
# generate TrueType hints
# font[letter].autoInstr()
# create the output truetype file
font.generate(‘output.ttf’)
Have you worked with python-fontforge? Blogged about it? Made an awesome script
or two? Let me know in the comments section — i’m pretty sure i’m not alone in
my fascination :-)
**Update**: Dear feed readers, please pardon my multi-post ineptitude; i’m
still trying to get the hang of posting through [vim](http://www.vim.org) –
one less mistake i’ll be making in the future.
[nudge]: http://betatype.com/node/18 (Interpolated Nudge macro)
[ls]: http://tinkerhouse.net/lettersoup
[gw]: http://ospublish.constantvzw.org/type/i-think-the-ideas-behind-it-are-beautiful-in-my-mind
[doc]: http://fontforge.sourceforge.net/python.html
[ml]: https://lists.sourceforge.net/lists/listinfo/fontforge-devel
[spiro]: http://www.levien.com/spiro/
[scripts]: http://fontforge.wiki.sourceforge.net/scripts
hey looking nice script , if it succesfully run can prove to great help in my college project
but it showing some error
./svg2ttf: line 16: LETTERS_DIR: command not found
./svg2ttf: line 17: BLANK_FONT: command not found
./svg2ttf: line 19: letters: command not found
./svg2ttf: line 26: syntax error near unexpected token
('font = fontforge.open(BLANK_FONT)’./svg2ttf: line 26:
i m using on ubuntu 8.10
kindly help me , my email id vinay.rks@gmail.com
My fault — i had forgotten to include the ‘shebang’ line in the very beginning; without it, the bash interpreter was trying to read it as a bash script, instead of calling Python.
Now corrected, many thanks :) (alternatively, you could run it using the ‘python svg2ttf’ command)
This is great! Thanks for this blog. I am starting development and this will be a big help.
This is great. Thank you.
I’ve got Coach Signature Zoe, I like this bag!! It was the last one with these colours inside the store. I’ve not noticed it at any other Coach retail store either. I asked the sales person concerning this bag and so they said that this bag is very hot that whenever they get it, it is sold out in few days!! Nuts! Coach Zoe Purse is produced with Coach Signature materials that’s treated being stain as well as water resistant. Trimmed by using platinum natural leather as well as silver equipment. Either side features attractive silver buckles, similar to the Carly. Neck straps provides dogleash end and also the internal is definitely layered in blue silky fabric having several pockets.
The Moncler Moka Down Jacket is often a lengthy puffer coat that reeks style, warmth, excellent and is in high demand of a person with fine taste. Using a removable drawstring hood that attaches for the coat with press studs and also a stand up collar with two press studs top into a zip fastening front offers wonderful detail. The Moka Jacket will have you searching extended and sleek as you walk with such security and confidence. Though styling inside the ideal you are going to also be so warm and comfy. The Moka Classic knee length coat with detachable hood in Nylon Laque giving you extra warmth in a flattering shape. Having shape slash pockets, contrast zipper, water resistant material and having the ability to machine wash completes this down jacket making it attractive and easy to wear|I have searched for, bought and tried lots of other high-end business down coats. This is the warmest coat of them all. The down coat is so light and you really can move in it. I’m a preschool teacher who stands outside for hours through the winter months. I’m so warm and in-style though wearing my Mountain Hardwear Downtown Coat. I’m petite, 4 feet eleven inches, 30 inch waist along with a double D chest. The Large size is slightly roomy permitting for real clothes to be worn underneath. The top-down, button-up zipper is crucial. I normally buy TNF brand for outside gear. Having purchased and tried many versions of their style with the Downtown Down Coat just doesn’t compare. Theirs created me cold, felt like armor and just was not worth the $300 value tag. So content that I stepped outside the TNF box and bought a Mountain Hardwear Coat. Hope your as happy with your gear as I am. Can’t wait to buy additional Mountain Hardwear brand gear.