ctrlcctrlv / lcd-font

14 segment display font with many character sets
SIL Open Font License 1.1
39 stars 9 forks source link

Investigate FontForge Python API #3

Closed ctrlcctrlv closed 9 years ago

ctrlcctrlv commented 9 years ago

Currently I'm using the Menus to generate the alternate SFDs and the OTFs, but that takes up considerable time (as fun as it is to watch the glyphs change it's becoming not worth it :P)

I should just write a build.py script.

ctrlcctrlv commented 9 years ago

There's a huge documentation page here: http://pfaedit.org/python.html

Shouldn't be too hard

ctrlcctrlv commented 9 years ago
[fredrick@localhost ~]$ python
Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontforge
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'fontforge'
>>> 
[fredrick@localhost ~]$ python2
Python 2.7.10 (default, May 26 2015, 04:16:29) 
[GCC 5.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontforge
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named fontforge

hmmm

ctrlcctrlv commented 9 years ago

I thought it may be because I build FontForge from source to avail of the latest changes, but Python is opt-out, not opt-in.

  --disable-native-scripting
                          disable the legacy fontforge scripting language
  --disable-python-scripting
                          disable Python scripting
  --disable-python-extension
                          do not build the Python extension modules "psMat"
                          and "fontforge", even if they were included in this
                          source distribution
ctrlcctrlv commented 9 years ago

I did ./configure again just to be sure.

Configuration:

  Source code location  .
  Build code location
  Destination prefix    /usr/local
  Compiler              gcc

Summary of optional features:

  real (floating pt)    double
  programs              yes
  native scripting      yes
  python scripting      yes
  python extension      yes
  freetype debugger     no
  raw points mode       no
  tile path             no
  gb12345 encoding      no

It could be because I have both sortsmill-editor and fontforge one is overwriting the extension of the other. Ech

ctrlcctrlv commented 9 years ago

The plot thickens :)

[fredrick@localhost fontforge]$ locate fontforge.py
/usr/local/lib/python2.7/site-packages/fontforge.py
/usr/local/lib/python2.7/site-packages/fontforge.pyc
/usr/local/lib/python2.7/site-packages/fontforge.pyo
ctrlcctrlv commented 9 years ago
[fredrick@localhost fontforge]$ PYTHONPATH=/usr/local/lib/python2.7/site-packages/ python2
Python 2.7.10 (default, May 26 2015, 04:16:29) 
[GCC 5.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontforge
guile: uncaught throw to misc-error: (public-lookup Module named ~s does not exist ((sortsmill ffcompat)) #f)

Yes sortsmill-editor overwrote my Python extension. d'oh!

ctrlcctrlv commented 9 years ago

Guess another sudo make install can't hurt

ctrlcctrlv commented 9 years ago

Actually this is a perfect time to try https://github.com/fontforge/fontforge/pull/2416

If this fixes https://github.com/fontforge/fontforge/issues/2406 I can just place my bounty on something else

ctrlcctrlv commented 9 years ago

Applied https://patch-diff.githubusercontent.com/raw/fontforge/fontforge/pull/2416.patch and rebuilding :sunglasses:

ctrlcctrlv commented 9 years ago

Got it, I figured it out.

[fredrick@localhost fontforge]$ PYTHONPATH=/usr/local/lib/python3.4/site-packages/ python3
Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontforge
>>> 

fontforge uses py3k, sortsmill-editor only supports py2k. Weird.