# Writing scripts to change fonts in FontForge

FontForge includes an interpreter so you can write scripts to modify fonts.

- Starting a script
- Scripting language
  - Built in variables
  - Built in procedures
  - Examples
- The Execute Script dialog
- The Scripts menu

## Starting scripts

If you start fontforge with a script on the command line it will not put up any windows and it will exit when the script is done.

>     $ fontforge -script scriptfile.pe {fontnames}

FontForge can also be used as an interpreter that the shell will automatically pass scripts to. If you a mark your script files as executable
`$ chmod +x scriptfile.pe`
and begin each one with the line
`#!/usr/local/bin/fontforge`
(or wherever fontforge happens to reside on your system) then you can invoke the script just by typing
`$ scriptfile.pe {fontnames}`

If you wish FontForge to read a script from stdin then you can use "-" as a "filename" for stdin. (If you build FontForge without X11 then fontforge will attempt to read a script file from `stdin` if none is given on the command line.)

You can also start a script from within FontForge with `File->Execute Script`, and you can use the Preference Dlg to define a set of frequently used scripts which can be invoked directly by menu.

The scripting language provides access to much of the functionality found in the font view's menus. It does not currently (and probably never will) provide access to everything. (If you find a lack let me know, I may put it in for you). It does not provide commands for building up a glyph out of splines, instead it allows you to do high level modifications to glyphs.

