summaryrefslogtreecommitdiffstats
path: root/examples/fontforge-old/demoAddToMenu.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/fontforge-old/demoAddToMenu.py')
-rwxr-xr-xexamples/fontforge-old/demoAddToMenu.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/fontforge-old/demoAddToMenu.py b/examples/fontforge-old/demoAddToMenu.py
new file mode 100755
index 0000000..6af6580
--- /dev/null
+++ b/examples/fontforge-old/demoAddToMenu.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+'FontForge: Demo script to add menu items to FF tools menu'
+__url__ = 'http://github.com/silnrsi/pysilfont'
+__copyright__ = 'Copyright (c) 2014 SIL International (http://www.sil.org)'
+__license__ = 'Released under the MIT License (http://opensource.org/licenses/MIT)'
+__author__ = 'David Raymond'
+
+import sys, os, fontforge
+sys.path.append(os.path.join(os.environ['HOME'], 'src/pysilfont/scripts'))
+import samples.demoFunctions
+from samples.demoFunctions import functionList, callFunctions
+#from samples.demoCallFunctions import callFunctions
+
+def toolMenuFunction(functionGroup,font) :
+ reload (samples.demoFunctions)
+ callFunctions(functionGroup,font)
+
+funcList=functionList()
+
+for functionGroup in funcList :
+ menuType = funcList[functionGroup][0]
+ fontforge.registerMenuItem(toolMenuFunction,None,functionGroup,menuType,None,functionGroup);
+ print functionGroup, " registered"
+
+''' This script needs to be called from one of the folders that FontForge looks in for scripts to
+run when it is started. With current versions of FontForge, one is Home/.config/fontforge/python.
+You may need to turn on showing hidden files (ctrl-H in Nautilus) before you can see the .config
+folder. Within there create a one-line python script, say call sampledemo.py containing a call
+to this script, eg:
+
+execfile("/home/david/src/pysilfont/scripts/samples/demoAddToMenu.py")
+
+Due to the reload(samples.demoFunctions) line above, changes functions defined in demoFunctions.py
+are dynamic, ie FontForge does not have to be restarted (as would be the case if the functions were
+called directly from the tools menu. Functions can even be added dynamically to the function groups.
+
+If new function groups are defined, FontForge does have to be restarted to add them to the tools menu.
+'''