Glyph Recipe Syntax»

FontLab VI allows you to generate composite and auto glyphs using one of two code syntaxes: the extended syntax based on Glyph Construction syntax, and the legacy syntax that is backwards-compatible with FontLab Studio 5 and is used in the alias.dat file.

In Font > Generate Glyphs > Custom, if the Use legacy (FLS5) code checkbox is off, the code you input will be interpreted as extended syntax; if the checkbox is on, the input will be interpreted as legacy syntax.

In auto layers, if the custom recipe starts with =, the contents of the field will be interpreted as extended syntax; if it starts with any other character, the recipe will be interpreted as legacy syntax.

Legacy syntax»

If the Font > Generate Glyphs > Custom > ==Use legacy (FLS5) code checkbox is on, FontLab expects the glyph generation code to use the legacy syntax.

The glyph generation code in the legacy syntax is a series of entries separated by newline, space, comma or semicolon. Spaces are not permitted within an entry, in this syntax.

Each entry generates one glyph and has the following format:

  • <resultGlyphName> (this causes FontLab to use a built-in recipe)
  • <legacyGlyphRecipe>=<resultGlyphName> (this causes FontLab to use a custom recipe)

If the entries are separated by newlines, they be optionally followed by #<glyphNote>.

Built-in glyph recipes»

If your glyph generation code only includes the <resultGlyphName>, FontLab will attempt to use a built-in glyph recipe for that glyph name.

FontLab has a built-in alias.dat database that, for a number of “known” glyph names includes recipes that define how a given glyph should be generated from component glyphs. If you place your own alias.dat file in the Data subfolder inside FontLab’s user data folder, FontLab will use that instead. FontLab will use in the alias.dat file to try to find the recipe that describes the generation of the glyph that uses that name. If it cannot find the recipe for that glyph name, it will try to find a recipe for a synonym glyph name (the synonyms are defined in standard.nam).

For example: When you generate the uni00C0 glyph (“À”), FontLab will look up alias.dat for a glyph recipe for uni00C0. If it does not find any such recipes, it’ll look for recipes for synonym glyph names. Agrave is a synonym for uni00C0, and several recipes for Agrave are provided in alias.dat. If it finds one or more such recipes, it will:

  • Find the first recipe, and then will find the A base glyph, then find the the grave.case mark glyph, and insert them as components into Agrave glyph. The Agrave glyph will get the advance width of A since that is the base glyph.
  • If any of the component glyphs cannot be found in the font, FontLab will attempt a fallback recipe, which is to insert the A glyph and the gravecomb glyph. If those are not found, it will try A and grave.
  • If none of the recipes give the full result, FontLab will use the last recipe and build the glyph using as many component glyphs as it can find.

Custom glyph recipes»

If FontLab’s or your own alias.dat doesn’t know how to generate your glyph, or if you use a different glyph naming scheme, or if you’d like to provide some positioning clues for your component glyphs, you can use custom glyph recipes.

In Font > Generate Glyphs > Custom if the Use legacy (FLS5) code checkbox is on and your glyph generation code consists of a series of entries in the form of <legacyGlyphRecipe>=<resultGlyphName>, the <legacyGlyphRecipe> portion will be interpreted to tell FontLab which components it should add to the glyph, and provides clues where to place them. Each entry must be separated by a space, comma, semicolon or a newline.

You can also input the <legacyGlyphRecipe> portion into the recipe text field next to the Auto layer toggle. This will specify a custom recipe for that auto layer using the legacy syntax. Then, FontLab will not look up the glyph name in alias.dat but instead, it will interpret the custom auto layer recipe.

Note: If the contents of the recipe text field starts with =, FontLab will interpret the recipe using the extended syntax (see below).

Example: If the Agrave glyph has an auto layer with an empty recipe field, it will use the alias.dat recipe, as described above. But if you enter A+uni0300 in that field, FontLab will use that recipe instead, and build the auto layer from as many component glyphs as it can find in the font.

When you’ve used custom recipes to build auto layers in Generate Glyphs, FontLab will automatically insert the recipes you’ve used into the auto layer recipe field.

Comments and Glyph notes»

When Font > Generate Glyphs > Custom uses the legacy syntax, you can follow each glyph generation code entry with #, immediately followed by a comment. The comment will be ignored.

However, if you follow the glyph generation code with #!, the text that follows afterwards will be added to the generated generated glyph as a glyph note.

To use comments or insert glyph notes, use new lines to separate the entries for each glyph.

For example: If your glyph generation code is A+acutecomb=Aacute #!To be finished, FontLab will build the glyph Aacute using the glyph recipe A+acutecomb, and the glyph will have the glyph note with the text To be finished.

