# FreeType-2.6 API Reference

# Glyph Variants

## Synopsis

FT_Face_GetCharVariantIndex | FT_Face_GetVariantsOfChar
FT_Face_GetCharVariantIsDefault | FT_Face_GetCharsOfVariant
FT_Face_GetVariantSelectors |

Many CJK characters have variant forms. They are a sort of grey area somewhere between being totally irrelevant and semantically distinct; for this reason, the Unicode consortium decided to introduce Ideographic Variation Sequences (IVS), consisting of a Unicode base character and one of 240 variant selectors (U+E0100-U+E01EF), instead of further extending the already huge code range for CJK characters.

An IVS is registered and unique; for further details please refer to Unicode Technical Standard #37, the Ideographic Variation Database:

http://www.unicode.org/reports/tr37/

To date (November 2014), the character with the most variants is U+9089, having 32 such IVS.

Adobe and MS decided to support IVS with a new cmap subtable (format 14). It is an odd subtable because it is not a mapping of input code points to glyphs, but contains lists of all variants supported by the font.

A variant may be either ‘default’ or ‘non-default’. A default variant is the one you will get for that code point if you look it up in the standard Unicode cmap. A non-default variant is a different glyph.

### FT_Face_GetCharVariantIndex

Defined in FT_FREETYPE_H (freetype.h).

      FT_EXPORT( FT_UInt )
      FT_Face_GetCharVariantIndex( FT_Face   face,
                                   FT_ULong  charcode,
                                   FT_ULong  variantSelector );

Return the glyph index of a given character code as modified by the variation selector.

#### input

face | A handle to the source face object.
charcode | The character code point in Unicode.
variantSelector | The Unicode code point of the variation selector.

#### return

The glyph index. 0 means either ‘undefined character code’, or ‘undefined selector code’, or ‘no variation selector cmap subtable’, or ‘current CharMap is not Unicode’.

#### note

If you use FreeType to manipulate the contents of font files directly, be aware that the glyph index returned by this function doesn't always correspond to the internal indices used within the file. This is done to ensure that value 0 always corresponds to the ‘missing glyph’.

This function is only meaningful if a) the font has a variation selector cmap sub table, and b) the current charmap has a Unicode encoding.

#### since

2.3.6

### FT_Face_GetCharVariantIsDefault

Defined in FT_FREETYPE_H (freetype.h).

      FT_EXPORT( FT_Int )
      FT_Face_GetCharVariantIsDefault( FT_Face   face,
                                       FT_ULong  charcode,
                                       FT_ULong  variantSelector );

Check whether this variant of this Unicode character is the one to be found in the ‘cmap’.

#### input

face | A handle to the source face object.
charcode | The character codepoint in Unicode.
variantSelector | The Unicode codepoint of the variation selector.

#### return

1 if found in the standard (Unicode) cmap, 0 if found in the variation selector cmap, or -1 if it is not a variant.

#### note

This function is only meaningful if the font has a variation selector cmap subtable.

#### since

2.3.6

### FT_Face_GetVariantSelectors

Defined in FT_FREETYPE_H (freetype.h).

      FT_EXPORT( FT_UInt32* )
      FT_Face_GetVariantSelectors( FT_Face  face );

Return a zero-terminated list of Unicode variant selectors found in the font.

#### input

face | A handle to the source face object.

#### return

A pointer to an array of selector code points, or NULL if there is no valid variant selector cmap subtable.

#### note

The last item in the array is 0; the array is owned by the FT_Face object but can be overwritten or released on the next call to a FreeType function.

#### since

2.3.6

### FT_Face_GetVariantsOfChar

Defined in FT_FREETYPE_H (freetype.h).

      FT_EXPORT( FT_UInt32* )
      FT_Face_GetVariantsOfChar( FT_Face   face,
                                 FT_ULong  charcode );

Return a zero-terminated list of Unicode variant selectors found for the specified character code.

#### input

face | A handle to the source face object.
charcode | The character codepoint in Unicode.

#### return

A pointer to an array of variant selector code points that are active for the given character, or NULL if the corresponding list is empty.

#### note

The last item in the array is 0; the array is owned by the FT_Face object but can be overwritten or released on the next call to a FreeType function.

#### since

2.3.6

### FT_Face_GetCharsOfVariant

Defined in FT_FREETYPE_H (freetype.h).

      FT_EXPORT( FT_UInt32* )
      FT_Face_GetCharsOfVariant( FT_Face   face,
                                 FT_ULong  variantSelector );

Return a zero-terminated list of Unicode character codes found for the specified variant selector.

#### input

face | A handle to the source face object.
variantSelector | The variant selector code point in Unicode.

#### return

A list of all the code points that are specified by this selector (both default and non-default codes are returned) or NULL if there is no valid cmap or the variant selector is invalid.

#### note

The last item in the array is 0; the array is owned by the FT_Face object but can be overwritten or released on the next call to a FreeType function.

#### since

2.3.6