Using fontlab to create a type that substitutes the first letter of a sentence with a different glyph.

pixelscript's picture

I don't know much about the use of conditions in creating a font. To try and get this to work I generated a glyph for the letter A and called it A.begin. I then changed the glyph and added this rule in the Open Type console:

feature diff {
substitute period space A' by A.begin;
} diff;

But it didn't work.

I'm a programmer so I get logical conditions but I just can't find the documentation for this. Any pointers will be much appreciated.

pixelscript's picture

Wow, I take it back, that documentation is like a different language.

blank's picture

Sorry, I didn't realize that the feature file spec doesn't explain CALT specifically. Here's what your code should be:

feature calt {
sub period space A' by A.begin;
} calt;

blank's picture

And the sub line needs to be indented, but typophile kills my spaces.

pixelscript's picture

Thanks for that! Is there something to indicate the beginning of a paragraph? Because obviously there is no period space for those cases....

oldnick's picture

And the sub line needs to be indented, but typophile kills my spaces.

Enclose the code within the html tags

<code>
    spaces</code>

and pad with non-breaking spaces, i.e., &nbsp;

Mark Simonson's picture

It's not possible to test for things like paragraphs and sentences in OT feature code. You can only test for glyphs or runs of glyphs. This makes it possible to test for words because they usually only contain letters and are surrounded by non-letters. Paragraphs and sentences are not as clear cut, plus you can't test for return or line feeds.

pixelscript's picture

Is there a way of saying always substitute A' with A.begin unless there is 'any character' space A' ?

Nick Shinn's picture

Use "ignore".
It's in the FontLab manual.

Mark Simonson's picture

James, you must be thinking of Python. Indents don't matter in (AFDKO) feature syntax, except to make it easier to follow for humans. In fact, you can lay it out any way you like as long as you get your curly braces and semicolons in the right places.

pixelscript's picture

nailed it


feature calt {
    @IGNORE = [A-Z a-z A.begin - Z.begin ampersand quotedbl numbersign dollar percent ampersand |craploads more here| ];
    @CAPS = [A-Z];
    ignore sub @IGNORE @CAPS';
    ignore sub @IGNORE space @CAPS';
    sub A' by A.begin;
    sub B' by B.begin;
    sub C' by C.begin;
    sub D' by D.begin;
    sub E' by E.begin;
    sub F' by F.begin;
    sub G' by G.begin;
    sub H' by H.begin;
    sub I' by I.begin;
    sub J' by J.begin;
    sub K' by K.begin;
    sub L' by L.begin;
    sub M' by M.begin;
    sub N' by N.begin;
    sub O' by O.begin;
    sub P' by P.begin;
    sub Q' by Q.begin;
    sub R' by R.begin;
    sub S' by S.begin;
    sub T' by T.begin;
    sub U' by U.begin;
    sub V' by V.begin;
    sub W' by W.begin;
    sub X' by X.begin;
    sub Y' by Y.begin;
    sub Z' by Z.begin;
} calt;

Thomas Phinney's picture

You know, if you are careful to keep each block of GIDs contiguous, you can shorten 26 lines of that code to:

sub [A - Z]' by [A.begin - Z.begin];

See: http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.htm...

Cheers,

T

Mark Simonson's picture

By the way: If you post OT feature code here and use non-breaking spaces (i.e., &nbsp;) to force display of indents, the code will not compile if it is copied and used as is.

Syndicate content Syndicate content