Open Type Fontlab (Pairs, Classes, Ligatures) Fontlab 5

Mike Jarboe
14.Nov.2007 11.30am
Mike Jarboe's picture

I’m trying to successfully implement kerning pairs, and possibly classes in an Open Type font file in Fontlab 5.

After reading a few threads regarding Open Type Pairs and Classes I learned of the glitch requiring another ’feature’ to be created to have Open Type Pairs export correctly and show up in the final font file.

Without much experience on the technical side of Open Type I did a quick cut and paste of

feature liga {
sub f i by fi;
sub f l by fl;
} liga;

via Twardoch’s suggestion and this worked rather easily as the results are shown while working in the opentype features panel… (I havent successfully exported and tested the font yet as I havent completed the kerning pairs but assume all is well)

I was curious how to successively add the rest of the remaining ligatures and it seems as easy as

feature liga {
sub f i by fi;
sub f l by fl;
} liga;

feature liga {
sub a e by ae;
} liga;

just adding a return and successively adding each ligature but I have four distinct questions:

1. Is the above way correct for adding numerous ligatures to just hit return and keep adding code to cover all possible ligatures?

2. Is there a more thorough manual or book for learning Open Type advanced features for someone who is more focused on the creative and design side of typography, basically something not long winded more of a visual learning guide?

3. What are the most desired features of Open Type, I’m assuming the ligature feature is one of them. Are there any other Open Type features that are as simple as the above ligature example?

4. What I’ve read regarding classes in Open Type seems complicated, pairs seem much easier, is there a clear and simplified guide to creating classes?

I do realize that there are designers for hire that can help implement advanced features for Open Type such as randomize code and etc… but for myself I’d like to learn and do as much as possible myself…

Thanks

Mike



Goran Soderstrom
14.Nov.2007 1.30pm
Goran Soderstrom's picture

I try to answer some of your questions:

1. You dont have to hit return and type the feature again on each new ligature. Just put all of your ligatures inside the the two brackets, like this:

feature liga {
sub f f b by f_f_b;
sub f f h by f_f_h;
sub f f i by ffi;
sub f f j by f_f_j;
sub f f k by f_f_k;
sub f f l by ffl;
sub f b by f_b;
sub f f by ff;
sub f h by f_h;
sub f i by fi;
sub f j by f_j;
sub f k by f_k;
sub f l by fl;
} liga;

2. Asking questions here is good – I have learned a lot, it also good to read the FL manual. These things are very hard to understand in the beginning I believe, but go on and try, some day the sun is shining :)

3. I think all features is quite easy to learn, everything is about substitution, for instance – here are a few popular:

Swash letters:
feature swsh {
sub @swsh1 by @swsh2;
} swsh;

Small Caps:
feature smcp {
sub @smcp1 by @smcp2;
sub @smallnumerals1 by @smallnumerals2;
sub @currency1 by @currency2;
sub @punctuation1 by @punctuation2;
} smcp;

Old Style Figures:
feature onum {
sub @onum1 by @onum2;
sub @currency1 by @currency2;
} onum;

In these cases, there are classes made first with all the necessary glyphs. One class for the original letters, and one for the glyphs that are supposed to substitute the former ones. I usually name the classes 1 and 2 – the 2 substitutes the 1. The classes must be built so the order and number of glyphs are the same in both classes.

As an example:

onum1 = one two three
onum2 = one.oldstyle two.oldstyle three-oldstyle

We also have:

Discretionary Ligatures:

feature dlig {
sub c t by c_t;
sub s t by s_t;
sub s p by s_p;
} dlig;

4. What to do you mean by “pairs”? Kerning pairs? Classes is very handy because it saves time. For instance, you make a class where the key glyph is “o” – you can then use this class to kern letters like e c d b p q as an example, not to mention the time you save for all the accented letters that is build on “o” – like ö ø ó ò etc.

If you do a search here, you will find more detailed information on this.

Youre welcome with any follow-up question you might have – someone will help you :)


Mike Jarboe
14.Nov.2007 1.54pm
Mike Jarboe's picture

Goran,

Thanks this information is great… its somewhat difficult but I’m learning quick.

Where could I find a list of ligature language, meaning a list that shows that ’fi’ only has to be typed as ’fi’ whereas ’fj’ needs an underscore like ’f_j’ and etc?

Yes, by pairs I meant ’kerning pairs’, I have handled pairs successfully in the past but Classes seem a bit more complex maybe because it has the left and right side, I understand it but need to implement it and go through the process to get a handle on how it works better.

Thanks again

Mike


Mike Jarboe
14.Nov.2007 2.38pm
Mike Jarboe's picture

Also with that I assume there would be a list that shows what the syntax is for like onesuperior and onehalf like one.fraction.two or whatever.


Goran Soderstrom
15.Nov.2007 1.14pm
Goran Soderstrom's picture

