OpenType Layout Features - Pos

Previous  Next

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 glyphs 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 group 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 groups the syntax is very similar:

group @group1 [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 @group1 <-20>
}

 

Declaring Pair adjustments (Type 2) positioning

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

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

 

For groups the syntax is very similar:

group @group1 [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]

group @group2 [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 @group1 @group2 <-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 group with a single glyph:

group @group1 [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 @group1 hypen <-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 (diacritcs) 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 exactly the same for Mark to Mark 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.