Adding OpenType features

Before asking a question on FontCreator look here for possible solutions and tutorials. Please do not post support requests here.
Post Reply
Laenglich
Posts: 10
Joined: Sat Jul 09, 2005 1:29 pm
Location: Waghäusel, Germany

Adding OpenType features

Post by Laenglich »

¡Hola!

I have found an easy way to add OpenType features to a font created with FontCreator. All you need is your TrueType font file, which must contain Postscript names. Look at Format → Post... in FontCreator; if there are no Postscript names yet, FC can even generate them automatically. You can choose them freely (but they should be unique). They are needed for identifying the glyphs in the OpenType script (see below).

Next you get the OpenType Compiler from http://home.kabelfoon.nl/~slam/fonts/otcomp.html (it's free). Basically it works like this:
- Let's say your font is YourFont.ttf
- Open a text editor (preferably one displaying line numbers for easier debugging) and write your OpenType script, let's call it YourFont.ot
- Compile the script: Type »otcomp YourFont.ot« in the console (provided that both the Compiler and the script are in the current directory).
- If there were no errors, the file YourFont.otf was created (the name is specified in the script). Test it with the TrueTypeViewer (http://home.kabelfoon.nl/~slam/fonts/tr ... iewer.html), which allows you to enable or disable every single feature, so you can easily watch the effect.

For everyone who has ever used e.g. a C compiler, this is totally familiar. :-) The .ttf file stays unchanged, so you can always edit the script and simply run the compiler again. On the other hand, you can use the same script for multiple font files, e.g. for different versions or different styles of your font.

There are a lot of great things you can do with an OpenType script:
- Place combining diacritical marks correctly, even as a stack on top of each other
- Remove the dot from i and j when a mark is placed on top
- Use ligatures, e.g. replace f + i by fi.
- Provide alternative glyphs, e.g. old style numerals or different forms of & or ß.
- Replace a glyph by a context-specific one, e.g. isolated/initial/medial/final forms of Arabic letters.
- Add new styles to your font, e.g. small caps.
- Kerning can be done a lot easier than with FontCreator, because you can use groups of characters (e.g. »down-pointing triangle-shaped letters« containing V, W, Y, Ẅ, Ẃ, Ý, Ỳ, Ỹ, ...), and you are not limited to 10,000 kerning pairs (which is not even enough for the Latin script, if you provide all the precomposed letters with marks). Additionally, you can also adjust the glyphs vertically.

There are a lot more features, but these mentioned above are the ones of which I know what they are useful for. ;-)

For the syntax of the OpenType script see the tutorial at http://home.kabelfoon.nl/%7Eslam/fonts/ ... ction.html
Again, this looks totally familiar to everyone who has ever written a program in a language like C. Basically, it looks like a set of functions containing function calls. ;-)
Yet, I have tested using ligatures like fi, removing the dot from i and j and placing diacritical marks in my font Quivira. The result looks great:
Image

Any downsides?
First, this will mean a damn lot of script writing for a large Unicode font like mine. ;-) But I think it's worth the effort.
Second, not every writing program supports every feature, e.g. in my tests MS Word 2003 removed the dot from i and j and placed the marks correctly, but did not use the ligatures. I guess it's a matter of time until the important features are supported in the widespread programs (or maybe this is just an expert option somewhere ;-) ).
Third and worst of all, Word doesn't display the characters of plane 1 any more. :-( In the TrueTypeViewer and the BabelMap they look as before. But the font Doulos SIL has a Plane-1-character that works in Word, so the problem must be solvable. I hope it is not a bug in this compiler. If you have an idea, please tell me!

