6

Environment: Win 7, Python 3.4, Sublime Text 2

I am trying to use fontforge as in following example, by importing fontforge in *.py:

import fontforge
font = fontforge.open('blank.sfd')
...

However, I haven't found any help for win 7 on where (or which subset) to include fontforge binary in my project to make it work. Any ideas, please? Thanks

Edit: I was trying to build it with pyextension in win 7 as described here:

http://fontforge.org/source-build.html#MS

via cygwin it fails on executing ./configure --enable-pyextension

throwing
checking for gcc
result: no    
checking for cc
result: no
checking for cl.exe
result: no
error: in `/cygdrive/c/fontforge':
no acceptable C compiler found in $PATH

Edit 2: By installing C compiler I've managed to ./configure it but my attempts have failed on executing make install command. I got following error, preceding another countless lines:

Makefile:91: recipe for target '../libfontforge.la' failed
make[1]: *** [../libfontforge.la] Error 1
make[1]: Leaving directory '/cygdrive/c/fontforge/fontforge'
Makefile:28: recipe for target 'fontforge' failed
make: *** [fontforge] Error 2
Community
  • 1
  • 1
zap
  • 61
  • 1
  • 3
  • What is the error when you `import fontforge`. Did you build FF with the Python extension enabled? – allcaps Apr 30 '14 at 12:23
  • @allcaps I was trying to build it with pyextension in win as described here: http://fontforge.org/source-build.html#MS via cygwin it fails on ./configure --enable-pyextension throwing checking for gcc result: no checking for cc result: no checking for cl.exe result: no error: in `/cygdrive/c/fontforge': no acceptable C compiler found in $PATH – zap Apr 30 '14 at 15:55
  • You need to install a C compiler and try again. – allcaps Apr 30 '14 at 19:43
  • Thanks, @allcaps, I've installed a C compiler, but I've failed on another command getting an error as described above. Do you have any idea, why it might be so? – zap May 03 '14 at 10:07
  • Nope, can't help you. Maybe the Fontforge mailing list? – allcaps May 03 '14 at 18:06
  • Did you manage to do this eventually? And in that case, how? I'm having the same problem. – akvilas Dec 15 '15 at 11:31
  • HI @akvilas I'm sorry I haven't managed to do it. Any progress at your side? – zap Dec 20 '15 at 08:50
  • @zap I gave up as well. I'm now using FontTools, which had the functionality I needed. But it would be great if there was a way to access FontForge from python in windows... short of doing a windows build of course. – akvilas Dec 20 '15 at 20:52

1 Answers1

11

Install fontforge for windows, then search your install for a fontforge-console.bat, and double-click it. From there you have a python environment that includes fontforge via the command:

ffpython

e.g.:

ffpython yourPythonFontForgeScript.py

You may need to cd to whatever directory has your python script before running that command, or otherwise make sure that the script is in your %PATH%.

Alex Hall
  • 956
  • 10
  • 18
  • Thanks, got me where I needed to be. using windows and not cygwin, but meh – Northstrider Mar 18 '17 at 09:52
  • 4
    This is probably a helpful answer for most folks just trying to get *some* Python scripting to work with FontForge on Windows (it definitely helped me), but it's worth noting that `ffpython` is FontForge's own copy of Python (not your system's Python), and if you simply downloaded the prebuilt Windows installer (as of this writing, `FontForge-2017-07-31-Windows-r2.exe`), then `ffpython` is Python 2, not Python 3. (Specifically, the 2017-07-31 build contains Python 2.7.13.) – John Y Oct 01 '18 at 21:07
  • Running ffpython somescript.py still produces an error if you add `import fontforge` at the top. `ModuleNotFoundError: No module named 'fontforge'` (At least for me) – fmotion1 Aug 26 '22 at 21:22
  • @Jay you run fontforge-console.bat. When that is done, in the same window, run ffpython, as if it were any other python interpreter. – Shmack Dec 17 '22 at 02:18