| 1 |
Using FontForge Plugins |
| 2 |
======================= |
| 3 |
|
| 4 |
A FontForge plugin is a Python package that contains code to enhance |
| 5 |
the FontForge application in some way, most often by adding one or more |
| 6 |
entries to the Font View or Char View :doc:`Tools menu </ui/menus/toolsmenu>`. |
| 7 |
Using a plugin is as easy as installing the package (often with |
| 8 |
`pip <https:pypi.org/project/pip/>`_) and, when necessary, "configuring" |
| 9 |
the plugin. Almost any plugin of general interest will be listed in |
| 10 |
the `PyPI package database <https:pypi.org/search/?q=%22FontForge_plugin%22>`_. |
| 11 |
|
| 12 |
Plugin Preferences |
| 13 |
------------------ |
| 14 |
|
| 15 |
Two FontForge preference values affect the behavior of plugins. The first is |
| 16 |
"UsePlugins" in the "Preferences ..." dialog (under :doc:`the File menu |
| 17 |
</ui/menus/filemenu>`), which is On by default. Turning this Off, temporarily |
| 18 |
or permanently, will keep FontForge from attempting to discover and load |
| 19 |
plugins. |
| 20 |
|
| 21 |
.. figure:: /images/plugdlg.png |
| 22 |
:alt: Configure Plugins... Dialog |
| 23 |
|
| 24 |
The second preference is "PluginStartupMode" in the "Configure Plugins..." |
| 25 |
dialog (also under the File menu), which can be set to "On", "Off", or |
| 26 |
"Ask" (the default). When this preference is set to "On" a newly discovered |
| 27 |
plugins is automatically loaded. When set to "Off" it is not loaded |
| 28 |
until you decide to Enable it in the same dialog. When set to "Ask" the |
| 29 |
dialog will appear on startup whenever a new plugin is discovered so that |
| 30 |
you can decide whether or not to use it. Which value makes the most sense for |
| 31 |
you will depend on the degree of control you have over what packages are |
| 32 |
installed in your python path. |
| 33 |
|
| 34 |
Enabling and Disabling Plugins |
| 35 |
------------------------------ |
| 36 |
|
| 37 |
The "Configure Plugins..." dialog allows you to Enable or Disable individual |
| 38 |
plugins and also Delete entries for once-discovered plugins that are no |
| 39 |
longer found. You can also "reorder" plugins—changing the load order and |
| 40 |
therefore the order of Tools menu entries. There are also buttons for |
| 41 |
loading a so-far-unloaded plugin (in case you do not want to wait for the |
| 42 |
next application restart), getting more (mostly technical) information |
| 43 |
about the plugin, and opening the web page associated with the plugin |
| 44 |
package. |
| 45 |
|
| 46 |
Finally, if a plugin has its own preferences you can set those with the |
| 47 |
"Configure" button (which is disabled otherwise). The content of preferences |
| 48 |
and the process of setting them will vary by plugin. |
| 49 |
|
| 50 |
Loading Plugins For Scripts |
| 51 |
--------------------------- |
| 52 |
|
| 53 |
When a script is run with FontForge directly using the ``-script`` flag each |
| 54 |
enabled and discovered plugin will be loaded before control is passed off to |
| 55 |
the script (unless the ``-skippyplug`` flag is also specified). |
| 56 |
In contrast, running a python script with the ``python`` command and importing |
| 57 |
the ``fontforge`` module will not cause plugins to be loaded. If you have a |
| 58 |
script that needs the functionality of a plugin (perhaps because it adds a |
| 59 |
new font export format) you must load the plugins explicitly by calling |
| 60 |
``fontforge.loadPlugins()``. Calling this function when plugins are already |
| 61 |
loaded should be harmless. |
| 62 |
|
| 63 |
Troubleshooting |
| 64 |
--------------- |
| 65 |
|
| 66 |
The FontForge project has no control over who can make a plugin. At |
| 67 |
some point you may install one that causes problems, potentially even |
| 68 |
preventing you from successfully running FontForge. One work-around for |
| 69 |
that situation is to run FontForge with the ``-skippyplug`` flag. |
| 70 |
When started with that flag FontForge will still "discover" plugins but |
| 71 |
will not automatically load them. You can then open the "Configure Plugins..." |
| 72 |
dialog, Disable the misbehaving plugin, and restart the program. |
| 73 |
|
| 74 |
When an individual plugin is present but cannot be loaded there will be |
| 75 |
relevant warnings logged on startup or when a load is attempted via the dialog |
| 76 |
or the python API. There will also be a warning for each *enabled* plugin |
| 77 |
that is not discovered. |