SourceForge.net Logo Home Page Project Page Download CVS repository
Installation Running Bypassing xgridfit script

Installing and invoking Xgridfit

Installation

At the moment there is no installer for any system other than Linux. On a Linux system, open a shell, change to the xgridfit directory, become root, and type

    make install
  

If you want to install the documentation as well, instead type

    make install-all
  

Xgridfit depends upon an XSLT processor. Most, perhaps all, Linux systems come with xsltproc, part of the XSLT library for Gnome. But other free XSLT processors are available: Saxon version 6, Saxon version 9, and versions of Xalan written in Java and C++. Xgridfit will work well with all of these processors, and some have advantages over others: Saxon 9, for example, may be faster than xsltproc under some circumstances. To switch from one XSLT processor to another, change to the root xgridfit directory and run the choose-processor script with one of the following arguments:

As a second argument, if you choose one of the Java-based processors, you may also enter a classpath to pass to the Java virtual machine when it is invoked. Normally, Xgridfit looks for a jar file (saxon.jar, saxon9.jar, xalan2.jar) in /usr/share/java; so for Saxon 9 the default classpath is /usr/share/java/saxon9.jar. If saxon9.jar is located elsewhere in your system, though, you can indicate that:

    $ ./choose-processor saxon-9 /usr/local/share/saxon/saxon9.jar
  

After you have run choose-processor you must become root and run make install. You may repeat this procedure as often as you like, until you have found a processor you like.

Running

Open your Xgridfit program file and make sure it contains an <infile> element containing the name of the FontForge source file (.sfd) or TrueType file (.ttf) to which instructions are to be added and an <outfile> element containing the name of the file (.sfd or .ttf) to be output. Now invoking Xgridfit is simply a matter of typing xgridfit on the command line, with the name of the program file (the extension should be .xgf or .xml) as a parameter, e.g.

    $ xgridfit Junicode-Bold.xgf
  

If all goes well, Xgridfit will produce a script named Junicode-Bold.pe. If the file named in the <infile> element is present, you may simply run your script in FontForge:

    $ fontforge -script Junicode-Bold.pe
  

The script produced by Xgridfit will open the .sfd or .ttf file, add cvt, fpgm and prep tables, add instructions to each glyph, and either save an .sfd file or generate a TrueType (.ttf) font.

The xgridfit script for Linux takes several command-line parameters:

-a value
Size of TrueType stack (default is 128).
-b value
Delta Break value. This is deprecated: use -p (push-break) instead. To accommodate old makefiles, this option now sets -p to twice its value.
-c yes|no
Determines whether Xgridfit should compile functions, control values, pre-program and maxp entries (default is "yes").
-d
Run in debug mode. Output is file.debug rather than file.pe.
-g glyph
Compile only the specified glyphs and skip all others. If more than one ps-name is given, they must be separated by "+" signs. No spaces permitted. See also the <glyph-select> element.
-i file
File to be input by generated script. Must have extension .sfd or .ttf.
-j path
This option is available only when using a Java-based processor (Saxon or Xalan-java). Use it to temporarily specify a classpath for the Java virtual machine. For example, if Xgridfit is set up to use Saxon 9, but you have a later copy in your personal account than is available in the system, you could invoke Xgridfit with the option -j ~/saxon/saxon9.jar.
-o file
File to be output by generated script. Must have extension .sfd or .ttf.
-O file
Script file to be output by Xgridfit.
-p
Push Break value. This option controls how many numbers a single PUSH instruction can push onto the stack. The default is 20; you may wish to experiment with higher numbers if you have large <push> elements or <delta> elements with many <delta-set> children.
-q
Run in quiet mode. Routine messages are suppressed, but warnings and error messages are displayed.
-s value
Maximum places in TrueType storage area. This area of memory is used to store variables, and also Xgridfit's own run-time data. The number must always be 24 or greater.
-S name
Save script for each glyph in file name_glyphname.pe.
-t value
Maximum number of points in Twilight zone. The default is 25, but few fonts require so many.
-T file
Processors other than xsltproc do not have native support for XInclude. If you use one of these processors with XInclude, Xgridfit uses xmllint (part of the libxml package) to resolve XIncludes, writing an intermediate file which it passes to the XSLT processor. Normally it deletes this file at the end of the run. Use the -T option to specify a different name for the temporary file; this will not be deleted and may be useful for debugging.
-v
Show version number and exit.
-V
Validate the program against the Relax NG schema. Validation is performed by xmllint, which first resolves any XIncludes. The compile proceeds only if your program is valid.
-z file
Name of separate script file for output of <outfile> (works with -S option).

Here are some sample command lines:

    Compiling all glyphs:
      xgridfit myfont.xgf

    Compiling only glyph uni0312:
      xgridfit -g uni0312 myfont.xgf

    Compiling several related glyphs:
      xgridfit -g a+macron+amacron myfont.xgf

    Producing a file to aid in debugging:
      xgridfit -d -g a+macron+amacron myfont.xgf

    Specifying input and output files:
      xgridfit -i myfont.sfd -o myfont.ttf myfont.xgf

    Validating before compilation:
      xgridfit -V myfont.xgf
  

Bypassing the xgridfit script

The xgridfit program is a script for the Bash shell, available on Linux systems and Mac OS X. If Bash is not available on your system, or if you prefer to use an XSLT processor that Xgridfit does not support, you can run Xgridfit by invoking your favorite XSLT processor directly--in which case parameters have a longer form. Here Xgridfit is run directly with xsltproc:

    xsltproc -o Junicode-Bold.pe \
      --stringparam infile Junicode-Bold.sfd \
      --stringparam outfile Junicode-Bold.ttf \
      --param max-twilight-points 29 \
      --param max-storage 128 \
      /usr/local/share/xgridfit/lib/xgridfit.xsl Junicode-Bold.xgf
  

Here is Saxon 6:

    java -jar /usr/local/saxon/saxon.jar \
      -o Junicode-Bold.pe \
      Junicode-Bold.xgf \
      /usr/local/share/xgridfit/lib/xgridfit.xsl
  

Xalan C++:

    xalan -in Junicode-Bold.xgf \
      -out Junicode-Bold.pe \
      -xsl /usr/local/share/xgridfit/lib/xgridfit.xsl \
      -param infile "'Junicode-Bold.sfd'" \
      -param outfile "'Junicode-Bold.sfd'"
  

Xalan java:

    java org.apache.xalan.xslt.Process -in Junicode-Bold.xgf \
      -out "Junicode-Bold.pe" \
      -xsl /usr/local/share/xgridfit/lib/xgridfit.xsl
  

If you like (and are feeling confident), you can skip generation of a FontForge script file and pass the output of an Xgridfit run directly to FontForge:

    xsltproc /usr/local/share/xgridfit/lib/xgridfit.xsl \
      Junicode-Bold.xgf | fontforge -script -
  

You can find a complete list of parameters that can be passed to an XSLT processor in the chapter on Parameters.

Note: The 4xslt processor does not work with Xgridfit: I do not know why. Other XSLT processors may or may not work: I can undertake to test only the major Open Source processors.