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
8
  • What is the error when you import fontforge. Did you build FF with the Python extension enabled?
    – allcaps
    Apr 30, 2014 at 12:23
  • @allcaps I was trying to build it with pyextension in win as described here: 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, 2014 at 15:55
  • You need to install a C compiler and try again.
    – allcaps
    Apr 30, 2014 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 3, 2014 at 10:07
  • Nope, can't help you. Maybe the Fontforge mailing list?
    – allcaps
    May 3, 2014 at 18:06

1 Answer 1

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%.

4
  • Thanks, got me where I needed to be. using windows and not cygwin, but meh Mar 18, 2017 at 9: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 1, 2018 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, 2022 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, 2022 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.