beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luafontloader / fontforge / fontforge / plugins.h
blob58ae244848475be2e74fad133f012c0ab945c788
1 /* Copyright (C) 2005-2008 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 /* If a user wants to write a fontforge plugin s/he should include this file */
31 I envision that there will eventually be three types of plug-ins. At the
32 moment I am only supporing two of them.
34 * A plug in which adds a new encoding to the encoding/force encoding
35 menus.
36 * A plug in which adds a new scripting command
37 * A plug in which adds a new menu item.
38 (I haven't figure out how I want to do this last. So I'm not currently
39 supporting it.)
41 A plug-in should be a dynamic library.
42 Plug-ins will be loaded at start up if they are in the default plugin
43 directory, or a script may explicitly invoke a LoadPlugin() call
44 and pass a filename.
45 Each plug-in should contain an entry-point:
46 void FontForgeInit(void);
47 When FF loads a plug-in it will call this entry point.
48 I expect that this routine in term will call one (or more) of the install
49 routines (though it can do whatever it likes):
50 * AddEncoding(name,enc-to-unicode-func,unicode-to-enc-func)
51 * AddScriptingCommand(name,func,needs-font)
53 Once loaded, there is no way to remove a plug in -- but you can map a
54 plug in's name to do something else.
56 I am presuming that plugins will be linked against libfontforge and
57 that it will have access to all routines declared in fontforge's
58 header files. I do not expect to turn this into a real library with
59 a true API. It's just a catch all bag of routines I have needed.
60 It's not documented either.
63 /* Entry point all plugins must contain */
64 extern int FontForgeInit(void);
65 /* If the load fails, then this routine should return 0, else 1 */
66 /* if it returns 0, fontforge will dlclose the shared lib */
67 /* FontForge will not complain itself. FontForgeInit should */
68 /* call LogError (or gwwv_post_error or whatever) if it wants */
69 /* to report failure */
71 /* AddScriptingCommand is documented within */
72 #include "scripting.h"
74 /* AddEncoding is documented here */
75 typedef int (*EncFunc)(int);
76 extern int AddEncoding(char *name,EncFunc enc_to_uni,EncFunc uni_to_enc,int max);
77 /* The "Encoding" here is a little different from what you normally see*/
78 /* It isn't a mapping from a byte stream to unicode, but from an int */
79 /* to unicode. If we have an 8/16 encoding (EUC or SJIS) then the */
80 /* single byte entries will be numbers less than <256 and the */
81 /* multibyte entries will be numbers >=256. So an encoding might be */
82 /* valid for the domain [0x20..0x7f] [0xa1a1..0xfefe] */
83 /* In other words, we're interested in the ordering displayed in the */
84 /* fontview. Nothing else */
85 /* The max value need not be exact (though it should be at least as big)*/
86 /* if you create a new font with the given encoding, then the font will */
87 /* have max slots in it by default */
88 /* A return value of -1 (from an EncFunc) indicates no mapping */
89 /* AddEncoding returns 1 if the encoding was added, 2 if it replaced */
90 /* an existing encoding, 0 if you attempt to replace a builtin */
91 /* encoding */
94 /* Internal routines. Plugins shouldn't need these */
95 extern void LoadPlugin(char *dynamic_lib_name);
96 /* Loads a single plugin file */
97 extern void LoadPluginDir(char *dir);
98 /* Loads any dynamic libs from this directory. if dir is NULL loads from */
99 /* default directory */