Bob Hallissy
and 1 contributors


Font::TTF::Scripts::Volt - Memory representation of a Volt based font


 use Font::TTF::Scripts::Volt;
 $fv = Font::TTF::Scripts::Volt->read_font($ttf_file, $ap_file, %opts);
 $dat = $fv->parse_volt;
 @map = $fv->align_glyphs($dat);
 $fv->merge_volt($dat, \@map);
 $res = $fv->out_volt;


Font::TTF::Scripts::Volt is based on and inherits from Font::TTF::Scripts::AP and as such supports all the information and methods in such an object. The read method does little beyond calling the corresponding AP method.

The real power in this module is in the parse_volt that can parse Volt source code. It does it rather slowly, but it does do it and reads it into an internal data structure. This data structure can then be merged into an existing font using align_glyphs and merge_volt. From there it can be output as Volt source. The data structure representing the Volt source is a hash containing the following elements:


Similar to the glyphs array from AP but adds a few Volt specific sub values


A possibly empty array of Unicode scalar values (as decimal integers).


MARK, BASE (in VOLT UI this is the SIMPLE type), LIGATURE or COMPONENT. This element will not be defined if the VOLT type is UNASSIGNED.


Number of components in a ligature


Volt name in the source


An optional hash by anchor name that contains an array of anchor definitions, one anchor for each ligature component (non-ligature glyphs have a single element in the array). Each anchor definition is a hash including:


A pos type containing the actual position of the anchor point


Contains LOCKED if the anchor point is locked


A hash of script structures keyed off the script tag as used in Volt, containing:


Optional script name as in Volt


Four letter script tag that ends up in the font


An array of language structures consisting of (nearly there)


Optional language name as in Volt


Four letter language tag that ends up in the font


Hash of feature structures keyed by feature tag, each containing (last one)


Optional name of the feature


Four letter feature tag that ends up in the font


Array of names of lookups associated with this feature


A hash of group definitions by name. The contents is an array of context_items corresponding to each element in the defining enum for the group.


An array of lookups in the order they appear in the Volt source. Each lookup consists of


Lookup name


Contains PROCESS_BASE if that is in the lookup




Contains a group name or ALL according to what is to be processed


Contains LTR or RTL


Comment, if any, associated with the lookup; string value but can be multi-line.


Contains an array of contexts as per IN_CONTEXT. Each element of the array is itself an array corresponding to the elements in a context. The first element this array is a string IN_CONTEXT or EXCEPT_CONTEXT depending on the type of context. Subsequent elements are arrays that consist of two elements: A string LEFT or RIGHT and a context_item.


A two-element array, the first element giving the lookup type: sub or pos and the second element being the content of the lookup.

For a sub lookup the second element is an array each element of which is a substitution pair held in an array. The first element of this substitution pair is an array of context_items to be substituted and the second element is an array of context_items that the subsitutition is substituted with.

For a pos lookup, the second element is an array hashes, one per sublookup. The elements in the hash are dependent on the type of positioning but have consistent meaning:




Gives the context glyph for ATTACH and ADJUST_SINGLE lookups and consists of an array of context_items


The first context glyph for an ADJUST_PAIR. It consists of an array of context_items which are referenced by number according to their index (starting at 1) in the positioning.


The second context glyph for an ADJUST_PAIR. It consists of an array of contexts_items which correspond to the second number in a position.


An array of context_items one for each glyph with an exit anchor. Used only in ATTACH_CURSIVE


An array of context_items one for each glyph with an entry anchor. Used only in ATTACH_CURSIVE


Used in an ATTACH to specify what glyphs are being attached and with which anchor point. Each element of this array is an array with two elements: a context_item to specify the moving glyph(s) (the non-moving glyph is specified by the context hash entry) and the name of the anchor point used to link the two. The base glyph has an anchor with the anchor name and the second glyph has an anchor with the anchor named prefixed by MARK_


An adjustment is used in a ADJUST_SINGLE as an array of positioning elements of type pos each one corresponding to a context_item in the context array.

For an ADJUST_PAIR the adj is an array of arrays. Each sub array has 3 elements: first index into the first array (starting at 1), second index into the second array (starting at 1) and a pos to specify the actual adjustment of those two glyphs.


The info hash contains some global information for the whole font with the following hash elements:


Specifies the pixesl per em for positioning purpsoes


Specifies the pixels per em for the grid


Specifies the presentation pixels per em


Optional. If TRUE, then the project options request use of pair position format 2 (rather than the default of format 1).


An array of cmap entries, each of which is an array of 3 numbers.

In addition to extra entries in the main object there are two types that are used in various places:


A context_item consists of an array with two or three elements. The first, a string, gives the type of the context item and the subsequent elements give the value. The context types are:


The second array element contains a glyph id. Note it does not contain a glyph name. The name is resolved to an id in the parser and converted back to a name during output.


The second array element is a string holding the name of the group being referenced


The second and third array elements are the first and last glyph id for the range. Ranges are particularly difficult to work with when merging different glyph arrays so should be avoided


An enum is a way of embedding a list of contexts within a context. The second array element is an array of context_items


A positioning element is a glorious animal. You would think that it could just be an x and y co-ordinate. You would be so wrong! A pos is a hash with three elements: x, y and adv. adv specifies changes to the advance width of a glyph in ADJUST_PAIR.

Each of these hash entries is an array. The first element of the array is the actual co-ordinate value. The second is an optionally empty array of adjustments to that co-ordinate. Each element of that array is a two element array of the adjust value and the ppem value at which the adjustment occurs.

$fv = Font::TTF::Scripts::Volt->read_font ($ttf_file, $ap_file, %opts)

Additional options available to this function include


Reference to a function that parses an Attachment Point name and returns a list considting of a Volt anchor name and component number. The components should be numbered starting from 1. Special conditions that may be returned:

If the return value is undef, or if the anchor name is undef, then this attachment point is ignored.

If the returned component number is undef, 1 will be assumed.

If -point2anchor is not provided, a default function (see below) is used.


Assembles the VOLT project source and returns it as a multi-line string.

Options include

  -default_glyphtype  Glyphs whose C<type> is unknown get set to this type


Parses volt source. If no $vtext then take it from the TSIV table in the font.

$fv->normal_rules($ndrawn, \%opts)

Generate ligature lookup normal_rules based on Unicode composition rules. If $ndrawn is true, then add rules for all Unicode composites, otherwise only those composites whose glyph is an actual TrueType contour glyph.

Options: -force force new lookup even if it already exists.

$fv->make_lookups($ligtype, \%opts)

Construct substitution lookups for all classes and ligclasses, and position lookups for all lists. Options include

  -force   force new lookup even if it already exists.
  -notmark list of anchors that do not imply a MARK glyph (e.g. "_R")


Convert all lists, classes and ligclasses into Volt groups.


Convert all attachment points in $fv into Volt anchors


This function, used if -point2anchor option isn't provided, peels off any digits at the end of the supplied Attachment Point name and uses them for the component. Anchor names starting with "_" are altered to start with "MARK_" instead.

NB: This function is not an object method, and it can be overridden by setting the -point2anchor option of read_font.

See also



Martin Hosken


Copyright (c) 1998-2016, SIL International (

This module is released under the terms of the Artistic License 2.0. For details, see the full text of the license in the file LICENSE.