Fontlab’s metrics.txt syntax—numbers and documentation?

blank's picture

What syntax must I use to create a metrics.txt entry for numbers? And is the syntax for metrics.txt documented somewhere?

twardoch's picture

James,

I agree that the syntax is a bit cryptical.

Metrics.txt has an internal definition for a few special predefined pseudoclasses for use only in Metrics.txt: uppercase, UPPERCASE, LATIN_UC, lowercase, LOWERCASE, LATIN_LC, smallcaps, SMALLCAPS, LATIN_SC.

These pseudoclasses are prepopulated in FontLab Studio with some content. Whenever a glyph that belongs to one of those pseudoclasses is clicked on the metrics table in the metric mode of Metrics window, the glyph will be displayed in the Metrics window, surrounded by a set of other glyphs defined in Metrics.txt in the %%TEMPLATE section.

You can modify contents of the prepopulated pseudoclasses by defining an identically-named class in FontLab Studio's Classes panel.

For example, the glyph uni2206 is normally surrounded by uppercase glyphs in the Metrics window. If you define a UPPERCASE class in the Classes panel that looks as follows:
UPPERCASE: uni2206
then the uni2206 glyph in Metrics window will join the prepopulated UPPERCASE pseudoclass. So from now on, in the metric mode of Metrics window the uni2206 glyph will behave exactly like uppercase letters, i.e. it will be surrounded by "HOH" on both sides, rather than "HOH" on the left side and "non" on the right side.

You can also define Metrics.txt templates for any classes that you defined in your Classes panel. Have a look at the following example:

%%CLASS_BEGIN
#figures
onum1
onum2
lnum1
lnum2
pnum1
pnum2
tnum1
tnum2
%%TEMPLATE
/zero/one/two@/three/four\n/five/six/seven@/eight/nine\n/dollar/sterling/Euro@/cent/currency\n/H/O/H@/n/o/n\n
%%CLASS_END

The lines starting with %% tell FontLab Studio that a new section of the file starts or ends somewhere. Then, the line starting with # is a comment, an internal description for a given section. And immediately after it, a series of lines can follow, each having a class name as defined in FontLab Studio's Classes panel. These can be OpenType class names, kerning class names or metric class names. In my case, they are OpenType class names that are normally used for onum, lnum, pnum and tnum OpenType Layout features.

The %%TEMPLATE section describes the default surrounding for a glyph in the metric mode of the Metrics window. In the @TEMPLATE section, the @ symbol stands for "current glyph", i.e. the glyph selected in the metrics table of the Metrics window, while \n represents a "new line", i.e. the jump to the next line.

Another example: if you create a metric class in the Classes panel as follows:
.uniFBE9: uniFBE9' uni067D.medi uni06B9.medi uni06BD.medi uni06CE.medi uni06D1.medi uni0751.medi uni0752.medi uni0753.medi uni0754.medi uni0755.medi uni0756.medi uni0767.medi uni0768.medi uni0769.medi uniFB55 uniFB59 uniFB5D uniFB61 uniFB65 uniFB69 uniFBA3 uniFBE7 uniFBFF uniFE8C uniFE92 uniFE98 uniFE9C uniFEE8 uniFEF4
then in Metrics.txt, you can add a following section:

%%CLASS_BEGIN
#.uniFBE9
.uniFBE9
%%TEMPLATE
/uniFBE0@/uniFE90
%%CLASS_END

then any of the Arabic glyphs defined in the .uniFBE9 will be surrounded by the glyphs uniFBE0 and uniFE90 when clicked on in the metric table in the Metrics window. (The right order of display, i.e. right-to-left, can be controlled by the RTL button in the Metrics window). Please scroll the image to the right to see the class definition:

Ps. I just noticed that I already answered this on an older thread on Typophile.

Cheers,
Adam

blank's picture

Sorry for making you answer it twice, Adam. I can’t believe I didn’t find that one when I was searching.

Syndicate content Syndicate content