Basically, all ligatures that does not have its own unicode number, should be written with underscore. So if you make your own ligatures that are not standard ligatures, put the underscore there.
The underscore also makes the ligatures “break apart” if you kern them, and the underscore also means that InDesign treat them as their original letters, so f_f_j will be ffj if you switch to a font that does not have this ligature, or if you copy paste text. That is a good thing.

I think the only ligatures that has unicode number these:

ff
fi
ffi
fl
ffl
Regarding classes, there are three types of classes in FontLab – kerning classes, metrics classe and OT classes. Think of them as groups of glyphs for that is what they are, nothing more. Groups to make things more easy to handle. In kerning classes, they are groups of glyphs that have some similiarities.
I dont understand your second question with the syntax?


Mike Jarboe
15.Nov.2007 2.12pm
Mike Jarboe's picture

Thanks again Goran the second question I mean is what the syntax is for fractions, I’m sure I’m not wording this all right but if for ligatures there is

feature liga {
sub f i by fi;
sub f l by fl;
} liga;

then is there a list of syntax for fractions or substitions so that if you type 1/2 or 1/4 it converts that into the actual corresponding fraction glyph it would be helpful if there was a txt file that showed the syntax (is that what its called?)

Thanks for bearing with these questions I’m learning fast since yesterday I’ve implemented ligatures, classes successfully and plan to do the same with fractions and alternates for another font I’m finalizing… hopefully this thread will help others as well…

Mike


charles_e
15.Nov.2007 2.59pm
charles_e's picture

Examples for proper syntax for the features come with the FontLab. For example, I use a Windows platform; the directory

C:\Program Files\FontLab\Studio5\Samples

is installed when I install the program.

One of the files you will see there is

freefontpro.fea

Which gives useful examples for writing the features code.

One thing to remember is that writing features depends to some extent on both a knowledge of the use of type, and the features a particular applications program will use. If, for example, you use InDesign, only those OpenType features InDesign supports are worth writing.

You can also write features (code) that most would consider a hack; for example, search for “fractions” on this forum to find a thread where fractions are, essentially, “always on” rather than selected & the feature applied. Makes sense for cookbooks; but is wrong for most text.

I would note that using Type 1 fonts, a layout engine like TeX (where you could use different encoding vectors essentially on the fly), and a preprocessing program for the text stream (search & replace strings including S&R using regular expressions) gave results essentially similar to OpenType and its features. The real plus is that OpenType supports Unicode, so further uses of a document are far easier than when the glyphs were known only by their *name*.

BTW, the bug that requires a substitution string in order for positioning strings to be applied is an bug with applications programs, not in FontLab or OpenType. I am sure Adobe will fix it in future releases of their programs.


k.l.
15.Nov.2007 3.07pm
k.l.'s picture

Some additional pieces:

You may also go to http://www.adobe.com/devnet/opentype/afdko/ and download both the FDK and the ExampleRomanFonts.zip. The former includes, among Adobe’s Font Development Kit tools, many useful documents including a Feature File Syntax document as html file. This syntax is used by the FDK as well as font editors that rely on the FDK (FontLab Studio and DTL FontMaster). The example font includes a number of feature files. (For the ’frac’ feature however you better open a not too old OpenType font ...)

Karsten


k.l.
15.Nov.2007 3.41pm
k.l.'s picture

An example. You have defined these OpenType classes in your FLS Classes Panel:

NUMERALS: zero one two three four five six seven eight nine
NUMERATORS: zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr
DENOMINATORS: zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom

A simple ’frac’ feature then looks like this (the idea was first introduced by John Hudson, I think):

feature frac {
    sub slash by fraction;
    sub @NUMERALS by @NUMERATORS;
    sub [fraction @DENOMINATORS] @NUMERATORS’ by @DENOMINATORS;
} frac;

Which means:
— first you replace ’slash’ by ’fraction’
— and all numerals by numerator numerals
— finally you replace all numerators by denominators — but only if they follow either the ’fraction’ or another denominator! (The quote sign in @NUMERATORS’ indicates that only glyphs of this class are to be substituted, the other glyphs, here enclosed in brackets, are the context which must be met so that the substitution takes place.)

This feature then should precede all other numeral-related features like ’sups’, ’subs’, ’sinf’, ’numr’, ’dnom’.

Don’t just copy/paste but play with it and try to understand what is going on. For example, kick out the context part “[fraction @DENOMINATORS]”, or only the “fraction” or only the “@DENOMINATORS”, out of the code and check what happens!  ;-)

Btw, there’s no need for covering ’percent’ and ’perthousand’ in the frac feature, as in some older examples!

Use of the feature: Select the glyphs that shall become a fraction and apply this feature. It should not be applied to entire paragraphs. For a discussion of the latter (and its disadvantages) see this thread.

Hope there’s no error or typo left ...