In the end I think this program is a phantastic addition to FontCreator, enabling us to create much more professional-looking fonts. There is also a tool for hinting (http://home.kabelfoon.nl/~slam/fonts/tticomp.html), but I haven't tested it yet.

Kind regards,
Længlich
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala »

Thanks for posting. You obviously got it to work fairly well. Although the OpenType Compiler Tutorial is well written and clearly laid out, I wouldn't describe the process as simple. I am familiar with the process of compiling from a DOS box, as I have used the process before with the Windows Help File compiler using Rich Text Files as the source. What seems hard to me is knowing how to write the OT script.

Perhaps you could provide a link to the script that you used for your font, so that we can see just how much text is required.
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Laenglich
Posts: 10
Joined: Sat Jul 09, 2005 1:29 pm
Location: Waghäusel, Germany

Post by Laenglich »

Bonjour!
Bhikkhu Pesala wrote:Thanks for posting. You obviously got it to work fairly well. Although the OpenType Compiler Tutorial is well written and clearly laid out, I wouldn't describe the process as simple.
Well, it is much simpler than everything else I found before. ;-)
Bhikkhu Pesala wrote:I am familiar with the process of compiling from a DOS box, as I have used the process before with the Windows Help File compiler using Rich Text Files as the source. What seems hard to me is knowing how to write the OT script.
Yes, I expected this. The tutorial explains single features very well, but never shows a complete working file. As I am familiar with computer programming, I managed to put the examples together quickly, but I'm sure this is not as easy for typographers who are not programmers.
Bhikkhu Pesala wrote:Perhaps you could provide a link to the script that you used for your font, so that we can see just how much text is required.
I plan to do so, and I may also comment and explain it - much like a second tutorial.
But at the moment the script isn't ready, and I have little time, so it will take at least another week, probably longer.

I estimate you need some hundreds of lines of code for a font that contains the complete Latin script, but it depends on several characteristics of your font: The more of your glyphs have the same width, the less code you need, the more ligatures or alternatives you provide, the more code is needed and so on. Generally I'm quite sure you need less lines of code than you have glyphs.

Kind regards,
Længlich
Dave Crosby
Typographer
Typographer
Posts: 793
Joined: Mon Feb 23, 2004 1:13 pm
Location: Enoch, Utah

Congratulations!

Post by Dave Crosby »

Congratulations on your new (for us!) approach.

All I knew before was that you could just change the ttf to otf and the font thinks it is an otf.

But you show how to make it the real thing.

Many thanks!
Aut nunc aut nunquam
Laenglich
Posts: 10
Joined: Sat Jul 09, 2005 1:29 pm
Location: Waghäusel, Germany

First OpenType tutorial: Ligatures

Post by Laenglich »

Ciao!

Okay, here is my first tutorial about OpenType features, and of course we start quite simple: We want to replace the sequence ff by ff, fi by fi and ffi by ffi. The original tutorial shows this case here: http://home.kabelfoon.nl/%7Eslam/fonts/ ... subst.html

I assume you have created your font in Font Creator and saved it as a .ttf-File; let's say it's called YourFont.ttf. Of course it must contain the necessary glyphs, in this case f, i, ff, fi and ffi with the Postscript names f, i, ff, fi and ffi:
Image

The glyphs may be mapped to their corresponding Unicode codepoints, but they don't have to. You can also create own ligatures like e.g. ffj which are not assigned in any standard. You can map them somewhere in the Private Use Area, if you want to make them accessible via a codepoint, but you can also leave them unmapped.

The original tutorial shows the lookup we need, but not the rest of the file. A complete working script looks like this:
#input "YourFont.ttf"
#output "YourFont.otf"

script latn { /* Latin */
    feature ligatures;
    /* you can add more features here */
}

script dflt { /* default */
    feature ligatures; /* no problem to use the same feature again */
}

feature ligatures liga {
    lookup ligaSub;
    /* you can add more lookups here */
}

lookup ligaSub {
    ignore mark;

    sub f f i -> ffi;
    sub f f -> ff;
    sub f i -> fi;
}