Legacy syntax for custom recipes»

Attachment operators»

Each <legacyGlyphRecipe> consists of one or more component glyph names separated by attachment operators (without spaces). Two attachment operators are defined:

Spacing attachment: _ (underscore)»

The spacing attachment operator _ appends the following glyph to the right of the preceding glyph and extends the resulting glyph’s width by its own advance width. Note: you can surround glyph names with single quotes (') if they already use _ in their glyph name. Examples:

f_l=f_l
f_i=f_i
c_t=ct
'f_f'_i=f_f_i

Non-spacing attachment: + (plus)»

The non-spacing attachment operator + treats the following glyph as a mark so it attaches it to the preceding glyph but does not modify the advance width.

For example:

C+caron=Ccaron
A+dieresis=Adieresis

Positioning suboperators»

In the recipe, the + operator may be optionally followed by one or two positioning suboperators:

horizontal positioning
| place the following glyph at the origin point of the preceding glyph
< align the following glyph to the left of the bounding box of the preceding glyph
> align the following glyph to the right of the bounding box of the preceding glyph
(no suboperator) center following glyph horizontally over the bounding box of the preceding glyph
vertical positioning
~ place the following glyph at the baseline
^ shift the following glyph by the difference between the font’s caps height and x-height
(no suboperator) shift or do not shift the following glyph, depending on whether the preceding glyph is an uppercase or a lowercase character

For example:

A+^>dotaccentcomb=Adotaccent

Add a number after alignment suboperator to additionally shift the component (the number must be an integer number in per-mille of the UPM size, i.e. 500 is always “half the current UPM size”). For example:

A+|-200~50acutecomb=Aacute

will place acutecomb component on the origin point of the A component, then shift it horizontally by -200‰ of the UPM, and shift it vertically by 50‰ of the UPM.

Decompose operator: % (percent)»

At the end of the recipe, you may optionally include the “decompose” operator.

When used, the resulting glyph will have references unlinked (so the elements will be independent). This is useful when you intend to modify the glyph heavily after you’ve generated it.

If FontLab cannot find a component required by a recipe, it will still generate the auto layer, but will print warning in the Output panel. If one glyph’s recipe refers to itself or to a second glyph which in turn refers to the first glyph, FontLab will not generate an auto layer and print a “circular references” error.

Positioning of marks explicitly or using anchors»

If a legacy glyph recipe is used to generate an auto layer or if Use anchors is turned on in Generate Glyphs, the positioning suboperators will only be used if the base and mark glyphs don’t have corresponding anchors. If the component glyphs have corresponding anchors, those anchors will be used for positioning.

Example: If the A base glyph has a top anchor placed somewhere above the letterform, and either the grave.case or the gravecomb mark glyph has a _top anchor placed somewhere below the letterform, then in Agrave, FontLab will position the _top anchor of the mark glyph in the same location as the top anchor of the base glyph.

You can use any anchor names as long as the anchor in the mark glyph uses the same name as the one in the base glyph, but with a _ prefix. If the glyphs don’t have matching anchors, FontLab will use the positioning clues encoded in the glyph recipe, which in this case will be “horizontally center the grave.case glyph” or “horizontally center the gravecomb glyph and raise it by the difference of the font master’s caps height and x-height”.

Extended syntax»

If the Font > Generate Glyphs > Custom > ==Use legacy (FLS5) code checkbox is off, FontLab expects the glyph generation code to use the extended syntax which is based on the Glyph Construction syntax.

The glyph generation code in the extended syntax is a series of entries separated by newline. Spaces are permitted in this syntax.

Each entry generates one glyph and has the following format:

<resultGlyphName> = <extendedGlyphRecipe>

You can also input the = <extendedGlyphRecipe> portion into the recipe text field next to the Auto layer toggle. This will specify a custom recipe for that auto layer using the extended syntax. Then, FontLab will not look up the glyph name in alias.dat but instead, it will interpret the custom auto layer recipe.

Each <extendedGlyphRecipe> consists of one or more component glyph names separated by attachment operators (surrounded with spaces), and followed by additional operators.

Attachment operators»

Two attachment operators are defined:

Spacing attachment: & (ampersand)»

The spacing attachment operator appends the following glyph to the right of the preceding glyph and extends the resulting glyph’s width by its own advance width.

For example:

f_f_i = f & f & i

Non-spacing attachment: + (plus)»

The non-spacing attachment operator treats the following glyph as a mark so it attaches it to the preceding glyph but does not modify the advance width.

For example:

Aringacute = A + ringcomb + acutecomb

Metrics operator: ^ (circumflex)»

You can also specify your own metrics instead of using the metrics resulting from the attachment.

Advance width»

<resultGlyphName> = <glyphName> + <glyphName> ^ <width>
Aacute = A + acute ^ 400

Sidebearings»

<resultGlyphName> = <glyphName> + <glyphName> ^ <lsb>, <rsb>
Aacute = A + acute ^ 30, 30

The values for the advance width, the left sidebearing and the right sidebearing can also be defined using basic maths and references to width, lsb or rsb of other glyphs.

# width is equal to twice the width of A
Aacute = A + acute ^ A * 2

# left sidebearing is equal to one third of the lsb of A
# right sidebearing is equal to twice the rsb of B
Aacute = A + acute ^ A / 3, B * 2

Positioning operator: @ (at)»

The Glyph Construction language offers different ways to position the attached components in relation to the current glyph’s coordinate space and bounding box.

By coordinates»

Position acute within the A coordinate space at x = 200, y = 100:

Aacute = A + acute@200,-100

Position acute within the A coordinate space at x = 100, y = 100:

Aacute = A + acute@100

By percentage of bounding boxes»

Position acute on A so that in x, 90% of the acute’s bounding width will be at 10% of the A’s bounding width, and in y, 20% of the acute’s bounding height will be at 80% of the A’s bounding height:

Aacute = A + acute@10%,80%

By named parameter»

A named parameter could be (in this order):

  • “key-and-lock” anchors: <anchorName> will in the 1st glyph will match _<anchorName> in the 2nd glyph, e.g. for Aacute = A + acute@top, the _top anchor of acute will be positioned on the top anchor of A
  • a single anchor name: anchors with the same name in both glyphs will match
  • a glyph guide name
  • a font guide name
  • a font metric: descender, xHeight, capHeight, ascender
  • for x, one of these:
  • left: the right edge of the 2nd component will be at the left edge of the 1st component
  • right: the left edge of the 2nd component will be at the right edge of the 1st component
  • innerLeft: the left edge of the 2nd component will be at the left edge of the 1st component
  • innerRight: the right edge of the 2nd component will be at the right edge of the 1st component
  • width: the left edge of the 2nd component will be at the bounding width of the 2nd component
  • origin: the x=0 of the 2nd glyph (not box) will be at x=0 of the 1st glyph (not box)
  • center: the center of the 2nd component will be at the center of the 1st component
  • for y, one of these:
  • bottom: the top of the 2nd component will be at the bottom of the 1st component
  • top: the bottom of the 2nd component will be at the top of the 1st component
  • origin: the baseline of the 2nd glyph will be at the baseline of the 1st glyph
  • center: the center of the 2nd component will be at the center of the 1st component
Aacute = A + acute@center,top

By expressions»

You can form expressions by surrounding them with ```.

Aringacute = A + ring@center,`top+10` + acute@center,`top-10`

By transformation matrix»

@ followed by a transformation matrix: 6 values xx, xy, yx, yy, x, y

Aacute = A + acute@1, 0, 0, 1, 100, 100

Flipping»

~ followed by a position will flip a component.

Horizontal flip:

preversedepigraphic = P@~,
Aacute = A + grave@~center,`top+120`

Vertical flip:

mepigraphicinverted = M@,~
Acircumflex = A + caron@center,~top

Flip horizontally and vertically:

gcommaaccent = g + commaaccent@~center,~top

Change the “current glyph”»

The current glyph is always the last component added.

For example, Aringacute = A + ring + acute will:

  • add component with name A (there is no current glyph)
  • add component with name ring (the current glyph is A)
  • add component with name acute (the current glyph is ring)

In the positioning operator, you can change the “current glyph” using @<glyphName>:<pos>. In this example, the ogonek will use the innerRight of A rather than of acute:

Aacuteogonek = A + acute@55%,`top+150` + ogonek@A:innerRight

Comments»

A line starting with (or anything after) a # is a comment and will not be used during execution.

# this is a comment
Aacute = A + acute
Agrave = A + grave # this is also a comment

If ! follows # in a recipe line, the text that follows will be inserted into the resulting glyph’s note field.

Agrave = A + grave #! To be corrected

Unsupported GlyphConstruction aspects»

The FontLab VI extended glyph recipe syntax does not support the following aspects of the Glyph Construction syntax:

  • $name = variable declaration and {name} variable usage
  • ! operator to specify a color flag
  • | operator to assign a Unicode codepoint
  • ? operator to ignore existing glyphs