Structure of the Xgridfit File
An Xgridfit file corresponds to a single TrueType font file. It supplies the Control Value Table, pre-program, functions and glyph programs for the font. It also controls several parameters relating to TrueType instructions, stored in the font's maxp table. The contents of the file must be well-formed XML, validated against one of the Xgridfit RELAX NG schemas (xgridfit-strict.rnc or xgridfit-transitional.rnc). The first line of the file must be the XML declaration:
<?xml version="1.0" encoding="UTF-8"?>
Since there is no standard way to associate a RELAX NG schema with a document, you must find out how your software does so. Nxml-mode, which validates on the fly, keeps schemas together in one directory and stores association data in the file schemas.xml. Copy xgridfit-strict.rnc or xgridfit-transitional.rnc to the schema directory as xgridfit.rnc and add this line to schemas.xml in the same directory:
<documentElement localName="xgridfit" uri="xgridfit.rnc"/>
After the XML declaration comes the <xgridfit> element, the root element that contains all other information in the file. The child elements of <xgridfit> can come in any order, if you use the strict schema. If you use the transitional schema, the elements must come in the following order:
-
<profile> element containing any number of the following;
or, the following as children of <xgridfit>:
- <infile>
- <outfile>
-
These in any order:
- <constant>
- <variable>
- <round-state>
- <default>
-
One of the following:
- <control-values> container with any number of <control-value> elements
- any number of <control-value> elements
-
One of the following:
- <functions> container with any number of <function> elements
- any number of <function> elements
-
One of the following:
- <macros> container with any number of <macro> elements
- any number of <macro> elements
- <pre-program> (this element is required)
- any number of <glyph> elements
Note that the containers <profile>, <control-values>, <functions>, and <macros> are deprecated: they should not be used in any new programming. Though the strict schema permits you to arrange the children of <xgridfit> in any order, it is wise to group like elements together. Here is a summary of the children of <xgridfit>:
<infile>
Specifies the name of the FontForge file or TrueType font to be opened by the script generated by Xgridfit.
<outfile>
Specifies the name of the file or font to be saved or generated by the script generated by Xgridfit.
<constant>
Unlike the <constant> elements defined in a <glyph> program, <constant>s here are visible in all <glyph> programs, in <function>, <macro>, and <pre-program> elements.
<variable>
Like the global <constant>, the <variable> defined here is visible everywhere. It should be written to only in the <pre-program>.
<round-state>
These elements, permitted only here, define custom round states, which can be invoked anywhere.
<default>
These elements define graphics defaults and other defaults and settings.
<control-value>
A <control-value> element defines a control value, a specialized variable used by various instructions to regulate distance on the grid. A typical TrueType font has many <control-value> elements.
<function>
A <function> element contains the definition of a function--a chunk of code that can be invoked from anywhere and, like the functions (methods, procedures) of other programming languages, can accept parameters and return values.
<macro>
A <macro> element contains the definition of a macro--a chunk of code that is compiled whenever the compiler encounters a <call-macro> element.
<pre-program>
The <pre-program> contains programming that is run whenever the font is about to be rasterized at a new size. Typical tasks for the <pre-program> are to round and adjust control values and set default values in the graphics state. the <pre-program> element is required, though it may be empty.
<glyph>
The file should contain one or more <glyph> elements. Each contains the programming for a single glyph.