Now let's just read it from top to bottom to see what it does:
The first two lines, starting with the keywords #input and #output, define the existing font which is used and the new one which will be created now. Note that these lines do not end with a semicolon (they look like the precompiler syntax used in C).
Next you see a script block: The keyword script, followed by a four letter code for the (Unicode) script, and after that a block of statements in curly brackets. /* starts a comment which is ignored by the compiler, and */ marks the end of the comment. Within a comment you can write whatever you want (except */, of course) - it has no effect on your font.
The script we are talking about is Latin, so we use the code latn (see all possible script codes here: http://www.microsoft.com/typography/dev ... t/TAGS.txt). Between the curly brackets we list all the features we want to apply to this script, each line starting with the keyword feature, followed by its name and a semicolon. You can choose the name freely, ligatures is not a keyword but the name I gave to our new feature. At the moment we want only one feature, so we're done with the script block.
(I have also defined the feature in a second block for the default script, mostly to show that the same feature can be applied to several scripts, and to ensure that our ligatures are also used e.g. in an English text embedded in Japanese. I don't know how the rendering programs handle this, but it won't do any damage anyway.)

Now that we have told the compiler that the feature ligatures shall be used in the Latin and the default script, we must define it. This is done by a feature block with a very similar syntax: First the keyword feature, then the name of the feature (in this case ligatures) and then a four letter code which says what to do. In this case we use liga for ligatures (there are many more, see here: http://www.microsoft.com/typography/dev ... t/TAGS.txt, at the end of the document). Between the following curly brackets we write a list of lookups, the same way we've listed the features for a script. You see: A feature can contain more than one lookup, i.e. it can do several different things. But for now one is enough. The name is chosen freely again.

At last we have to define the lookup we've referenced in the feature, and the syntax looks similar again: Each lookup has a name and a block of statements in curly brackets. Now these statement are the actually interesting part, because here we finally tell the renderer what it shall do.
The first line, ignore mark;, tells it that we are not interested in combining marks (at least not now). In this lookup they can be ignored, e.g. f + combining acute + i is treated exactly like f + i. (We will care about the positioning of the marks later in another feature.) *
After that we write the actual ligature substitutions, one per line. Each line consist of the following elements:
sub <list of glyphs> -> <one glyph>;
The glyphs are identified by their Postscript names. Note the order of the substitutions: The ffi ligature must be placed before the ff ligature, otherwise the renderer would replace ff before seeing the i and thus never use ffi.

Well, that's all about ligatures. To test it, save the example as plain text with the file extension .ot. (Important note: Use a plain text editor, not something like Word which adds formatting data. I recommend Notepad++, which I also use for HTML, CSS, PHP and so on. You can download the example here: http://www.grinningbit.com/forum/high-l ... gatures.ot) Replace YourFont.ttf with the actual name of your font, run the compiler and open the .otf-file with the TrueType Viewer. Enable the feature »Standard Ligatures« and watch the result:
Image

If you open the .otf-file in Font Creator and take a look at Format → Tables... , you will see that it contains some unsupported tables now. This is what the compiler has made from our script.
Image

Note that this kind of substitution is not only usable for ligatures. Decomposing accented letters or Arabic form shaping works the same way (you can also substitute one glyph by several others, or one by one; see http://www.microsoft.com/OpenType/OTSpec/gsub.htm).

I hope that this tutorial is useful for you - if yes, I'll write some more (I'm thinking of mark positioning, which is a bit more difficult to understand, but not much).

Kindest regards,
Længlich

* In this example this line will not work, because we haven't defined anywhere which glyphs are marks. We'll do that in another tutorial, but I wanted to insert the line here anyway to have this feature done completely.
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala »

Well, at least I got some error messages, so I must be doing something right. :roll:
garava.ot(l.21 c.3): error: Error: second "#input" option.
garava.ot(l.22 c.2): error: Error: second "#output" option.
These are the input/output lines:
#input "Garava Regular.ttf"
#output "Garava Regular.otf"
I tried renaming my font to "GaravaR.ttf" and changing the lines accodingly, but the space doesn't seem to be the problem.
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Laenglich
Posts: 10
Joined: Sat Jul 09, 2005 1:29 pm
Location: Waghäusel, Germany

Debugging

Post by Laenglich »

Good morning!
Bhikkhu Pesala wrote:Well, at least I got some error messages, so I must be doing something right. :roll:
From my experience in computer programming I state that error messages are great. Really, no irony! The bad things are programs that compile without errors, but do different things from what they're supposed to, or even worse, you don't get any feedback at all, or a crash. But error messages are something you can work with. :-)
Bhikkhu Pesala wrote:
garava.ot(l.21 c.3): error: Error: second "#input" option.
garava.ot(l.22 c.2): error: Error: second "#output" option.
These are the input/output lines:
#input "Garava Regular.ttf"
#output "Garava Regular.otf"
I tried renaming my font to "GaravaR.ttf" and changing the lines accodingly, but the space doesn't seem to be the problem.
I don't think the space is the problem either - I guess this is what the quotes are for: to allow non-alphanumeric characters in the filenames.

But the line numbers 21 and 22 are interesting. The two lines you've quoted above stand at the beginning of the script, don't they? Are they repeated later? What stands in line 21 and 22?
If you don't see the error in these lines, can you make the script file available online, so that I can take a look into it?

Kind regards,
Længlich
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala »

Ah! We have progress. Just a silly cut and paste error.

The next error was the Postscript names for ff, fi, fl, etc. In my fonts, these are mapped to the legacy positions in the PUA as well as the Alphabetic Presentation Forms codepoints, so Generate Postscript names generates names like uniFB01 instead of fi. Type the postscript name, save the file, and everything works as expected with no errors TruetypeViewer displays the ligatures OK when the GSUB feature checkbox is checked.

All I need now is an application that supports OpenType features. :(

This is my best effort so far:
Updated 12/1/2009 to correct a small error
Postscript names correspond to code-points used by FontCreator's SmallCaps glyph transformation. Ligatures use logical plain text postscript names.

Code: Select all

#input "Garava Regular.ttf" 
#output "Garava Regular.otf" 

script latn { 
    feature PetiteCaps;
    feature ScientificInferiors; 
    feature Superscript; 
    feature OldstyleFigures; 
    feature AlternativeFractions; 
    feature ligatures;
    feature discretionaryligatures;
} 
feature ScientificInferiors sinf {
    lookup ScientificInferiors;
}
lookup ScientificInferiors {
    sub [zero-nine] -> [uni2080-uni2089]; 
    sub plus -> uni208A; 
    sub minus -> uni208B; 
    sub equal -> uni208C; 
    sub parenleft -> uni208D; 
    sub parenright -> uni208E; 
}
feature Superscript sups {
    lookup Superscript;
}
lookup Superscript {
    sub zero -> uni2070; 
    sub one -> uni00B9; 
    sub two -> uni00B2; 
    sub three -> uni00B3; 
    sub [four-nine] -> [uni2074-uni2079]; 
    sub plus -> uni207A; 
    sub minus -> uni207B; 
    sub equal -> uni207C; 
    sub parenleft -> uni207D; 
    sub parenright -> uni207E; 
}
feature OldstyleFigures onum {
    lookup OldstyleFigures;
}    
lookup OldstyleFigures {
    sub [zero-nine] -> [uniE2C0-uniE2C9]; 
}
feature AlternativeFractions afrc {
    lookup AlternativeFractions;
}
lookup AlternativeFractions {
    sub [onequarter - threequarters] -> [uniE34C-uniE34E];
    sub [onethird - seveneighths] -> [uniEC73-uniEC7E];
}
feature PetiteCaps pcap {
    lookup PetiteCaps;
}    
lookup PetiteCaps {
    sub exclam -> uniE059;
    sub dollar -> uniE2B4;
    sub percent -> uniE2B5;
    sub ampersand -> uniE05E;
    sub question -> uniE077;
    sub [zero-nine] -> [uniE2C0-uniE2C9]; 
    sub [a-z] -> [uniE2F1 - uniE30A];
    sub exclamdown -> uniE0D9;
    sub sterling -> uniE333;
    sub yen -> uniE335;
    sub questiondown -> uniE34F;
    sub [agrave - odieresis] -> [uniE370 - uniE386];
    sub [oslash - ydieresis] -> [uniE388 - uniE38F];
    sub amacron -> uniE391;
    sub abreve -> uniE393;
    sub aogonek -> uniE395;
    sub cacute -> uniE397;
    sub ccircumflex -> uniE399;
    sub cdotaccent -> uniE39B;
    sub ccaron -> uniE39D;
    sub dcaron -> uniE39F;
    sub dcroat -> uniE3A1;
    sub emacron -> uniE3A3;
    sub ebreve -> uniE3A5;
    sub edotaccent -> uniE3A7;
    sub eogonek -> uniE3A9;
    sub ecaron -> uniE3AB;
    sub gcircumflex -> uniE3AD;
    sub gbreve -> uniE3AF;
    sub gdotaccent -> uniE3B1;
    sub gcommaaccent -> uniE3B3;
    sub hcircumflex -> uniE3B5;
    sub hbar -> uniE3B7;
    sub itilde -> uniE3B9;
    sub imacron -> uniE3BB;
    sub ibreve -> uniE3BD;
    sub iogonek -> uniE3BD;
    sub ij -> uniE3C3;
    sub jcircumflex -> uniE3C5;
    sub kcommaaccent -> uniE3C7;
    sub lacute -> uniE3CA;
    sub lcommaaccent -> uniE3CC;
    sub lcaron -> uniE3CE;
    sub ldot -> uniE3D0;
    sub lslash -> uniE3D2;
    sub nacute -> uniE3D4;
    sub ncommaaccent -> uniE3D6;
    sub ncaron -> uniE3D8;
    sub eng -> uniE3DB;
    sub omacron -> uniE3DD;
    sub obreve -> uniE3DF;
    sub ohungarumlaut -> uniE3E1;
    sub oe -> uniE3E3;
    sub racute -> uniE3E5;
    sub rcommaaccent -> uniE3E7;
    sub rcaron -> uniE3E9;
    sub sacute -> uniE3EB;
    sub scircumflex -> uniE3ED;
    sub scedilla -> uniE3EF;
    sub scaron -> uniE3F1;
    sub tcommaaccent -> uniE3F3;
    sub tcaron -> uniE3F5;
    sub tbar -> uniE3F7;
    sub utilde -> uniE3F9;
    sub umacron -> uniE3FB;
    sub ubreve -> uniE3FD;
    sub uring -> uniE3FF;
    sub uhungarumlaut -> uniE401;
    sub uogonek -> uniE403;
    sub wcircumflex -> uniE405;
    sub ycircumflex -> uniE407;
    sub zacute -> uniE40A;
    sub zdotaccent -> uniE40C;
    sub zcaron -> uniE40E;
    sub uni01F5 -> uniE485;
    sub aringacute -> uniE48B;
    sub aeacute -> uniE48D;
    sub oslashacute -> uniE48F;
    sub scommaaccent -> uniE4A9;
    sub uni021B -> uniE4AB;
    sub iotadieresistonos -> uniE238;
    sub alphatonos -> uniE254;
    sub epsilontonos -> uniE255;
    sub etatonos -> uniE256;
    sub iotatonos -> uniE257;
    sub upsilondieresistonos -> uniE258;
    sub [alpha - sigma1] -> [uniE259 - uniE26B];
    sub [tau - omega] -> [uniE26C - uniE659];
    sub iotadieresis -> uniE272;
    sub upsilondieresis -> uniE273;
    sub omicrontonos -> uniE274;
    sub upsilontonos -> uniE275;
    sub omegatonos -> uniE276;
    sub uni1E0D -> uniE92D;   
    sub uni1E25 -> uniE945;
    sub uni1E37 -> uniE957;
    sub uni1E39 -> uniE959;
    sub uni1E41 -> uniE961; 
    sub uni1E43 -> uniE963;
    sub uni1E45 -> uniE965;
    sub uni1E47 -> uniE967;
    sub uni1E5B -> uniE97B;
    sub uni1E5D -> uniE97D;
    sub uni1E63 -> uniE983;
    sub uni1E6D -> uniE98D;
    sub wgrave -> uniE9A1;
    sub wacute -> uniE9A3;
    sub wdieresis -> uniE9A5;
    sub ygrave -> uniEA13;
    sub uni1EF9 -> uniEA19; 
}

feature ligatures liga { 
    lookup ligaSub; 
} 

lookup ligaSub { 

    sub f f i -> ffi; 
    sub f f l -> ffl; 
    sub f f t -> fft; 
    sub f f y -> ffy; 
    sub f t y -> fty; 
    sub f f -> ff; 
    sub f i -> fi; 
    sub f j -> fj; 
    sub f l -> fl; 
    sub f r -> fr; 
    sub f t -> ft; 
    sub f y -> fy; 
    sub t r -> tr; 
    sub t t -> tt; 
    sub t y -> ty; 
    sub longs t -> longst; 
}

feature discretionaryligatures dlig { 
    lookup dligSub; 
} 

lookup dligSub { 

    sub c k -> ck; 
    sub c t -> ct; 
    sub s p -> sp; 
    sub s t -> st; 
    sub t z -> tz; 
    sub Q u -> Qu; 
    sub T h -> Th; 
}
The result can be seen in TrueType Viewer:

Image
Last edited by Bhikkhu Pesala on Sat Jan 26, 2008 9:24 pm, edited 3 times in total.
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Laenglich
Posts: 10
Joined: Sat Jul 09, 2005 1:29 pm
Location: Waghäusel, Germany

Post by Laenglich »

Bhikkhu Pesala wrote:The next error was the Postscript names for ff, fi, fl, etc. In my fonts, these are mapped to the legacy positions in the PUA as well as the Alphabetic Presentation Forms codepoints, so Generate Postscript names generates names like uniFB01 instead of fi.
Oh, I know this problem. I also use some glyphs for more than one codepoint, so at the first attempt half of the capital Latin letters got Greek names...
Bhikkhu Pesala wrote:All I need now is an application that supports OpenType features. :(
Well, MS Word places marks and does contextual substitutions (dotless i before accent, Arabic letters etc.). It does not use the ligatures. I haven't tested small caps and old style numerals yet - this is interesting.
And I don't know about OpenOffice yet, I plan to test that later, too.
Bhikkhu Pesala wrote:This is my best effort so far: [...]
Looks great! :-) You got it to work, and I'm absolutely sure you will also get the other features to work. (Actually, as far as I can see, there are only three basic things to learn:
1. Substituting glyphs
2. Positioning glyphs
3. Doing these things only in a special context.
So it won't become much more complicated.)
Bhikkhu Pesala wrote:My next task is to learn how to add Old Style Figures and nut fractions.
I think this works pretty much the same way as the small caps. The feature tag for old style numerals is »onum«, and then you just substitute glyphs again. For nut fractions I think »afrc« (alternate fractions) should be the best choice.

I'll write about contextual substitutions and positioning marks later in this thread.

Kind regards,
Længlich
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala »

I don't have Word, and I am fairly sure OpenOffice doesn't support OpenType features, therefore the incentive to pursue this is low. I coded my full range of Latin Extended Small Capitals only to run into problems with Postscript Names again. Debugging code is not difficult, but it is very time-consuming. I prefer to wait until Erwin makes this easy for us via the GUI.

A few tips for any brave adventurers along this path:

1. Put OTComp.exe in the same directory as your fonts.
2. Make a shortcut for the Command Prompt to launch it in your fonts directory such as:
"%HOMEDRIVE%%HOMEPATH%\My Documents\My Fonts\Unicode"
3. Associate *.OT files with a text editor such as Notepad2 or Notepad++ that supports line numbering.
4. Alternatively, you can name your code files with *.txt extension and use Notepad. OTcomp.exe will still accept them.
5. Rename OTcomp.exe to OT.exe to save a few keystrokes.
6. Put TrueTypeViewer.exe and qt-mt230nc.dll in your fonts directory too for easy access. You can run it from Windows Explorer.
7. While debugging code, keep TruetypeViewer open and click the reload button after updating your *.otf successfully.
8. If you get any errors at all, no *.otf will be created.
9. To test glyphs beyond the ANSI range, use the backslash as an escape character, e.g. \0101 will display ā in the Preview window.
10. Having successfully produced a source file for one font, you only need to modify the first two lines for other fonts. However, this will only work if the other fonts contain the identical glyphs with identical postscript names. Mappings are unimportant, as the compiler works with postscript names.
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Laenglich
Posts: 10
Joined: Sat Jul 09, 2005 1:29 pm
Location: Waghäusel, Germany

Post by Laenglich »

Hello,

you're right: OpenOffice doesn't support any OpenType features, but the well-known programming libraries used for font rendering all start supporting at least some of them. So it should only be a question of time, i.e. versions...

There is a GUI for OpenType features: Microsoft VOLT. It's free, too.
Without the OTCompiler I had not understood how to use it. ;-) But now that I know the structure of scripts, features and lookups this might be an option aswell.
Interestingly, when I try to save Quivira.otf as a new file, it complains »unknown cmap format«. This might also be the reason why Word doesn't like my Plane-1-characters any more... need some research.

Kind regards,
Længlich
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala »

I managed to get OldStyle Figures, Ligatures, Alternative Fractions, Superscripts, and Scientific Inferirors working OK. That's enough for now.

Code: Select all

#input "Lekhana Regular.ttf" 
#output "Lekhana Regular.otf" 

script latn {  
    feature ligatures; 
} 
script dflt { 
    feature ligatures; 
    feature ScientificInferiors; 
    feature Superscript; 
    feature oldstylefigures; 
    feature AlternativeFractions; 
} 
feature ScientificInferiors sinf {
    lookup ScientificInferiors;
}
lookup ScientificInferiors {
    sub [zero-nine] -> [uni2080-uni2089]; 
    sub plus -> uni208A; 
    sub minus -> uni208B; 
    sub equal -> uni208C; 
    sub parenleft -> uni208D; 
    sub parenright -> uni208E; 
}
feature Superscript sups {
    lookup Superscript;
}
lookup Superscript {
    sub zero -> uni2070; 
    sub i -> uni2071; 
    sub one -> uni00B9; 
    sub two -> uni00B2; 
    sub three -> uni00B3; 
    sub [four-nine] -> [uni2074-uni2079]; 
    sub plus -> uni207A; 
    sub minus -> uni207B; 
    sub equal -> uni207C; 
    sub parenleft -> uni207D; 
    sub parenright -> uni207E; 
    sub n -> uni207F; 
}
feature oldstylefigures onum {
    lookup oldstylefigures;
}    
lookup oldstylefigures {
    sub [zero-nine] -> [uniE2C0 - uniE2C9]; 
}
feature AlternativeFractions afrc {
    lookup AlternativeFractions;
}
lookup AlternativeFractions {
    sub [onequarter - threequarters] -> [uniE34C-uniE34E];
    sub [onethird - seveneighths] -> [uniEC73-uniEC7E];
}
feature ligatures liga { 
    lookup ligaSub; 
} 
lookup ligaSub { 

    sub f f i -> ffi; 
    sub f f l -> ffl; 
    sub f f t -> fft; 
    sub f f y -> ffy; 
    sub f t y -> fty; 
    sub c k -> ck; 
    sub c t -> ct; 
    sub f j -> fj; 
    sub f r -> fr; 
    sub f t -> ft; 
    sub f y -> fy; 
    sub s p -> sp; 
    sub t r -> tr; 
    sub t t -> tt; 
    sub t y -> ty; 
    sub t z -> tz; 
    sub Q u -> Qu; 
    sub T h -> Th; 
    sub f f -> ff; 
    sub f i -> fi; 
    sub f l -> fl; 
    sub longs t -> longst; 
    sub s t -> st; 
    sub s p -> sp; 
}
Note that the order in which the features are defined in the data file defines their order of preference. If scientific inferiors, superscripts, and oldstyle figures are all enabled, the first in the list — scientific inferiors (subscripts) will override the other two. The dialogues below list features in the alphabetical order of their OpenType tags, not in their order of precedence as defined in the data (above).
     feature ScientificInferiors;
     feature Superscript;
     feature oldstylefigures;
Image

Image

Image
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Post by Bhikkhu Pesala »

My latest attempt at adding OpenType features to my Talapanna and Talapanna fonts uses the Initial Capitals feature to access the Gothic Drop Capitals in the fonts. Ligatures are divided into two groups — standard and discretionary. This is the source file for adding the features using OTCOMP.EXE:

Updated code to correct an error. All OpenType layout tags should be in lowercase, except for the DFLT tag. I have removed the "dflt" tag and just used the "latn" tag instead.

Code: Select all

#input "Talapanna Regular.ttf" 
#output "Talapanna Regular.otf" 

script latn {  
    feature InitialCapitals;
    feature ligatures; 
    feature ScientificInferiors; 
    feature Superscript; 
    feature ligatures;
    feature discretionaryligatures;
} 
feature ScientificInferiors sinf {
    lookup ScientificInferiors;
}
lookup ScientificInferiors {
    sub [zero-nine] -> [uni2080-uni2089]; 
    sub plus -> uni208A; 
    sub minus -> uni208B; 
    sub equal -> uni208C; 
    sub parenleft -> uni208D; 
    sub parenright -> uni208E; 
}
feature Superscript sups {
    lookup Superscript;
}
lookup Superscript {
    sub zero -> uni2070; 
    sub one -> uni00B9; 
    sub two -> uni00B2; 
    sub three -> uni00B3; 
    sub [four-nine] -> [uni2074-uni2079]; 
    sub plus -> uni207A; 
    sub minus -> uni207B; 
    sub equal -> uni207C; 
    sub parenleft -> uni207D; 
    sub parenright -> uni207E; 
}
feature InitialCapitals init {
    lookup InitialCapitals;
}    
lookup InitialCapitals {
    sub [A-Z] -> [uniE2D1 - uniE2EA];
}

feature ligatures liga { 
    lookup ligaSub; 
} 

lookup ligaSub { 

    sub f f i -> ffi; 
    sub f f l -> ffl; 
    sub f f t -> fft; 
    sub f f y -> ffy; 
    sub f t y -> fty; 
    sub f f -> ff; 
    sub f i -> fi; 
    sub f j -> fj; 
    sub f l -> fl; 
    sub f r -> fr; 
    sub f t -> ft; 
    sub f y -> fy; 
    sub k y -> ky; 
    sub t r -> tr; 
    sub t t -> tt; 
    sub t y -> ty; 
    sub longs t -> longst; 
}

feature discretionaryligatures dlig { 
    lookup dligSub; 
} 

lookup dligSub { 

    sub c k y -> cky; 
    sub c k -> ck; 
    sub c t -> ct; 
    sub s p -> sp; 
    sub s t -> st; 
    sub t z -> tz; 
    sub Q u -> Qu; 
    sub T h -> Th; 
    sub A V -> AV; 
    sub H E -> HE; 
    sub L A -> LA; 
    sub M E -> ME; 
    sub N K -> NK; 
    sub N T -> NT; 
    sub O C -> OC; 
    sub O G -> OG; 
    sub O O -> OO; 
    sub T L -> TL; 
    sub T Y -> TYcaps; 
    sub T W -> TW; 
    sub T T -> TTcaps; 
    sub U B -> UB; 
    sub U D -> UD; 
}
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 9869
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: Adding OpenType features

Post by Bhikkhu Pesala »

The ordinals feature requires a contextual lookup. It should use superscripts for letters that follow a digit. English only uses 1st, 2nd, 3rd, 4th, etc., but French requires 1ème, and Irish uses a superscripted ú for all ordinals. The digits may be followed by one or more letters that should be superscripts.

The following code does what is needed as long as the ordinal glyphs are included in the font and have the corresponding Postscript names.

Code: Select all

feature Ordinals ordn {
    lookup Ordinals;
}
    group @Ordinals [zero-nine uniE2C0-uniE2C9 uniEAA1 - uniEABA uniEAC1 - uniEADA uniEB28 uniEB3A uniEB48 uniEB5A];
    group @Alphas [A-Z a-z Egrave Uacute egrave uacute];

    lookup Ordinals{
    context (@Ordinals) @Alphas;
    sub 0 Super;
}  lookup Super {
    sub [A-Z] -> [uniEAA1 - uniEABA];
    sub [a-z] -> [uniEAC1 - uniEADA];
    sub Egrave -> uniEB28;
    sub Uacute -> uniEB3A;
    sub egrave -> uniEB48;
    sub uacute -> uniEB5A;
}
The @Ordinals group includes the digits, OldStyle figures, and the Superscripts, so any character in the @Alpha group following a digit or superscript in the @Ordinals group will use the "Super" lookup table, and will also be superscripted. As soon as a character not included in the @Alpha group is encountered, the superscripted text reverts to normal text.

The attachment illustrates the feature at work using the TrueType Viewer utility.
Attachments
Ordinals.png
Ordinals.png (20.68 KiB) Viewed 55860 times
My FontsReviews: MainTypeFont CreatorHelpFC15 + MT12.0 @ Win 10 64-bit build 19045.2486
Erwin Denissen
Moderator
Moderator
Posts: 11107
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: Adding OpenType features

Post by Erwin Denissen »

Thanks for explaining all the reasoning behind these OpenType features. This will help us with the decision when and how we are going to add OTL editing support in FontCreator.

UPDATE: OpenType layout features are supported since FontCreator version 7 without using third party tools.
Erwin Denissen
High-Logic
Proven Font Technology
Post Reply