Fontlab Metrics.txt: Can I create classes for individual letters?

blank's picture

Is it possible to create classes for individual letters in Fontlab’s Metrics.txt file? And if so, what is the proper syntax?

Mighty Pete's picture

If it's just single letters you don't need classes. Classes are like folders.

If there is nothing inside on compile it will just convert them to single lines of code.

twardoch's picture

James,

as this is not officially documented, I'm trying to find out the answer to your questions from our developers.

Adam

blank's picture

Thanks Adam!

twardoch's picture

Well, here is your answer:

you can create new sections of the Metrics.txt file (or best, put a copy into your user data folder first) by the following pattern:

%%CLASS_BEGIN
#name of your section
names of classes as defined in the Classes panel
separated by new lines
%%TEMPLATE
one-line template definition using the /glyphname or \uUnicode notation, where @ is the currently active glyph and \n is the place of the line wrap
%%CLASS_END

For example, if you have classes "onum1", "lnum1", "pnum1" and "tnum1" defined in your Classes panel that contain all the various figure types, you could define a Metrics.txt section as follows:

%%CLASS_BEGIN
#figures
onum1
lnum1
pnum1
tnum1
%%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 "onum1" etc. class names here refer to what is defined in the Classes panel as "OpenType classes", without any glyphname prefix.

But you can also use names of Metric classes here (named e.g. ".A", ".O" etc., with dot as the prefix) or Kerning classes (named e.g. "_A", "_Y" etc., with underscore as the prefix).

Also note that in kerning mode, "@" stands of the currently selected kerning pair, and that in such case, for both glyphs from the kerning pair the appropriate left or right part of the template is selected. So if you have a section defined for uppercase and another section defined for smallcaps, then for kerning pairs such as /T/y.smcp the left part of the template will be shown from the #uppercase section and the right part will be shown from the #smallcaps section.

Also note that in Metrics.txt, there are some internally pre-initialized glyph classes such as "uppercase", "UPPERCASE", "LATIN_UC", "lowercase", "LOWERCASE", "LATIN_LC", "smallcaps", "SMALLCAPS", "LATIN_SC". If they are not defined in the Classes panel, a default pre-initialized definition will be used for them but if you define classes with those names in your Classes panel, that definition will be used. Of course you can also have additional class names that you add to the appropriate sections for Metrics.txt, e.g. "UC", "LC", "SC" if that is how you choose to name your classes in the Classes panel.

Regards,
Adam

Syndicate content Syndicate content