programming ligatures

matt_yow's picture

Hi all,
First off, I have zero experience with coding and syntax for proper output.

I have just finished a typeface with the usual ligatures (fl, fi, ffl, ffi, even st & ct) and I want to make the ligatures automatic instead of being forced to navigate to the glyphs palette and manually apply ligatures.

I know the answer is in Robofab or Python but I do not have any experience with them and can't find a decent walk-through in the context of type design, specifically ligatures (since Python does all sorts of applications, type design being one).

Is there not a standard snippet of code that applies to all typefaces that automates the ligatures? "when U+0066 & U+0066 appear consecutively with U+FB00"?
I presume not.

Also, I use Fontographer 5.

Thanks in advance.

oldnick's picture

In a simple text editor, declare the liga feature in aalt:

feature aalt{
feature liga;
} aalt;

Then program the ligatures thus:

feature liga {
# Latin
sub f i by fi;
sub f l by fl;
sub X X by XX;
etc.
} liga;

Then, SAVE AS your_file_name.fea. In FOG5, navigate to Element > Font Info > Encoding, then select the radio button for an external feature file, and browse for and select your feature file.

blank's picture

I know the answer is in Robofab or Python…

Nick’s answer is correct, but just to elaborate, character substitution is done with OpenType features. Robofab and Python are used to automate font design tasks; they don’t actually introduce any code into a font.

twardoch's picture

Also, I'll mention that recommended glyph names for ligatures are "f_l", "f_i", "f_f", "s_t", "f_adieresis" etc.

So your code would look like

feature liga {
# Latin
sub f i by f_i;
sub f l by f_l;
sub f f by f_f;
sub s t by s_t;
# etc.
} liga;

(after "sub" you type in sequences of glyph names that should be replaced, after "by" you type in the glyph name that is inserted).

A.

blank's picture

Adam, can Freefont pro be opened in Fog?

twardoch's picture

Dunwich/James,

it's VFB, so it can — but since FOG doesn't have any UI for displaying the font features, the code won't be visible/accessible.

I do recommend installing the demo version of FontLab Studio along Fontographer 5. The demo version of FL Studio is free, and serves as an excellent in-depth font viewer. If you open an OpenType font in the FontLab Studio demo, you can export the font feature definitions from the OpenType panel into a .fea text file, edit it in a text editor and then use it in FOG 5 when generating the font.

FontLab Studio 5 can only export font feature definitions in the older AFDKO 1.6 syntax. If you want to export font feature definitions including things like mark attachment, ie. in the AFDKO 2.5 syntax, you need to use a different tool, such as DTL OTMaster, which is also available from fontlab.com.

Best,
Adam

matt_yow's picture

I knew the answer would be as simple as this.
Let me apply this text and see what my output is, etc and get back with more questions.

Thanks so much all

matt_yow's picture

ok, a basic problem I'm running into now. I have TextEdit, Adobe Reader & MSWord and none of them Save As... .fea
What program or application can save a file as such?

riccard0's picture

What program or application can save a file as [.fea]?

Use TextEdit, save as text, then change the extension from .txt to .fea in the name of the file.

Té Rowan's picture

On a Windows system, you will likely have to set the directory display to show file endings. M$Vim defaults to hiding them.

twardoch's picture

Matt,

in TextEdit, you need to choose Format / Make Plain Text before saving.

Theunis de Jong's picture

Té, "TextEdit" is a dead giveaway :-)

Matt, when using TextEdit, make sure to select menu "Format", then choose "Make Plain Text". Otherwise, you'll be looking in vain for the "Save as plain text" option ... (You'll get to choose what character encoding you want to use, but I'm guessing the default "UTF-8" is just fine for the plain text file that a .fea is.)

matt_yow's picture

thanks riccard0,
I saved it as a .fea, then applied to the encoding section.

my text is exactly:

feature aalt{
feature liga;
} aalt;

feature liga {
# Latin

sub f i by f_i;
sub f l by f_l;
sub f f l by f_f_l;
sub f f i by f_f_i;
sub s t by s_t;

# etc.

} liga;

and upon trying to Generate Font File,
"cannon generate open type file due to an error in feature definition file."
are the underscores necessary or will spaces clear the issue? (sub f i by fi;)

I'll try copy/pasting the code from an established typeface with the ligature features until I know more.

oldnick's picture

#etc. should NOT be in your code: it was included in the examples only to show that the same format should be followed for any other ligatures you wished to include. The glyphnames for the ligatures should be EXACTLY the same as those entered in your feature file.

charles ellertson's picture

The glyphnames for the ligatures should be EXACTLY the same as those entered in your feature file.

Exactly. So, if your glyph in the font is named fi, it will have to be so named in the feature file.

Better to change the name to f_i in the font -- and of course, use f_i in the feature file (as Adam suggested). The "fi" glyph hangs around in some fonts, and is in Unicode, to accommodate legacy issues. Sort of like corsets . . .

Té Rowan's picture

@theunis - I suspected a Windows box when I saw MSWord in the list, but TextEdit could just as well be a Mac program, as far as I'm concerned. Now, Notepad or Wordpad...

Aside: I generally use only two editors: mewin (though it's not eight-bit clean) and mcedit. Meaning? Count me out of any editor jihad.

Syndicate content Syndicate content