If you set the environment variable `PFAEDIT_VERBOSE` (it doesn't need a value, just needs to be set) then FontForge will print scripts to stdout as it executes them.

In general I envision this as being useful for things like taking a latin font and extending it to contain cyrillic glyphs. So the script might:

- Reencode the font
- Place a reference to Latin "A" at Cyrillic "A"
- Copy Latin "R" to Cyrillic "YA"
- Flip "YA" horizontally
- Correct its direction
- ... and so forth

## Scripting Language

The syntax is rather like a mixture of C and shell commands. Every file corresponds to a procedure. As in a shell script arguments passed to the file are identified as $1, $2, ... $n. $0 is the file name itself. $argc gives the number of arguments. $argv[<expr>] provides array access to the arguments.

Terms can be

- A variable name (like "$1" or "i" or "@fontvar" or "_global")
  The scope of the variable depends on the initial character of its name.
  - A '$' signifies that it is a built-in variable. The user cannot create any new variables beginning with '$'. Some, but not all, of these may be assigned to.
  - A '_' signifies that the variable is global, it is always available. You can use these to store context across different script files (or to access data within nested script files).
  - A '@' signifies that the variable is associated with the font. Any two scripts looking at the same font will have access to the same variables.
  - A variable which begins with a letter is a local variable. It is only meaningful within the current script file. Nested script files may have different variables with the same names.
- an integer expressed in decimal, hex or octal
- a unicode code point (which has a prefix of "0u" or "0U" and is followed by a string of hex digits. This is only used by the select command.
- a real number (in "C" locale format -- "." as the decimal point character)
- A string which may be enclosed in either double or single quotes. String tokens are limited to 256 bytes. "\n" can be used to represent a newline character. (If you need longer strings use the concatenation operator).
- a procedure to call or file to invoke.
- an expression within parentheses
- a series of expressions (separated by commas) within brackets, as `[1, 2, 3, 5, 8]`, used to create an array.

There are three different comments supported:

- Starting with a "#" character and proceeding to end of line
- Starting with "//" and proceeding to end of line
- Starting with "/*" and proceeding to "*/"

Expressions are similar to those in C, a few operators have been omitted, a few added from shell scripts. Operator precedence has been simplified slightly. So operators (and their precedences) are:

- unary operators (+, -, !, ~, ++ (prefix and postfix), --(prefix and postfix), () (procedure call), [] (array index), :h, :t, :r, :e
  Most of these are as expected in C, the last four are borrowed from shell scripts and are applied to strings
  - :h gives the head (directory) of a pathspec
  - :t gives the tail (filename) of a pathspec
  - :r gives the pathspec without the extension (if any)
  - :e gives the extension
- *, /, % (binary multiplicative operators)
- +, - (binary arithmetic operators)
  If the first operand of + is a string then + will be treated as concatenation rather than addition. If the second operand is a number it will be converted to a string (decimal representation) and then concatenated.
- ==, !=, >, <, >=, <= (comparison operators, may be applied to either two integers or two strings)
- &&, & (logical and, bitwise and. (logical and will do short circuit evaluation))
- ||, |, ^ (logical or, bitwise or, bitwise exclusive or (logical or will do short circuit evaluation))
- =, +=, -=, *=, /=, %= (assignment operators as in C. The += will act as concatenation if the first operand is a string.)

Note there is no comma operator, and no "?:" operator. The precedence of "and" and "or" has been simplified, as has that of the assignment operators.

Procedure calls may be applied either to a name token, or to a string. If the name or string is recognized as one of FontForge's internal procedures it will be executed, otherwise it will be assumed to be a filename containing another fontforge script file, this file will be invoked (since filenames can contain characters not legal in name tokens it is important to allow general strings to specify filenames). If the procedure name does not contain a directory then it is assumed to be in the same directory as the current script file. At most 25 arguments can be passed to a procedure.

Arrays are passed by reference, strings and integers are passed by value.

Variables may be created by assigning a value to them (only with the "="), so:
`i=3`
could be used to define "i" as a variable. Variables are limited in scope to the current file, they will not be inherited by called procedures.

A statement may be

- an expression
- `if ( expression )
  statements
  {elseif ( expression )
  statements}
  [else
  statements]
  endif`
- `while ( expression )
  statements
  endloop`
- `foreach
  statements
  endloop`
- `return [ expression ]`
- `shift`

As with C, non-zero expressions are defined to be true.
A return statement may be followed by a return value (the expression) or a procedure may return nothing (void).
The shift statement is stolen from shell scripts and shifts all arguments down by one. (argument 0, the name of the script file, remains unchanged.
The foreach statement requires that there be a current font. It executes the statements once for each glyph in the selection. Within the statements only one glyph at a time will be selected. After execution the selection will be restored to what it was initially. (Caveat: Don't reencode the font within a foreach statement).
Statements are terminated either by a new line (you can break up long lines with backslash newline) or a semicolon.

Trivial example:

>     i=0;	#semicolon is not needed here, but it's ok
>     while ( i<3 )
>        if ( i==1 /* pointless comment */ )
>     	Print( "Got to one" )	// Another comment
>        endif
>        ++i
>     endloop

FontForge maintains the concept of a "current font"-- almost all commands refer only to the current font (and require that there be a font). If you start a script with File->Execute Script, the font you were editing will be current, otherwise there will be no initial current font. The Open(), New() and Close() commands all change the current font. FontForge also maintains a list of all fonts that are currently open. This list is in no particular order. The list starts with $firstfont.

Similarly when working with cid keyed fonts, FontForge works in the "current sub font", and most commands refer to this font. The CIDChangeSubFont() command can alter that.

All builtin variables begin with "$", you may not create any variables that start with "$" yourself (though you may assign to (some) already existing ones)

- `$0` the current script filename
- `$1` the first argument to the script file
- `$2` the second argument to the script file
- ...
- `$argc` the number of arguments passed to the script file (this will always be at least 1 as $0 is always present)
- `$argv` allows you to access the array of all the arguments
- `$curfont` the name of the filename in which the current font resides
- `$firstfont` the name of the filename of the font which is first on the font list (Can be used by Open()), if there are no fonts loaded this returns an empty string. This can be used to determine if any font at all is loaded into fontforge.
- `$nextfont` the name of the filename of the font which follows the current font on the list (or the empty string if the current font is the last one on the list)
- `$fontchanged` returns 1 if the current font has changed, 0 if it has not changed since it was read in (or saved).
- `$fontname` the name contained in the postscript FontName field
- `$familyname` the name contained in the postscript FamilyName field
- `$fullname` the name contained in the postscript FullName field
- `$fondname` if set this name indicates what FOND the current font should be put in under Generate Mac Family.
- `$weight` the name contained in the postscript Weight field
- `$copyright` the name contained in the postscript Notice field
- `$filename` the name of the file containing the font.
- `$fontversion` the string containing the font's version
- `$cidfontname` returns the fontname of the top-level cid-keyed font (or the empty string if there is none)
  Can be used to detect if this is a cid keyed font.
- `$cidfamilyname, $cidfullname, $cidweight, $cidcopyright` similar to above
- `$mmcount` returns 0 for non multiple master fonts, returns the number of instances in a multiple master font.
- `$italicangle` the value of the postscript italic angle field
- `$curcid` returns the fontname of the current font
- `$firstcid` returns the fontname of the first font within this cid font
- `$nextcid` returns the fontname of the next font within this cid font (or the empty string if the current sub-font is the last)
- `$macstyle` returns the value of the macstyle field (a set of bits indicating whether the font is bold, italic, condensed, etc.)
- `$bitmaps` returns an array containing all bitmap pixelsizes generated for this font. (If the font database contains greymaps then they will be indicated in the array as `(<BitmapDepth><<16)|<PixelSize>`)
- `$selection` returns an array containing one entry for each glyph in the current font indicating whether that glyph is selected or not (0=>not, 1=>selected)
- `$panose` returns an array containing the 10 panose values for the font.
- `$trace` if this is set to one then FontForge will trace each procedure call.
- `$version` returns a string containing the current version of fontforge. This should look something like "020817".
- `$`<Preference Item> (for example `$AutoHint`) allows you to examine the value of that preference item (to set it use `SetPref`)

The following example will perform an action on all loaded fonts:

>     file = $firstfont
>     while ( file != "" )
>        Open(file)
>        /* Do Stuff */
>        file = $nextfont
>     endloop

The built in procedures are very similar to the menu items with the same names. Often the description here is sketchy, look at the menu item for more information.

Print(arg1,arg2,arg3,...)
  This corresponds to no menu item. It will print all of its arguments to stdout. It can execute with no current font.
PostNotice(str)
  When run from the UI will put up a window displaying the string (the window will not block the program and will disappear after a minute or so). When run from the command line will write the string to stderr.
Error(str)
  Prints out str as an error message and aborts the current script
AskUser(question[,default-answer])
  Asks the user the question and returns an answer (a string). A default-answer may be specified too.
Array(size)
  Allocates an array of the indicated size.

  >     a = Array(10)
  >     i = 0;
  >     while ( i<10 )
  >        a[i] = i++
  >     endloop
  >     a[3] = "string"
  >     a[4] = Array(10)
  >     a[4][0] = "Nested array";

SizeOf(arr)
  Returns the number of elements in an array.
TypeOf(any)
  Returns a string naming the type of the argument:
  - "Integer"
  - "Real"
  - "Unicode"
  - "String"
  - "Array"
  - "Void"
    (The following type is used internally, but I don't think the user can ever see it. It is included here for completeness)
  - "LValue"
Strsub(str,start[,end])
  Returns a substring of the string argument. The substring begins at position indexed by start and ends before the position indexed by end (if end is omitted the end of the string will be used, the first position is position 0). Thus `Strsub("abcdef",2,3) == "c"` and `Strsub("abcdef",2) == "cdef"`
Strlen(str)
  Returns the length of the string.
Strstr(haystack,needle)
  Returns the index of the first occurrence of the string needle within the string haystack (or -1 if not found).
Strrstr(haystack,needle)
  Returns the index of the last occurrence of the string needle within the string haystack (or -1 if not found).
Strcasestr(haystack,needle)
  Returns the index of the first occurrence of the string needle within the string haystack ignoring case in the search (or -1 if not found).
Strcasecmp(str1,str2)
  Compares the two strings ignoring case, returns zero if the two are equal, a negative number if str1<str2 and a positive number if str1>str2
Strtol(str[,base])
  Parses as much of str as possible and returns the integer value it represents. A second argument may be used to specify the base of the conversion (it defaults to 10). Behavior is as for strtol(3).
Strskipint(str[,base])
  Parses as much of str as possible and returns the offset to the first character that could not be parsed.
Strtod(str)
  Converts a string to a real number.
LoadPrefs()
  Loads the user's preferences. This used to happen automatically at startup. Now it happens automatically when the UI is started, but scripts must request it.
SavePrefs()
  Save the current state of preferences. This used to happen when SetPref was called, now a script must request it explicitly.
GetPref(str)
  Gets the value of the preference item whose name is contained in str. Only boolean, integer, real, string and file preference items may be returned. Boolean and real items are returned with integer type and file items are returned with string type. Encodings (NewCharset) are returned as magic numbers, these are meaningless outside the context of get/set Pref.
SetPrefs(str,val[,val2])
  Sets the value of the preference item whose name is contained in str. If the preference item has a real type then a second argument may be passed and the value set will be val/val2.
LoadPlugin(filename)
  Will load the fontforge plugin stored in the given file (this should be a shared library).
LoadPluginDir([directory-name])
  Searches the given directory for things that look like fontforge plugins and loads them. If directory is omitted then it will load the two default directories:
  - /usr/local/share/fontforge/plugins
  - ~/.PfaEdit/plugins
LoadNamelist(filename)
  Will load the namelist stored in the given file.
LoadPluginDir([directory-name])
  Searches the given directory for things that look like fontforge plugins and loads them. If directory is omitted then it will load the default directory:
  - ~/.PfaEdit/
DefaultOtherSubrs()
  Returns to using Adobe's versions of the OtherSubrs subroutines.
ReadOtherSubrsFile(filename)
  Reads new PostScript subroutines to be used in the OtherSubrs array of a type1 font. The file format is a little more complicated than it should be (because I can't figure out how to parse the OtherSubrs array into individual subroutines).
  - The subroutine list should not be enclosed in a [ ] pair
  - Each subroutine should be preceded by a line starting with '%%%%' (there may be more stuff after that)
  - Subroutines should come in the obvious order, and must have the expected meaning.
  - If you don't wish to support flex hints set the first three subroutines to "{}"
  - You may specify at most 14 subroutines (0-13)
  - Any text before the first subroutine will be treated as a copyright notice.

  >     % Copyright (c) 1987-1990 Adobe Systems Incorporated.
  >     % All Rights Reserved
  >     % This code to be used for Flex and Hint Replacement
  >     % Version 1.1
  >     %%%%%%
  >     {systemdict /internaldict known
  >     1183615869 systemdict /internaldict get exec
  >     ...
  >     %%%%%%
  >     {gsave currentpoint newpath moveto} executeonly
  >     %%%%%%
  >     {currentpoint grestore gsave currentpoint newpath moveto} executeonly
  >     %%%%%%
  >     {systemdict /internaldict known not
  >     {pop 3}
  >     ...

GetEnv(str)
  Returns the value of the unix environment variable named by str.
FileAccess(filename[,prot])
  Behaves like the unix access system call. Returns 0 if the file exists, -1 if it does not. If protection is omitted, checks for read access.
WriteStringToFile("string","Filename"[,append])
  Creates the file named "Filename" and writes the string to it. If the append flag is present and non-zero, then the string will be appended to the file. This deals with null-terminated strings, not with byte arrays. Returns -1 on failure otherwise the number of bytes written.
LoadStringFromFile("filename")
  Reads the entire file into a string. Returns a null string for a non-existant or empty file. The returned string will have enough bytes allocated to hold the entire file plus one trailing NUL byte. If the file contains a NUL itself, fontforge will think the string ends there.
UnicodeFromName(name)
  Looks the string "name" up in FontForge's database of commonly used glyph names and returns the unicode value associated with that name, or -1 if not found. This does not check the current font (if any).
Chr(int)
Chr(array)
  Takes an integer [0,255] and returns a single character string containing that code point. Internally FontForge interprets strings as if they were in utf8 (well really, FontForge almost always just uses ASCII-US internally). If passed an array, it should be an array of integers and the result is the string.
Ord(string[,pos])
  Returns an array of integers representing the encoding of the characters in the string. If pos is given it should be an integer less than the string length and the function will return the integer encoding of that character in the string.
Real(int)
  Converts an integer to a real number.
Round(real)
  Converts a real number to an integer by rounding to the nearest integer
Floor(real)
  Converts a real number to the largest integer smaller than the real.
Ceil(real)
  Converts a real number to the smallest integer larger than the real.
Int(real)
  Uses standard C conversion from real to integer.
UCodePoint(int)
  Converts the argument to a unicode code point (a special type used in several commands).
ToString(arg)
  Converts its argument to a string. (the output is what the Print() command would print)
IsNan(real)
  Returns whether the value is a nan.
IsFinite(real)
  Returns whether the value is finite (not infinite and not a nan).
Sqrt(val)
  Returns the square root
Exp(val)
  Returns e^val
Log(val)
  Returns the natural log of val.
Pow(val1,val2)
  Returns val1^val2
Sin(val)
  Returns the sine of val
Cos(val)
  Returns the cosine of val
Tan(val)
  Returns the tangent of val
ATan2(val1,val2)
  Returns the arc-tangent. See atan2(3) for more info.
Utf8(int)
  Takes an integer [0,0x10ffff] and returns the utf8 string representing that unicode code point. If passed an array of integers it will generate a utf8 string containing all of those unicode code points. (it does not expect to get surrogates).
Rand()
  returns a random integer

FontsInFile(filename)
  Returns an array of strings containing the names of all fonts within a file. Most files contain one font, but some (mac font suitcases, dfonts, ttc files, svg files, etc) may contain several. If the file contains no fonts (or the file doesn't exist, or the fonts aren't named), a zero length array is returned. It does not open the font. It can execute without a current font.
Open(filename[,flags])
  This makes the font named by filename be the current font. If filename has not yet been loaded into memory it will be loaded now. It can execute without a current font.
  When loading from a ttc file (mac suitcase, dfont, svg, etc), a particular font may be selected by placing the fontname in parens and appending it to the filename, as `Open("gulim.ttc(Dotum)")`
  The optional flags argument current has only one flag in it:
  - 1 => the user does have the appropriate license to examine the font no matter what the fstype setting is.
New()
  This creates a new font. It can execute with no current font.
Close()
  This frees up any memory taken up by the current font and drops it off the list of loaded fonts. After this executes there will be no current font.
Save([filename])
  If no filename is specified then this saves the current font back into its sfd file (if the font has no sfd file then this is an error). With one argument it executes a SaveAs command, saving the current font to that filename.
Generate(filename[,bitmaptype[,fmflags[,res[,mult-sfd-file[,namelist-name]]]]])
  Generates a font. The type of font is determined by the extension of the filename. Valid extensions are:
  - .pfa
  - .pfb
  - .bin (a mac postscript (pfb) resource in a mac binary wrapper)
    .res (on the Mac itself FontForge will put the result directly into a font suitcase file, and the extension should be ".res" rather than ".bin")

    Note: you must also create a bitmap font in NFNT format or the mac will not recognize your postscript font.

  - *%s*.pf[ab] (here more than just an extension is required, the font name must contain a "%s") (splits a big font up into multiple pfb fonts each with 256 characters, making use of the fifth argument to determine how this is done). The "%s" will be replaced by the fontnumber specified in the mult-sfd-file.
  - .mm.pfa (multiple master font in ascii format)
  - .mm.pfb (multiple master font in binary format)
  - .pt3 (type 3)
  - .ps (type 0)
  - .t42 (type 42, truetype wrapped in PostScript)
  - .cid.t42 (type 42 cid font)
  - .cid (non-otf cid font)
  - .cff (bare cff font)
  - .cid.cff (bare cff cid-keyed font)
  - .ttf
  - .sym.ttf (a truetype file with a symbol (custom) encoding)
  - .ttf.bin (a mac truetype resource in a mac binary wrapper)
    suit (on the Mac itself FontForge will put the result directly into a font suitcase file, and the extension should be ".suit" not ".ttf.bin")
  - .dfont (a mac truetype resource in a dfont file)
  - .otf (either cid or not depending on the font)
  - .otf.dfont (a mac opentype resource in a dfont file)
  - .svg (an svg font)
  - <null extension> If you don't want to generate an outline font at all (but do want to provide a filename for bitmap or metrics files) then provide a null extension (ie. `"Times."` but NOT `"Times"`) -- the generated bitmap fonts will have appropriate extensions for their font types, the "." is merely a placeholder.

  If present, bitmaptype may be one of:

  - bdf
  - ttf (for EBDT/bdat table in truetype/opentype)
  - sbit (for bdat table in truetype without any outline font in a dfont wrapper)
  - bin (for nfnt in macbinary)

    NOTE: Mac OS/X does not appear to support NFNT bitmaps. However even though unused itself, an NFNT bitmap must be present for a resource based type1 postscript font to be used. (More accurately the obsolete FOND must be present, and that will only be present if an obsolete NFNT is also present)

  - fnt (For windows FNT format)
  - otb (For X11 opentype bitmap format)
  - pdb (for palm bitmap fonts)
  - pt3 (for a postscript type3 bitmap font)
  - "" for no bitmaps

  Note: If you request bitmap output then all strikes in the current font database will be output, but this command will not create bitmaps, so if there are no strikes in your font database, no strikes will be output (even if you ask for them). If you wish to output bitmaps you must first create them with the BitmapsAvail scripting command or Element->Bitmaps Avail.

  fmflags controls

  - -1 => default (generate an afm file for postscript fonts, never generate a pfm file, full 'post' table, ttf hints)
  - fmflags&1 => generate an afm file (if you are generating a multiple master font then setting this flag means you get several afm files (one for each master design, and one for the default version of the font) and an amfm file)
  - fmflags&2 => generate a pfm file
  - fmflags&4 => generate a short 'post' table with no glyph name info in it.
  - fmflags&8 => do not include ttf instructions
  - fmflags&0x10 => where apple and ms/adobe differ about the format of a true/open type file, use apple's definition (otherwise use ms/adobe)
    Currently this affects bitmaps stored in the font (Apple calls the table 'bdat', ms/adobe 'EBDT'), the PostScript name in the 'name' table (Apple says it must occur exactly once, ms/adobe say at least twice), and whether morx/feat/kern/opbd/prop/lcar or GSUB/GPOS/GDEF tables are generated.
  - fmflags&0x20 => generate a 'PfEd' table and store glyph comments
  - fmflags&0x40 => generate a 'PfEd' table and store glyph colors
  - fmflags&0x80 => generate tables so the font will work on both Apple and MS platforms.
    Apple has screwed up and in Mac 10.4 (Tigger), if OpenType tables are present in a font then the AAT tables will be ignored -- or so I'm told (I can't test this myself). Unfortunately Apple does not implement all of OpenType, so the result is almost certain to be wrong).
  - If you want neither OpenType nor Apple tables (just an old fashioned 'kern' table and nothing else) then set both 0x80 and 0x10.
  - fmflags&0x100 => generate a glyph map file (GID=>glyph name, unicode map). The map file will have extension ".g2n".
  - fmflags&0x200 => generate a 'TeX ' table containing (most) TeX font metrics information
  - fmflags&0x400 => generate an ofm file (for omega)
  - fmflags&0x800 => generate an old style 'kern'ing table. Only meaningful if set with OpenType (GPOS/GSUB) tables and without Apple tables.
  - fmflags&0x10000 => generate a tfm file
  - fmflags&0x40000 => do not do flex hints
  - fmflags&0x80000 => do not include postscript hints
  - fmflags&0x200000 => round postscript coordinates

  res controls the resolution of generated bdf fonts. A value of -1 means fontforge will guess for each strike.

  If the filename contains a "%s" and has either a ".pf[ab]" extension then a "mult-sfd-file" may be present. This is the filename of a file containing the mapping from the current encoding into the subfonts. Here is an example. If this file is not present FontForge will go through its default search process to find a file for the encoding, and if it fails the fonts will not be saved.

GenerateFamily(filename,bitmaptype,fmflags,array-of-font-filenames)
  Generates a mac font family (FOND) from the fonts (which must be loaded) in the array-of-font-filenames. filename, bitmaptype, fmflags are as above.

  >     #!/usr/local/bin/fontforge
  >     a = Array($argc-1)
  >     i = 1
  >     j = 0
  >     while ( i < $argc )
  >     # Open each of the fonts
  >       Open($argv[i], 1)
  >     # and store the filenames of all the styles in the array
  >       a[j] = $filename
  >       j++
  >       i++
  >     endloop

  >     GenerateFamily("All.otf.dfont","dfont",16,a)

ControlAfmLigatureOutput(script,lang,ligature-tag-list)
  All three arguments must be strings. The first two must be strings containing four or fewer characters, the third a string containing a comma separated list of 4 (or fewer) character strings. Ligatures will be placed in an AFM file only if
  - their tags match one of the entries in the list
  - they are active in the given script with the given language ("*" acts as a wildcard for both script and language).

  The default setting is:

  >     ControlAfmLigatureOutput("*","dflt","liga,rlig")

Import(filename[,toback[,flags]])
  Either imports a bitmap font into the database, or imports background image[s] into various glyphs. There may be one or two arguments. The first must be a string representing a filename. The extension of the file determines how the import proceeds.
  - If the extension is ".bdf" then a bdf font will be imported
  - If the extension is ".pcf" then a pcf font will be imported.
  - If the extension is ".ttf" then the EBDT or bdat table of the ttf file will be searched for bitmap fonts
  - If the extension is "pk" then a metafont pk (bitmap font) file will be import and by default placed in the background
  - Otherwise if the extension is an image extension, and any loaded images will be placed in the background.
    - If the filename contains a "*" then it should be a recognized template in which case all images which match that template will be loaded appropriately and stored in the background
    - Otherwise there may be several filenames (separated by semicolons), the first will be placed in the background of the first selected glyph, the second into the background of the second selected glyph, ...
  - If the extension is "eps" then an encapsulated postscript file will be merged into the foreground. The file may be specified as for images (except the extension should be "eps" rather than an image extension). FontForge is limited in its ability to read eps files.
  - If the extension is "svg" then an svg file will be read into the foreground.

  If present the second argument must be an integer, if the first argument is a bitmap font then the second argument controls whether it is imported into the bitmap list (0) or to fill up the backgrounds of glyphs (1). For eps and svg files this argument controls whether the splines are added to the foreground or the background layer of the glyph.

  If there is a third argument it must also be an integer and provides a set of flags controling the behavior of importing an EPS (and in one case SVG too) file.

  - 16 => remove anything currently present (works for SVG & EPS)
  - 8 => correct direction
  - 4 => attempt to handle TeX erasers (stroking with a white pen)
  - 2 => remove overlap
Export(format[,bitmap-size])
  For each selected glyph in the current font, this command will export that glyph into a file in the current directory. Format must be a string and must end with one of
  - eps -- the selected glyphs will have their splines output into eps files. The files will be named "<glyph-name>_<font-name>.eps".
  - pdf -- the selected glyphs will have their splines output into pdf files. The files will be named "<glyph-name>_<font-name>.pdf".
  - svg -- the selected glyphs will have their splines output into svg files. The files will be named "<glyph-name>_<font-name>.svg".
  - fig -- the selected glyphs will have their splines converted (badly) into xfig files. The files will be named "<glyph-name>_<font-name>.fig".
  - xbm -- The second argument specifies a bitmap font size, the selected glyphs in that bitmap font will be output as xbm files. The files will be named "<glyph-name>_<font-name>.xbm".
  - bmp -- The second argument specifies a bitmap font size, the selected glyphs in that bitmap font will be output as bmp files. The files will be named "<glyph-name>_<font-name>.bmp".
  - png -- The second argument specifies a bitmap font size, the selected glyphs in that bitmap font will be output as png files. The files will be named "<glyph-name>_<font-name>.png".

  The format may consist entirely of the filetype (above), or it may include a full filename (with some format control within it) which has the file type as an extension:

  > "Glyph %n from font %f.svg"
  > "U+%U.bmp"

  All characters in the format string except for % are copied verbatim. If there is a % then the following character controls behavior:

  - %n -- inserts the glyph name (or the first 40 characters of it for long names)
  - %f -- inserts the font name (or the first 40 characters)
  - %e -- inserts the glyph's encoding as a decimal integer
  - %u -- inserts the glyph's unicode code point in lower case hex
  - %U -- inserts the glyph's unicode code point in upper case hex
  - %% -- inserts a single '%'
MergeKern(filename)
  Loads Kerning info out of either an afm or a tfm file and merges it into the current font.
PrintSetup(type,[printer[,width,height]])
  Allows you to configure the print command. Type may be a value between 0 and 4
  - 0 => print with lp
  - 1 => print with lpr
  - 2 => output to ghostview
  - 3 => output to PostScript file
  - 4 => other printing command
  - 5 => output to a pdf file

  If the type is 4 (other) and the second argument is specified, then the second argument should be a string containing the "other" printing command.
  If the type is 0 (lp) or 1 (lpr) and the second argument is specified, then the second argument should contain the name of a laser printer
  (If the second argument is a null string neither will be set).

  The third and fourth arguments should specify the page width and height respectively. Units are in 1/72 inches (almost points), so 8.5x11" paper is 612,792 and A4 paper is (about) 595,842.

PrintFont(type[,pointsize[,sample-text/filename[,output-file]]])
  Prints the current font according to the PrintSetup. The values for type are (meanings are described in the section on printing):
  - 0 => Prints a full font display at the given pointsize
  - 1 => Prints selected glyphs to fill page
  - 2 => Prints selected glyphs at multiple pointsizes
  - 3 => Prints a text sample read from a file at the given pointsize(s)
  - 4 => Prints a text sample, except that instead of treating the third argument as a file name it represents the sample itself (in utf-8 encoding)

  The pointsize is either a single integer or an array of integers. It is only meaningful for types 0, 3 and 4. If omitted or set to 0 a default value will be chosen. The font display will only look at one value.

  If you selected print type 3 then you may provide the name of a file containing sample text. This file may either be in ucs2 format (preceded by a 0xfeff value), or in the current default encoding. A null string or an omitted argument will cause FontForge to use a default value.

  If your PrintSetup specified printing to a file (either PostScript or pdf) then the fourth argument provides the filename of the output file.

Quit(status)
  Causes FontForge to exit with the given status (no attempt is made to save unsaved files). This command can execute with no current font.

Cut
  Makes a copy of all selected glyphs and saves it in the clipboard, then clears out the selected glyphs
Copy
  Makes a copy of all selected glyphs.
CopyReference
  Makes references to all selected glyphs and stores them in the clipboard.
CopyWidth
  Stores the widths of all selected glyphs in the clipboard
CopyVWidth
  Stores the vertical widths of all selected glyphs in the clipboard
CopyLBearing
  Stores the left side bearing of all selected glyphs in the clipboard
CopyRBearing
  Stores the right side bearing of all selected glyphs in the clipboard
CopyGlyphFeatures(arg,...)
  This copies features from the currently selected glyph (only one) and stores them in the clipboard.

  arg may be either a string in which case it should be either a four character opentype tag (like "kern") or a mac feature setting (like "<1,1>"). Or it may be an integer in which case it must be the integer representation of one of the above. Or arg may be an array of strings and integers (in this case there may be only one argument).

  The feature 'kern' will match any kerning pair that has the currently selected glyph as the first character of the two. The (made up) feature '_krn' will match any kerning pair that has the currently selected glyph as the last character of the two. Similary for 'vkrn' and '_vkn'.

Paste
  Copies the clipboard into the selected glyphs of the current font (removing what was there before)
Paste Into
  Copies the clipboard into the current font (merging with what was there before)
PasteWithOffset(xoff,yoff)
  Translates the clipboard by xoff,yoff before doing a PasteInto(). Can be used to build accented glyphs.
SameGlyphAs
  If the clipboard contains a reference to a single glyph then this makes all selected glyphs refer to that one.

  Adobe suggests that you avoid this. Use a reference instead. In some situations (I think pdf files is one) having one glyph with several encodings causes problems (Acrobat uses the glyph to back-map through the encoding to work out the unicode code point. But that will fail if a glyph has two unicode code points associated with it).

Clear
  Clears out all selected glyphs
ClearBackground
  Clears the background of all selected glyphs
CopyFgToBd
  Copies all foreground splines into the background in all selected glyphs
Join([fudge])
  Joins open paths in selected glyphs. If fudge is specified then the endpoints only need to be within fudge em-units of each other to be merged.
UnlinkReference
  Unlinks all references within all selected glyphs
SelectAll
  Selects all glyphs
SelectNone
  Deselects all glyphs
SelectInvert()
  Inverts the selection.
Select(arg1, arg2, ...)
  This clears out the current selection, then for each pair of arguments it selects all glyphs between (inclusive) the bounds specified by the pair. If there is a final singleton argument then that single glyph will be selected. An argument may be specified by:
  - an integer which specifies the location in the current font's encoding
  - a postscript unicode name which gets mapped into the current font's encoding
  - a unicode code point (0u61) which gets mapped to the current font's encoding
  - If Select is given exactly one argument and that argument is an array then the selection will be set to that specified in the array. So array[0] would set the selection of the glyph at encoding 0 and so forth. The array may have a different number of elements from that number of glyphs in the font but should otherwise be in the same format as that returned by the $selection psuedo-variable.
SelectMore(arg1, arg2, ...)
  The same as the previous command except that it does not clear the selection initially, so it extends the current selection.
SelectFewer(arg1, arg2, ...)
  The same as the previous command except that it clears the selection on the indicated glyphs, so it reduces the current selection.
SelectSingletons(arg1, ...)
  Selects its arguments without looking for ranges.
SelectMoreSingletons(arg1, ...)
SelectFewerSingletons(arg1, ...)
SelectIf(arg1,arg2, ...)
  The same as Select() except that instead of signalling an error when a glyph is not in the font it returns an error code.
  - 0 => there were no errors but no glyphs were selected
  - <a positive number> => there were no errors and this many glyphs were selected
  - -2 => there was an error and no glyphs were selected
  - -1 => there was an error and at least one glyph was selected before that.
SelectChanged([merge])
  Selects all changed glyphs. If merge is true, will or the current selection with the new one.
SelectHintingNeeded([merge])
  Selects all glyphs which FontForge thinks need their hints updated.
SelectByATT(type,tags,contents,search-type)
  See the Select By ATT menu command. The values for type are:

  `"Position"` | Simple position
  `"Pair"` | Pairwise positioning (but not kerning)
  `"Substitution"` | Simple substitution
  `"AltSubs"` | Alternate substitution
  `"MultSubs"` | Multiple substitution
  `"Ligature"` | Ligature
  `"LCaret"` | Ligature caret
  `"Kern"` | Kerning
  `"VKern"` | Vertical Kerning
  `"Anchor"` | Anchor class

  And for search_type

  1. Select Results
  2. Merge Selection
  3. Restrict Selection

Reencode(encoding-name[,force])
  Reencodes the current font into the given encoding which may be:
  compacted,original,
  iso8859-1, isolatin1, latin1, iso8859-2, latin2, iso8859-3, latin3, iso8859-4, latin4, iso8859-5, iso8859-6, iso8859-7, iso8859-8, iso8859-9, iso8859-10, isothai, iso8859-13, iso8859-14, iso8859-15, latin0, koi8-r, jis201, jisx0201, AdobeStandardEncoding, win, mac, symbol, wansung, big5, johab, jis208, jisx0208, jis212, jisx0212, sjis, gh2312, gb2312packed, unicode, iso10646-1, TeX-Base-Encoding, one of the user defined encodings.
  You may also specify that you want to force the encoding to be the given one.
  Note: some encodings are specified by glyph names (ie. user defined encodings specified as postscript encoding arrays) others are specified as lists of unicode code points (most built in encodings except for AdobeStandard and TeX, user defined encodings specified by codepoints). If you reencode to an encoding defined by glyph names, then ff will first move glyphs to the appropriate slots, and then force any glyphs with the wrong name to have the correct one. The most obvious example of this is the fi ligature: AdobeStandard says it should be named "fi", modern fonts tend to call it "f_i". Reencoding to AdobeStandard will move this glyph to the right slot, and then name it "fi".
RenameGlyphs(namelist-name)
  Renames all the glyphs in the current font according to the namelist.
SetCharCnt(cnt)
  Sets the number of encoding slots in the font.
LoadEncodingFile(filename)
LoadTableFromFile(tag,filename)
  Both arguments should be strings, the first should be a 4 letter table tag. The file will be read and preserved in the font as the contents of the table with the specified tag. Don't use a tag that ff thinks it understands!
SaveTableToFile(tag,filename)
  Both arguments should be strings, the first should be a 4 letter table tag. The list of preserved tables will be searched for a table with the given tag, and saved to the file.
RemovePreservedTable(tag)
  Searches for a preserved table with the given tag, and removes it from the font.
HasPreservedTable(tag)
  Returns true if the font contains a preserved table with the given tag.
SetFontOrder(order)
  Sets the font's order. Order must be either 2 (quadratic) or 3 (cubic). It returns the old order.
SetFontHasVerticalMetrics(flag)
  Sets whether the font has vertical metrics or not. A 0 value means it does not, any other value means it does. Returns the old setting.
SetFontNames(fontname[,family[,fullname[,weight[,copyright-notice[,fontversion]]]]])
  Sets various postscript names associated with a font. If a name is omitted (or is the empty string) it will not be changed.
SetFondName(fondname)
  Sets the FOND name of the font.
SetItalicAngle(angle[,denom])
  Sets the postscript italic angle field appropriately. If denom is specified then angle will be divided by denom before setting the italic angle field (a hack to get real values). The angle should be in degrees.
SetMacStyle(val)
SetMacStyle(str)
  The argument may be either an integer or a string. If an integer it is a set of bits expressing styles as defined on the mac

  0x01 | Bold
  0x02 | Italic
  0x04 | Underline
  0x08 | Outline
  0x10 | Shadow
  0x20 | Condensed
  0x40 | Extended
  -1 | FontForge should guess the styles from the fontname

  The bits 0x20 and 0x40 (condensed and extended) may not both be set.

  If the argument is a string then the string should be the concatenation of various style names, as "Bold Italic Condensed"

SetTTFName(lang,nameid,utf8-string)
  Sets the indicated truetype name in the MS platform. Lang must be one of the language/locales supported by MS, and nameid must be one of the small integers used to indicate a standard name, while the final argument should be a utf8 encoded string which will become the value of that entry. A null string ("") may be used to clear an entry.
  Example: To set the SubFamily string in the American English language/locale
  `SetTTFName(0x409,2,"Bold Oblique")`
GetTTFName(lang,nameid)
  The lang and nameid arguments are as above. This returns the current value as a utf8 encoded string. Combinations which are not present will be returned as "".
SetPanose(array) SetPanose(index,value)
  This sets the panose values for the font. Either it takes an array of 10 integers and sets all the values, or it takes two integer arguments and sets `font.panose[index] = value`
SetOS2Value(field-name,field-value)
  This sets one of the fields of the OS/2 table to the given value. The field-name must be one of the strings listed below:

  `Weight, Width, FSType, IBMFamily, VendorID, Panose,
  WinAscent, WinAscentIsOffset`

  These are equivalent to the WinAscent field & []Offset check box in Font Info->OS/2->Misc. Where WinAscentOffset controls whether WinAscent is treated as an absolute number or as relative to the expected number.

  `WinDescent, WinDescentIsOffset,
  TypoAscent, TypoAscentIsOffset,
  TypoDescent, TypoDescentIsOffset,
  HHeadAscent, HHeadAscentIsOffset,
  HHeadDescent, HHeadDescentIsOffset,
  TypoLineGap, HHeadLineGap, VHeadLineGap,
  SubXSize, SubYSize, SubXOffset, SubYOffset`

  Sets the Subscript x/y sizes/offsets.

  `SupXSize, SupYSize, SupXOffset, SupYOffset`

  Sets the Superscript x/y sizes/offsets.

  `StrikeOutSize, StrikeOutPos`

  Usually the second argument is an integer but `VendorID` takes a 4 character ASCII string, and `Panose` takes a 10 element integer array.

GetOS2Value(field-name)
  The argument takes the same set of tag strings. `VendorId` returns a string, and `Panose` returns an array. The others return integers.
SetMaxpValue(field-name,value)
  The field-name must be a string and one of: `Zones, TwilightPntCnt, StorageCnt, MaxStackDepth, FDEFs,` or `IDEFs`. Value must be an integer.
GetMaxpValue(field-name)
  Field name must be as above.
SetUniqueID(value)
  Sets the postscript uniqueid field as requested. If you give a value of 0 then FontForge will pick a reasonable random number for you.
SetTeXParams(type,design-size,slant,space,stretch,shrink,xheight,quad,extraspace[...])
  Sets the TeX (text) font parameters for the font.
  Type may be 1, 2 or 3, depending on whether the font is text, math or math extension.
  DesignSize is the pointsize the font was designed for.
  The remaining parameters are described in Knuth's The MetaFont Book, pp. 98-100.
  Slant is expressed as a percentage. All the others are expressed in em-units.
  If type is 1 then the 9 indicated arguments are required. If type is 2 then 24 arguments are required (the remaining 15 are described in the metafont book). If type is 3 then 15 arguments are required.
GetTeXParam(index)
  If index == -1 then the tex font type will be returned (text==0, math==1, math extended=2)
  Else index is used to index into the font's tex params array.
SetCharName(name[,set-from-name-flag])
  Sets the currently selected glyph to have the given name. If set-from-name-flag is absent or is present and true then it will also set the unicode value and the ligature string to match the name.
SetUnicodeValue(uni[,set-from-value-flag])
  Sets the currently selected glyph to have the given unicode value. If set-from-value-flag is absent or is present and true then it will also set the name and the ligature string to match the value.
SetGlyphClass(class-name)
  Sets the class on all selected glyphs to be one of "automatic", "none", "base", "ligature", "mark" or "component".
SetCharColor(color)
  Sets any currently selected glyphs to have the given color (expressed as 24 bit rgb (0xff0000 is red) with the special value of -2 meaning the default color.
SetCharComment(comment)
  Sets the currently selected glyph to have the given comment. The comment is converted via the current encoding to unicode.
SetGlyphChanged(flag)
  If flag is 1 sets all selected glyphs to be changed, if flag is 0 sets them unchanged.
BitmapsAvail(sizes)
  Controls what bitmap sizes are stored in the font's database. It is passed an array of sizes. If a size is specified which is not in the font database it will be generated. If a size is not specified which is in the font database it will be removed. A size which is specified and present in the font database will not be touched.
  If you want to specify greymap fonts then the low-order 16 bits will be the pixel size and the high order 16 bits will specify the bits/pixel. Thus 0x8000c would be a 12 pixel font with 8 bits per pixel, while either 0xc or 0x1000c could be used to refer to a 12 pixel bitmap font.
BitmapsRegen(sizes)
  Allows you to update specific bitmaps in an already generated bitmap font. It will regenerate the bitmaps of all selected glyphs at the specified pixelsizes.
ApplySubstitution(script,lang,tag)
  All three arguments must be strings of no more that four characters (shorter strings will be padded with blanks to become 4 character strings). For each selected glyph this command will look up that glyph's list of substitutions, and if it finds a substitution with the tag "tag" (and if that substitution matches the script and language combination) then it will apply the substitution-- that is it will find the variant glyph specified in the substitution and replace the current glyph with the variant, and clear the variant.

  FontForge recognizes the string "*" as a wildcard for both the script and the language (not for the tag though). So if you wish to replace all glyphs with their vertical variants:

  >     SelectAll()
  >     ApplySubstitution("*","*","vrt2")

Transform(t1,t2,t3,t4,t5,t6)
  Each argument will be divided by 100. and then all selected glyphs will be transformed by this matrix
HFlip([about-x])
  All selected glyphs will be horizontally flipped about the vertical line through x=about-x. If no argument is given then all selected glyphs will be flipped about their central point.
VFlip([about-y])
  All selected glyphs will be vertically flipped about the horizontal line through y=about-y. If no argument is given then all selected glyphs will be flipped about their central point.
Rotate(angle[,ox,oy])
  Rotates all selected glyph the specified number of degrees. If the last two args are specified they provide the origin of the rotation, otherwise the center of the glyph is used.
Scale(factor[,yfactor][,ox,oy])
  All selected glyphs will be scaled (scale factors are in percent)
  - with one argument they will be scaled uniformly about the glyph's center point
  - with two arguments the first specifies the scale factor for x, the second for y. Again scaling will be about the center point
  - with three arguments they will be scaled uniformly about the specified center
  - with four arguments they will be scaled differently about the specified center
Skew(angle[,ox,oy])
Skew(angle-num,angle-denom[,ox,oy])
  All selected glyphs will be skewed by the given angle.
Move(delta-x,delta-y)
  All selected glyphs will have their points moved the given amount.
MoveReference(delta-x,delta-y,[refname/ref-unicode]+)
  References may be identified either by a string containing the name of the glyph being refered to, or an integer containing the unicode code point of the glyph being refered to, there may be an arbetrary (positive) number of references specified. Each selected glyph will be searched for references that match the name/unicode-values given, all references found will be moved by the specified offsets.

  >     MoveReference(300,0,"acute",0xb4)

  > Will move any acute or grave references 300 em-units horizontally from where they currently are

PositionReference(x,y,[refname/ref-unicode]+)
  References may be identified either by a string containing the name of the glyph being refered to, or an integer containing the unicode code point of the glyph being refered to, there may be an arbetrary (positive) number of references specified. Each selected glyph will be searched for references that match the name/unicode-values given, all references found will be at the specified location.

  >     PositionReference(0,0,"circumflex")

  > Will position any references to circumflex so that they are where the base circumflex is

ScaleToEm(em-size)
ScaleToEm(ascent,descent)
  Change the font's ascent and descent and scale everything in the font to be in the same proportion to the new em (which is the sum of ascent and descent) value that it was to the old value.
NonLinearTransform(x-expression,y-expression)
  Takes two string arguments which must contain valid expressions of x and y and transforms all selected glyphs using those expressions.

  >     <e0> := "x" | "y" | "-" <e0> | "!" <e0> | "(" <expr> ")" |
  >     	"sin" "(" <expr> ")" | "cos" "(" <expr> ")" | "tan" "(" <expr> ")" |
  >     	"log" "(" <expr> ")" | "exp" "(" <expr> ")" | "sqrt" "(" <expr> ")" |
  >     	"abs" "(" <expr> ")" |
  >     	"rint" "(" <expr> ")" | "float" "(" <expr> ")" | "ceil" "(" <expr> ")"
  >     <e1> := <e0> "^" <e1>
  >     <e2> := <e1> "*" <e2> | <e1> "/" <e2> | <e1> "%" <e2>
  >     <e3> := <e2> "+" <e3> | <e2> "-" <e3>
  >     <e4> := <e3> "==" <e4> | <e3> "!=" <e4> |
  >     	<e3> ">=" <e4> | <e3> ">" <e4> |
  >     	<e3> "<=" <e4> | <e3> "<" <e4>
  >     <e5> := <e4> "&&" <e5> | <e4> "||" <e5>
  >     <expr> := <e5> "?" <expr> ":"

  Example: To do a perspective transformation with a vanishing point at (200,300):

  >     NonLinearTrans("200+(x-200)*abs(y-300)/300","y")

  This command is not available in the default build, you must modify the file `configure-fontforge.h` and then rebuild FontForge.

ExpandStroke(width)
ExpandStroke(width,line cap, line join)
ExpandStroke(width,line cap, line join,0,removeinternal /external flag)
ExpandStroke(width,calligraphic-angle,height-numerator,height-denom)
ExpandStroke(width,calligraphic-angle,height-numerator,height-denom, 0, remove internal/external flag)
  In the first format a line cap of "butt" and line join of "round" are implied.
  A value of 1 for remove internal/external will remove the internal contour, a value of 2 will remove the external contour.
  The first three calls simulate the PostScript "stroke" command, the two final simulate a caligraphic pen.
  Width
    In the PostScript "stroke" command the width is the distance between the two generated curves. To be more precise, at ever point on the original curve, a point will be added to each of the new curves at width/2 units as measured on a vector normal to the direction of the original curve at that point.
    In a caligraphic pen, the width is the width of the pen used to draw the curve.
  Line-cap
    Can have one of three values: 0=> butt, 1=>round, 2=>square
  Line-join
    Can have one of three values: 0=>miter, 1=>round, 2=>bevel
  caligraphic-angle
    the (fixed) angle at which the pen is held.
  height-numerator/denominator
    These two values specify a ratio between the height and the width
    height = numerator * width / denominator
    (the scripting language only deals in integers, so when fractions are needed this kludge is used)
  remove internal/external contour flags
    1 => remove internal contour
    2=> remove external contour
    (you may not remove both contours)
    4 => run remove overlap on result (buggy)
Outline(width)
  Strokes all selected glyphs with a stroke of the specified width (internal to the glyphs). The bounding box of the glyph will not change. In other words it produces what the mac calls the "Outline Style".
Inline(width,gap)
  Produces an outline as above, and then shrinks the glyph so that it fits inside the outline. In other words, it produces an inlined glyph.
Shadow(angle,outline-width,shadow-width)
  Converts the selected glyphs into shadowed versions of themselves.
Wireframe(angle,outline-width,shadow-width)
  Converts the selected glyphs into wireframed versions of themselves.
RemoveOverlap()
  Does the obvious.
OverlapIntersect()
  Removes everything but the intersection.
FindIntersections()
  Finds everywhere that splines cross and creates points there.
Simplify()
Simplify(flags,error[,tan_bounds[,bump_size[,error_denom,line_len_max]]])
  With no arguments it does the obvious. If flags is -1 it does a Cleanup, otherwise flags should be a bitwise or of
  - 1 -- Slopes may change at the end points.
  - 2 -- Points which are extremum may be removed
  - 4 -- Corner points may be smoothed into curves
  - 8 -- Smoothed points should be snapped to a horizontal or vertical tangent if they are close
  - 16 -- Remove bumps from lines
  - 32 -- make lines which are close to horizontal/vertical be horizontal/vertical
  - 64 -- merge lines which are nearly parallel into one
  - 128 -- change which point is the start point if a contour's start point is not an extremum

  The error argument is the number of font units by which the modified path is allowed to stray from the true path.
  The tan_bounds argument specifies the tangent of the angle between the curves at which smoothing will stop (argument is multiplied by .01 before use).
  And bump_size gives the maximum distance a bump can move from the line and still be smoothed out.
  If a fifth argument is given then it will be treated as the denominator of the error term (so users can express fraction pixel distances).
  Generally it is a bad idea to merge a line segment with any other than a colinear line segment. The longer the line segment, the more likely that such a merge will produce unpleasing results. The sixth argument, if present, specifies the maximum length for lines which may be merged (anything longer will not be merged).

NearlyHvCps([error[,err-denom]])
  Checks for control points which are almost, but not quite horzontal or vertical (where almost means (say) that `abs( (control point).x - point.x ) < error`, where error is either:

  .1 | if no arguments are given
  first-arg | if one argument is given
  first-arg/second-arg | if two arguments are given

NearlyHvLines([error[,err-denom]])
  Checks for lines which are almost, but not quite horzontal or vertical (where almost means (say) that `abs( (end point).x - (start point).x ) < error`, where error is either:

  .1 | if no arguments are given
  first-arg | if one argument is given
  first-arg/second-arg | if two arguments are given

NearlyLines(error)
  Checks for splines that are nearly linear, and makes them so. A spline is nearly linear if the maximum deviation of the spline from the line between the spline's endpoints is less than error.
AddExtrema()
RoundToInt([factor])
  Rounds all points/hints/reference-offsets to be integers. If the the "factor" argument is specified then it rounds like `rint(factor * x) / factor`, in other words if you set factor to 100 then it will round to hundredths.
RoundToCluster([within[,max]])
  The first two provide a fraction that indicates a value within which similar coordinates will be bundled together. Max indicates how many "within"s from the center point it will go if there are a chain of points each within "within" of the previous one. So

  >      RoundToCluster(.1,.5)

  Will merge coordinates within .1 em-unit of each other. A sequence like `-.1,-.05,0,.05,.1,.15` will all be merged together because each is within .1 of the next, and none is more than .5 from the center.

AutoTrace()
CorrectDirection([unlinkrefs])
  If the an argument is present it must be integral and is treated as a flag controlling whether flipped references should be unlinked before the CorrectDirection code runs. If the argument is not present, or if it has a non-zero value then flipped references will be unlinked.
DefaultATT(tag)
  For all selected glyphs make a guess as to what might be an appropriate value for the given tag. If the tag is "*" then FontForge will apply guesses for all features it can.
AddATT(type,script-lang,tag,flags,variant)
AddATT("Position",script-lang,tag,flags,xoff,yoff,h_adv_off,v_adv_off)
AddATT("Pair",script-lang,tag,flags,name,xoff,yoff,h_adv_off,v_adv_off,xoff2,yoff2,h_adv_off2,v_adv_off2)
  Allows you to add an Advanced Typography feature to a single selected glyph. The first argument may be either: Position, Pair, Substitution, AltSubs, MultSubs or Ligature. The second argument should be a script-lang list where each 4-character script name is followed by a comma separated list of 4 character language names (with the languages enclosed in curly braces) -- or the special string "Nested". As:
  `grek{dflt} latn{dflt,VIT ,ROM }`
  The third arg should be a 4 character opentype feature tag (or apple feature/setting).

  The fourth argument should be the otf flags (or -1 to make FontForge guess appropriate flags).

  - 0x0001 => RightToLeft
  - 0x0002 => IgnoreBaseGlyphs
  - 0x0004 => IgnoreLigatures
  - 0x0008 => IgnoreMarks
  - 0x00F0 => not defined
  - 0xFF00 => not supported

  The remaining argument(s) vary depending on the value of the first (type) argument. For Position tags there are 4 integral arguments which specify how this feature modifies the metrics of this glyph. For Pair type the next argument is the name of the other glyph in the pair followed by 8 integral arguments, the first 4 specify the changes in positioning to the first glyph, the next four the changes for the second char. For substitution tags the fifth argument is the name of another glyph which will replace the current one. For an AltSubs tag the argument is a space separated list of glyph names any of which will replace the current one. For a MultSubs the argument is a space separated list of names all of which will replace the current one. For a Ligature the argument is a space separated list of glyph names all of which will be replaced by the current glyph.

RemoveATT(type,script-lang,tag)
  Removes any feature tags which match the arguments (which are essentially the same as above, except that any of them may be "*" which will match anything).
CheckForAnchorClass(name)
  Returns 1 if the current font contains an Anchor class with the given name (which must be in utf8).
AddAnchorClass(name,type,script-lang,tag,flags,merge-with)
  These mirror the values of the Anchor class dialog of Element->Font Info. The first argument should be a utf8 encoded name for the anchor class. The second should be one of the strings "default", "mk-mk", or "cursive". The third should be a script-lang string like:
  `grek{dflt} latn{dflt,VIT ,ROM }`
  The fourth arg should be a 4 character opentype feature tag. The fifth argument should be the otf flags (or -1 to make FontForge guess appropriate flags). The sixth and last argument should be the name of another AnchorClass to be merged into the same lookup (or a null string if this class merges with no other class yet).
RemoveAnchorClass(name)
  Removes the named AnchorClass (and all associated points) from the font.
AddAnchorPoint(name,type,x,y[,lig-index])
  Adds an AnchorPoint to the currently selected glyph. The first argument is the name of the AnchorClass. The second should be one of the strings: "mark", "basechar", "baselig", "basemark", "cursentry" , "cursexit" or "default" ("default" tries to guess an appropriate setting for you). The next two values specify the location of the point. The final argument is only present for things of type "baselig".
BuildComposite()
BuildAccented()
BuildDuplicate()
AddAccent(accent[,pos])
  There must be exactly one glyph selected. That glyph must contain at least one reference (and the least recently added reference must be the base glyph -- the letter on which the accent is placed). The first argument should be either the glyph-name of an accent, or the unicode code point of that accent (and it should be in the font). The second argument, if present indicates how the accent should be positioned... if omitted a default position will be chosen from the unicode value for the accent, this argument is the or of the following flags:

  0x100 | Above
  0x200 | Below
  0x400 | Overstrike
  0x800 | Left
  0x1000 | Right
  0x4000 | Center Left
  0x8000 | Center Right
  0x10000 | Centered Outside
  0x20000 | Outside
  0x40000 | Left Edge
  0x80000 | Right Edge
  0x100000 | Touching

ReplaceWithReference([fudge])
  Finds any glyph which contains an inline copy of one of the selected glyphs, and converts that copy into a reference to the appropriate glyph. Selection is changed to the set of glyphs which the command alters.

  If specified the fudge argument specifies the error allowed for coordinate differences.

MergeFonts(other-font-name[,flags])
  Loads other-font-name, and extracts any glyphs from it which are not in the current font and moves them to the current font. The flags argument is the same as that for Open. Currently the only relevant flag is to say that you do have a license to use a font with fstype=2.
InterpolateFonts(percentage,other-font-name[,flags])
  Interpolates a font which is percentage of the way from the current font to the one specified by other-font-name (note: percentage may be negative or more than 100, in which case we extrapolate a font). This command changes the current font to be the new font. NOTE: You will need to set the fontname of this new font. The flag argument is the same as for Open.
DefaultUseMyMetrics()
  Looks at all selected glyphs. If any glyph contains references, does not have the "USE-MY-METRICS" bit set on any of those references, and if one of those references has the same width as the current glyph, and has an identity transformation matrix, then set the bit on that reference.
DefaultRoundToGrid()
  Looks at all selected glyphs, if any reference is not positioned by point matching, then FontForge will set the truetype "ROUND-TO-GRID" flag for the reference.

AutoHint()
SubstitutionPoints()
AutoCounter()
DontAutoHint()
AutoInstr()
AddInstrs(thingamy,replace,instrs)
  Where thingamy is a string, either "fpgm" or "prep" in which case it refers to that truetype table (which will be created if need be), or a glyph-name in which case it refers to that glyph, or a null string in which case any selected characters will be used.
  Where replace is an integer. If zero then the instructions will be appended to any already present. If non-zero then the instructions will replace those already present.
  And instrs is a string containing fontforge's human readable version of tt instructions, as "`IUP[x]\nIUP[y]`"
ClearInstrs()
  From selected glyphs
ClearTable(tag)
  Removes the table named tag. This may be 'fpgm', 'prep', 'cvt ', 'maxp' or any user defined tables. It returns 1 if it found (and removed) the table, 0 if the table was not present.
FindOrAddCvtIndex(value[,sign-matters])
  Returns the index in the cvt table of the given value. If the value does not exist in the table it will be added, and an index at the end of the table will be returned. Most tt instructions ignore the sign of items in the cvt table, but a few care. Usually this command stores the absolute value of value, but if sign-matters is present and non-zero a negative value can be looked up (or added).
ReplaceCvtAt(index,value)
  Change the cvt table at the given index to have the new value.
GetCvtAt(index)
  Return the value in the cvt table at the given index.
PrivateToCvt()
  Adds the standard numeric entries in the Private dictionary into the cvt table.
ClearHints()
AddHHint(start,width)
  Adds horizontal stem hint to any selected glyphs. The hint starts at location "start" and is width wide. A hint will be added to all selected glyphs.
AddVHint(start,width)
  Adds a vertical stem hint to any selected glyphs. The hint starts at location "start" and is width wide. A hint will be added to all selected glyphs.
ClearCharCounterMasks()
  Clears any counter masks from the (one) selected glyph.
SetCharCounterMask(cg,hint-index,hint-index,...)
  Creates or sets the counter mask at index cg to contain the hints listed. Hint index 0 corresponds to the first hstem hint, index 1 to the second hstem hint, etc. vstem hints follow hstems.
ReplaceCharCounterMasks(array)
  This requires that there be exactly one glyph selected. It will create a set of counter masks for that glyph. The single argument must be an array of twelve element arrays of integers (in c this would be "int array[][12]"). This is the format of a type2 counter mask. The number of elements in the top level array is the number of counter groups to be specified. The nested array thus corresponds to a counter mask, and is treated as an array of bytes. Each bit in the byte specifies whether the corresponding hint is active in this counter. (there are at most 96 hints, so at most 12 bytes). Array[i][0]&0x80 corresponds to the first horizontal stem hint, Array[i][0]&0x40 corresponds to the second, Array[i][1]&0x80 corresponds to the eighth hint, etc.
ClearPrivateEntry(key)
  Removes the entry indexed by the given key from the private dictionary of the font.
ChangePrivateEntry(key,val)
  Changes (or adds if the key is not already present) the value in the dictionary indexed by key. (all values must be strings even if they represent numbers in PostScript)
GetPrivateEntry(key)
  Returns the entry indexed by key in the private dictionary. All return values will be strings. If an entry does not exist a null string is returned.
HasPrivateEntry(key)
  Returns whether key exists in the private dictionary.
SelectBitmap(size)
  In a bitmap only font this selects which bitmap strike will be used for units in the following metrics commands. If no bitmap is selected, then the units should be in em-units, otherwise units will be in pixels of the given bitmap strike. The size should be the pixelsize of the font. If you use anti-aliased fonts then size should be set to (depth<<16)|pixel_size. A value of -1 for size deselects all bitmaps (units become em-units).
SetWidth(width[,relative])
  If the second argument is absent or zero then the width will be set to the first argument, if the second argument is 1 then the width will be incremented by the first, and if the argument is 2 then the width will be scaled by <first argument>/100.0 . In bitmap only fonts see the comment at SelectBitmap about units.
SetVWidth(vertical-width[,relative])
  If the second argument is absent or zero then the vertical width will be set to the first argument, if the second argument is 1 then the vertical width will be incremented by the first, and if the argument is 2 then the vertical width will be scaled by <first argument>/100.0 . In bitmap only fonts see the comment at SelectBitmap about units.
SetLBearing(lbearing[,relative])
  If the second argument is absent or zero then the left bearing will be set to the first argument, if the second argument is 1 then the left bearing will be incremented by the first, and if the argument is 2 then the left bearing will be scaled by <first argument>/100.0 . In bitmap only fonts see the comment at SelectBitmap about units.
SetRBearing(rbearing[,relative])
  If the second argument is absent or zero then the right bearing will be set to the first argument, if the second argument is 1 then the right bearing will be incremented by the first, and if the argument is 2 then the right bearing will be scaled by <first argument>/100.0 . In bitmap only fonts see the comment at SelectBitmap about units.
CenterInWidth()
AutoWidth(spacing)
  Guesses at the widths of all selected glyphs so that two adjacent "I" glyphs will appear to be spacing em-units apart. (if spacing is the negative of the em-size (sum of ascent and descent) then a default value will be used).
AutoKern(spacing,threshold[,kernfile])
  (AutoKern doesn't work well in general)
  Guesses at kerning pairs by looking at all selected glyphs, or if a kernfile is specified, FontForge will read the kern pairs out of the file.
SetKern(ch2,offset)
  Sets the kern between any selected glyphs and the glyph ch2 to be offset. The first argument may be specified as in Select(), the second is an integer representing the kern offset.
RemoveAllKerns()
  Removes all kern pairs and classes from the current font.
SetVKern(ch2,offset)
  Sets the kern between any selected glyphs and the glyph ch2 to be offset. The first argument may be specified as in Select(), the second is an integer representing the kern offset.
VKernFromHKern()
  Removes all vertical kern pairs and classes from the current font, and then generates new vertical kerning pairs by copying the horizontal kerning data for a pair of glyphs to the vertically rotated versions of those glyphs.
RemoveAllVKerns()
  Removes all vertical kern pairs and classes from the current font.

MMInstanceNames()
  Returns an array containing the names of all instance fonts in a multi master set.
MMAxisNames()
  Returns an array containing the names of all axes in a multi master set.
MMAxisBounds(axis)
  Axis is an integer less than the number of axes in the mm font. Returns an array containing the lower bound, default value and upper bound. Note each value is multiplied by 65536 (because they need not be integers on the mac, and ff doesn't support real values).

  (The default value is a GX Var concept. FF simulates a reasonable value for true multiple master fonts).

MMWeightedName()
  Returns the name of the weighted font in a multi master set.
MMChangeInstance(instance)
  Where instance is either a font name or a small integer. If passed a string FontForge searches through all fonts in the multi master font set (instance fonts and the weighted font) and changes the current font to the indicated one. If passed a small integer, then -1 indicates the weighted font and values between [0,$mmcount) represent that specific instance in the font set.
MMChangeWeight(weights)
  Weights is an array of integers, one for each axis. Each value should be 65536 times the desired value (to deal with mac blends which tend to be small real numbers). This command changes the current multiple master font to have a different default weight, and sets that to be the current instance.
MMBlendToNewFont(weights)
  Weights is an array of integers, one for each axis. Each value should be 65536 times the desired value (to deal with mac blends which tend to be small real numbers). This command creates a completely new font by blending the mm font and sets the current font to the new font.

CIDChangeSubFont(new-sub-font-name)
  If the current font is a cid keyed font, this command changes the active sub-font to be the one specified (the string should be the postscript FontName of the subfont)
CIDSetFontNames(fontname[,family[,fullname[,weight[,copyright-notice]]]])
  Sets various postscript names associated with the top level cid font. If a name is omitted (or is the empty string) it will not be changed. (this is just like SetFontNames except it works on the top level cid font rather than the current font).
CIDFlatten()
  Flattens a cid-keyed font.
CIDFlattenByCMap(cmap-filename)
  Flattens a cid-keyed font, producing a font encoded with the result of the CMAP file.
ConvertToCID(registry, ordering, supplement)
  Converts current font to a CID-keyed font using given registry, ordering and supplement. registry and ordering must be strings, supplement must be a integer.
ConvertByCMap(cmapfilename)
  Converts current font to a CID-keyed font using specified CMap file. cmapfilename must be a path name of a file conforming Adobe CMap File Format.

CharCnt()
  Returns the number of encoding slots (or encoding slots + unencoded glyphs) in the current font
InFont(arg)
  Returns whether the argument is in the font. The argument may be an integer in which case true is returned if the value is >= 0 and < total number of glyphs in the font. Otherwise if the argument is a unicode code point or a postscript glyph name, true is returned if that glyph is in the font.
WorthOutputting([arg])
  If there is no argument then a single glyph should be selected and the function applies to that glyph, otherwise arg is as above. This returns true if the glyph contains any splines, references, images or has had its width set.
DrawsSomething([arg])
  Arg is as above. This returns true if the glyph contains any splines, references or images.
CompareGlyphs([pt_err[,spline_err[,pixel_off_frac[,bb_err[,compare_hints[,report_diffs_as_errors]]]]]])
  This function compares two versions of one or several glyphs. It looks at any selected glyphs in the font and compares them to an equivalent glyph in the clipboard (there must be the same number of selected glyphs as glyphs in the clipboard).
  - It checks to make sure the advance width of each glyph pair is similar
  - It checks to make sure that each contains the same set of references
  - It checks to make sure that all points (both base and control) are within pt_err of each other
  - If that fails then it performs a slower check to see if points lying along the contours have equivalent points in the other glyph (that is: If you have simplified a glyph and are comparing it to the original, this check should pass it while the previous check would fail).
  - Optionally you may check that the bitmaps match.
  - Optionally you may check if hints (and hintmasks) match.

  The first argument controls the accuracy with which points must match. A value of 0 is an exact match and will also check hints. If you provide a negative value then this test will be skipped.

  The second argument controls the accuracy with which the contour check must match. A value of 0 will not work due to rounding errors in the process. A negative value will skip the test.

  The third argument controls bitmap tests. A negative value (the default) will mean no bitmap tests are done. A value of 0 requires an exact match of the bitmap. A value between 0 and 1 specifies the fraction of the pixel range that will be accepted for a match (so in a greymap with a depth of 8 the pixel range in 256, and a fraction value of .25 would mean any pixel value within 64 (.25*256) would match).

  The fourth argument controls how different the bounding boxes of anti-aliased bitmaps can be (the bounding boxes of bitmaps with depth 1 must match exactly)

  The fifth argument controls whether to tests hints and hintmasks. A value of 1 tests hints, 2 tests hintmasks and 3 tests both, a value of 7 will test hintmasks only in glyphs with conflicts.

  Normally this function treats any differences it finds as errors and stops the script. If you set the sixth argument to 0 then it will return a value which ors the following flags together (some flags indicate errors, others unusual conditions, others success -- the function will never return both an error and success flag, but it can return several success flags at once if you are comparing more than one glyph)

  1 | Different numbers of contours in a glyph
  2 | A contour in one glyph is open when the corresponding contour is closed
  4 | Disordered contours (contours are in different orders in the two glyphs)
  8 | Disordered start (the start point is at a different place in the two glyphs)
  16 | Disordered direction (the contour is clockwise in one and counter in the other)
  32 | Glyphs match by checking points
  64 | Glyphs match by checking the contours
  128 | Outline glyphs do not match
  256 | Different references in the two glyphs (or different transformation matrices)
  512 | Different advance widths in the two glyphs
  1024 | Different vertical advance widths in the two glyphs
  2048 | Different hints in the two glyphs
  4096 | Different hintmasks in the two glyphs
  8192 | Different numbers of layers in the two glyphs
  16384 | Contours do not match in the two glyphs
  32768 | We only find a match after we have unlinked references
  65536 | Bitmap glyphs have different depths
  2*65536 | Bitmap glyphs have different bounding boxes
  4*65536 | Bitmaps are different
  8*65536 | Bitmap glyphs do not match (set with all the above)
  16*65536 | Bitmap glyphs match

CompareFonts(other-font-filename,output-filename,flags)
  This will compare the current font with the font in `other-font-filename` (which must already have been opened). It will write the results to the `output-filename`, you may use "-" to send the output to stdout. The `flags` argument controls what will be compared.

  flags
  1 | compare outlines
  2 | compare outlines exactly (otherwise allow slight errors and the unlinking of references)
  4 | warn if the outlines don't exactly match (but are pretty close)
  8 | compare hints
  0x10 | compare hintmasks
  0x20 | compare hintmasks only if the glyph has hint conflicts
  0x40 | warn if references need to be unlinked before a match is found
  0x80 | compare bitmap strikes
  0x100 | compare font names
  0x200 | compare glyph positioning
  0x400 | compare glyph substitutions

GlyphInfo(str)
GlyphInfo("Kern",glyph-spec)
GlyphInfo("VKern",glyph-spec)
GlyphInfo(str,script,lang,tag)
  There must be exactly one glyph selected in the font, and this returns information on it. The information returned depends on str with the obvious meanings:
  - "Name" returns the glyph's name
  - "Unicode" returns the glyph's unicode encoding
  - "Encoding" returns the glyph's encoding in the current font
  - "Width" returns the glyph's width
  - "VWidth" returns the glyph's Vertical width
  - "TeXHeight" returns the tex_height field (a value of 0x7fff indicates that a default value will be used)
  - "TeXDepth" returns the tex_depth field (a value of 0x7fff indicates that a default value will be used)
  - "TeXSubPos" returns the tex_sub_pos field (a value of 0x7fff indicates that a default value will be used)
  - "TeXSuperPos" returns the tex_super_pos field (a value of 0x7fff indicates that a default value will be used)
  - "LBearing" returns the glyph's left side bearing
  - "RBearing" returns the glyph's right side bearing
  - "BBox" returns a 4 element array containing [minimum-x-value, minimum-y-value, maximum-x-value, maximum-y-value] of the glyph.
  - "Kern" (there must be a second argument here which specifies another glyph as in Select()) Returns the kern offset between the two glyphs (or 0 if none).
  - "VKern" (there must be a second argument here which specifies another glyph as in Select()) Returns the vertical kern offset between the two glyphs (or 0 if none).
  - "Xextrema" (there must be a second argument here which specifies the vertical position) Returns a two element array containing the minimum and maximum horizontal positions on the contours of the glyph at the given vertical position. If the position is beyond the glyph's bounding box the minimum value will be set to 1 and the max to 0 (ie. max<min which is impossible).
  - "Yextrema" (there must be a second argument here which specifies the horizontal position) Returns a two element array containing the minimum and maximum vertical positions on the contours of the glyph at the given horizontal position. If the position is beyond the glyph's bounding box the minimum value will be set to 1 and the max to 0 (ie. max<min which is impossible).
  - "Color" returns the glyph's color as a 24bit rgb value (or -2 if no color has been assigned to the glyph).
  - "Comment" returns the glyph's comment (it will be converted from unicode into the default encoding).
  - "Changed" returns whether the glyph has been changed since the last save or load.
  - "DontAutoHint" returns the status of the "Don't AutoHint" flag.
  - "Position" takes three additional arguments, a script, a language and a tag (all 4 character strings) and returns whether the glyph has a Position alternate with that tag.
  - "Pair" takes three additional arguments, a script, a language and a tag (all 4 character strings) and returns whether the glyph has a Pairwise positioning alternate with that tag.
  - "Substitution" takes three additional arguments, a script, a language and a tag (all 4 character strings) and returns the name of the Simple Substitution alternate with that tag (or a null string if there is none).
  - "AltSubs" takes three additional arguments, a script, a language and a tag (all 4 character strings) and returns a space separated list of the names of all alternate substitutions with that tag (or a null string if there is none).
  - "MultSubs" takes three additional arguments, a script, a language and a tag (all 4 character strings) and returns a space separated list of all the names of all glyphs this glyph gets decomposed into with that tag (or a null string if there is none).
  - "Ligature" takes three additional arguments, a script, a language and a tag (all 4 character strings) and returns a space separated list of the names of all components with that tag (or a null string if there is none).
  - "GlyphIndex" returns the index of the current glyph in the ttf 'glyf' table, or -1 if it has been created since. This value may change when a truetype/opentype font is generated (to the index in the generated font).
  - "PointCount" returns the number of points in the glyph (this means different things in different modes).
  - "LayerCount" returns the number of layers in the glyph. This will always be 2 (foreground & background) except in the case of a multilayered font.
  - "RefCount" returns the number of references in the glyph
  - "RefNames" returns an array containing the names of all glyphs refered to. This may contain 0 elements. This may contain a glyph twice ("colon" might refer twice to period)
  - "RefTransform" returns an array of arrays. The bottom most arrays are 6 element (real) transformation matrices which are applied to their respective glyphs.

  Examples:

  >     Select("A")
  >     lbearing = GlyphInfo("LBearing")
  >     kern = GlyphInfo("Kern","O")
  >     Select(0u410)
  >     SetLBearing(lbearing)
  >     SetKern(0u41e,kern)
  >     Select("a")
  >     verta = GlyphInfo("Substitution","*","dflt","vrt2")

CharInfo(str)
  Depreciated name for GlyphInfo
SetGlyphTeX(height,depth[,subpos,suppos])
  Sets the tex_height and tex_depth fields of this glyph. And the subscript pos and superscript pos for math fonts.
GetPosSub(feature-tag,script,lang)
  One glyph must be selected, this returns information about GPOS/GSUB features attached to this glyph (It will not return information about class based kerning or contextual features -- nothing that applies to the font as a whole -- just things relating to the current glyph). The arguments must be 4 letter strings (or the special string "*" which acts as a wildcard). It returns an Array of Arrays (with one entry for each feature which matches the arguments). If nothing matches a 0 length array will be returned.

  Each sub-array contains the following information

  - The feature tag (a string)
  - The script/language string of this feature
  - The type (As a string, One of `Position, Pair, Substitution, AltSubs, MultSubs` or`Ligature`)

  The remaining entries depend on the type.

  For Positions
    There will be 4 numbers indicating respectively the contents of a GPOS value record (dx,dy,d_horizontal_advance,d_vertical_advance)
  For Pairs
    A string containing the name of the other glyph in the pair

    A list of 8 numbers indicating the contents of two GPOS value records (the first four numbers control the current glyph, the next four numbers control the second glyph)

  For Substitutions
    A string containing the name of a glyph with which the current glyph is to be replaced.
  For the others
    A set of glyph names, one for each component.

  Examples:

  >     >Select("ffl")
  >     >Print( GetPosSub("liga","*","*"))
  >     [[liga,latn{dflt} ,Ligature,f,f,l],
  >     [liga,latn{dflt} ,Ligature,ff,l]]
  >     >Select("T")
  >     >Print( GetPosSub("*","*","*"))
  >     [[kern,latn{dflt} ,Pair,u,0,0,-76,0,0,0,0,0],
  >     [kern,latn{dflt} ,Pair,e,0,0,-92,0,0,0,0,0],
  >     [kern,latn{dflt} ,Pair,a,0,0,-92,0,0,0,0,0],
  >     [kern,latn{dflt} ,Pair,o,0,0,-76,0,0,0,0,0]]
  >     >Select("onehalf")
  >     >Print( GetPosSub("frac","latn","dflt"))
  >     [[frac,latn{dflt} ,Ligature,one,slash,two],
  >     [frac,latn{dflt} ,Ligature,one,fraction,two]]

## Examples

- FontForge's testsuite (such as it is)
- Directory of donated scripts
- Scripts used in other projects
  - x-symbol

### Example 1:

>     #Set the color of all selected glyphs to be yellow
>     #designed to be run within an interactive fontforge session.
>     foreach
>       SetCharColor(0xffff00)
>     endloop

### Example 2:

>     #!/usr/local/bin/fontforge
>     #Take a Latin font and apply some simple transformations to it
>     #prior to adding cyrillic letters.
>     #can be run in a non-interactive fontforge session.
>     Open($1);
>     Reencode("KOI8-R");
>     Select(0xa0,0xff);
>     //Copy those things which look just like latin
>     BuildComposit();
>     BuildAccented();

>     //Handle Ya which looks like a backwards "R"
>     Select("R");
>     Copy();
>     Select("afii10049");
>     Paste();
>     HFlip();
>     CorrectDirection();
>     Copy();
>     Select(0u044f);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     //Gamma looks like an upside-down L
>     Select("L");
>     Copy();
>     Select(0u0413);
>     Paste();
>     VFlip();
>     CorrectDirection();
>     Copy();
>     Select(0u0433);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     //Prepare for editing small caps K, etc.
>     Select("K");
>     Copy();
>     Select(0u043a);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     Select("H");
>     Copy();
>     Select(0u043d);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     Select("T");
>     Copy();
>     Select(0u0442);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     Select("B");
>     Copy();
>     Select(0u0432);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     Select("M");
>     Copy();
>     Select(0u043C);
>     Paste();
>     CopyFgToBg();
>     Clear();

>     Save($1:r+"-koi8-r.sfd");
>     Quit(0);

## The Execute Script dialog

This dialog allows you to type a script directly in to FontForge and then run it. Of course the most common case is that you'll have a script file somewhere that you want to execute, so there's a button [Call] down at the bottom of the dlg. Pressing [Call] will bring up a file picker dlg looking for files with the extension *.pe (you can change that by typing a wildcard sequence and pressing the [Filter] button). After you have selected your script the appropriate text to text to invoke it will be placed in the text area.

The current font of the script will be set to whatever font you invoked it from.

## The Scripts Menu

You can use the preference dialog to create a list of frequently used scripts. Invoke File->Preferences and select the Scripts tag. In this dialog are ten possible entries, each one should have a name (to be displayed in the menu) and an associated script file to be run.

After you have set up your preferences you can invoke scripts from the font view, either directly from the menu (File->Scripts-><your name>) or by a hot key. The first script you added will be invoked by Cnt-Alt-1, then second by Cnt-Alt-2, and the tenth by Cnt-Alt-0.

The current font of the script will be set to whatever font you invoked it from.

-- Prev -- TOC -- Next --