OpenType Layout Features - Pos

<< Click to Display Table of Contents >>

Navigation:  Editing Fonts > Format > OpenType Layout Features > Script Editor > Script Syntax >

OpenType Layout Features - Pos

The pos keyword declares a glyph positioning. As explained in the supported glyph positioning types there are several positioning types. Positioning declarations can only be declared in lookups. It is not possible to declare a positioning directly in a feature. Each lookup can only have one type of positioning; this means that if you want to use several positioning types in a single feature, multiple lookups have to be declared.

For most positioning declarations several coordinates can be defined that determine the glyph's positioning changes. Each declaration consists of one to four coordinates.

 

The format of a coordinate is (including brackets):

<XAdvance YAdvance XPlacement YPlacement>

The XAdvance must always be specified, the YAdvance, XPlacement and YPlacement are optional.

 

XAdvance

horizontal adjustment for advance

YAdvance

vertical adjustment for advance

XPlacement

horizontal adjustment for placement

YPlacement

vertical adjustment for placement

 

Declaring Single adjustments (Type 1) positioning

Single positioning is used to alter the position of a single glyph or glyph class and can be used to easily create subscript and superscript like features using the same glyphs.

lookup MyLookupTable {
 pos A <-20 [0 0 0]>;
}

 

For classes the syntax is very similar:

class @class1 [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]

 

lookup MyLookupTable {
 pos @class1 <-20>
}

 

Declaring Pair adjustments (Type 2) positioning

Pair positioning is used to alter the position of 2 glyphs or glyph classes and is mostly used to define kerning pairs.

lookup MyLookupTable {
 pos A B <-10 [0 0 0]> [<0 [0]>];
}

 

For classes the syntax is very similar:

class @class1 [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]

class @class2 [a b c d e f g h i j k l m n o p q r s t u v w x y z]

 

lookup MyLookupTable {
 pos @class1 @class2 <-20>
}

 

This will create 676 kerning pairs with a value of -20 with only one line of code.

It is also possible to combine a class with a single glyph:

class @class1 [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]

 

lookup MyLookupTable {
 pos @class1 hyphen <-10>
}

 

This will create 26 kerning pairs with a value of -10 with only one line of code

 

Declaring Mark‑to‑Base (Type 4) positioning

Mark‑to‑Base positioning is used to attach mark glyphs (diacritics) to base glyphs using anchors.

lookup MyLookupTable {
 mark acute 0 0;

 mark ring 0 0;

 pos A mark  -10 30;

 pos B mark -10 20;

 mark esp 0 0;

 pos A mark -10 20;
}

 

 

Declaring Mark‑to‑Mark (Type 6) positioning

Mark‑to‑Mark positioning is used to attach mark glyphs to other mark glyphs.

The syntax is the same as for Mark‑to‑Base positioning, but only mark glyphs are used.

 

Declaring Chained Context (Type 8) positioning

This is syntax is identical  to the GSUB syntax. The only difference is that the substitution tables are GPOS lookups instead of GSUB lookups.