Skip to content

FreeType » Docs » Core API » Font Testing Macros

# Font Testing Macros

## Synopsis

Macros to test the most important font properties.

It is recommended to use these high-level macros instead of directly testing the corresponding flags, which are scattered over various structures.

## FT_HAS_HORIZONTAL

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_HORIZONTAL( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL ) )

A macro that returns true whenever a face object contains horizontal metrics (this is true for all font formats though).

#### also

`FT_HAS_VERTICAL` can be used to check for vertical metrics.

## FT_HAS_VERTICAL

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_VERTICAL( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_VERTICAL ) )

A macro that returns true whenever a face object contains real vertical metrics (and not only synthesized ones).

## FT_HAS_KERNING

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_KERNING( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_KERNING ) )

A macro that returns true whenever a face object contains kerning data that can be accessed with `FT_Get_Kerning`.

## FT_HAS_FIXED_SIZES

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_FIXED_SIZES( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES ) )

A macro that returns true whenever a face object contains some embedded bitmaps. See the `available_sizes` field of the `FT_FaceRec` structure.

## FT_HAS_GLYPH_NAMES

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_GLYPH_NAMES( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) )

A macro that returns true whenever a face object contains some glyph names that can be accessed through `FT_Get_Glyph_Name`.

## FT_HAS_COLOR

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_COLOR( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_COLOR ) )

A macro that returns true whenever a face object contains tables for color glyphs.

#### since

2.5.1

## FT_HAS_MULTIPLE_MASTERS

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_MULTIPLE_MASTERS( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) )

A macro that returns true whenever a face object contains some multiple masters. The functions provided by `FT_MULTIPLE_MASTERS_H` are then available to choose the exact design you want.

## FT_HAS_SVG

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_SVG( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_SVG ) )

A macro that returns true whenever a face object contains an ‘SVG ’ OpenType table.

#### since

2.12

## FT_HAS_SBIX

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_SBIX( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX ) )

A macro that returns true whenever a face object contains an ‘sbix’ OpenType table and outline glyphs.

Currently, FreeType only supports bitmap glyphs in PNG format for this table (i.e., JPEG and TIFF formats are unsupported, as are Apple-specific formats not part of the OpenType specification).

#### note

For backward compatibility, a font with an ‘sbix’ table is treated as a bitmap-only face. Using `FT_Open_Face` with `FT_PARAM_TAG_IGNORE_SBIX`, an application can switch off ‘sbix’ handling so that the face is treated as an ordinary outline font with scalable outlines.

Here is some pseudo code that roughly illustrates how to implement ‘sbix’ handling according to the OpenType specification.

      if ( FT_HAS_SBIX( face ) )
      {
        // open font as a scalable one without sbix handling
        FT_Face       face2;
        FT_Parameter  param = { FT_PARAM_TAG_IGNORE_SBIX, NULL };
        FT_Open_Args  args  = { FT_OPEN_PARAMS | ...,
                                ...,
                                1, &param };

        FT_Open_Face( library, &args, 0, &face2 );

        <sort `face->available_size` as necessary into
         `preferred_sizes`[*]>

        for ( i = 0; i < face->num_fixed_sizes; i++ )
        {
          size = preferred_sizes[i].size;

          error = FT_Set_Pixel_Sizes( face, size, size );
          <error handling omitted>

          // check whether we have a glyph in a bitmap strike
          error = FT_Load_Glyph( face,
                                 glyph_index,
                                 FT_LOAD_SBITS_ONLY          |
                                 FT_LOAD_BITMAP_METRICS_ONLY );
          if ( error == FT_Err_Invalid_Argument )
            continue;
          else if ( error )
            <other error handling omitted>
          else
            break;
        }

        if ( i != face->num_fixed_sizes )
          <load embedded bitmap with `FT_Load_Glyph`,
           scale it, display it, etc.>

        if ( i == face->num_fixed_sizes  ||
             FT_HAS_SBIX_OVERLAY( face ) )
          <use `face2` to load outline glyph with `FT_Load_Glyph`,
           scale it, display it on top of the bitmap, etc.>
      }

[*] Assuming a target value of 400dpi and available strike sizes 100, 200, 300, and 400dpi, a possible order might be [400, 200, 300, 100]: scaling 200dpi to 400dpi usually gives better results than scaling 300dpi to 400dpi; it is also much faster. However, scaling 100dpi to 400dpi can yield a too pixelated result, thus the preference might be 300dpi over 100dpi.

#### since

2.12

## FT_HAS_SBIX_OVERLAY

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_HAS_SBIX_OVERLAY( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_SBIX_OVERLAY ) )

A macro that returns true whenever a face object contains an ‘sbix’ OpenType table with bit 1 in its `flags` field set, instructing the application to overlay the bitmap strike with the corresponding outline glyph. See `FT_HAS_SBIX` for pseudo code how to use it.

#### since

2.12

## FT_IS_SFNT

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_SFNT( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_SFNT ) )

A macro that returns true whenever a face object contains a font whose format is based on the SFNT storage scheme. This usually means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded bitmap fonts.

If this macro is true, all functions defined in `FT_SFNT_NAMES_H` and `FT_TRUETYPE_TABLES_H` are available.

## FT_IS_SCALABLE

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_SCALABLE( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_SCALABLE ) )

A macro that returns true whenever a face object contains a scalable font face (true for TrueType, Type 1, Type 42, CID, OpenType/CFF, and PFR font formats).

## FT_IS_FIXED_WIDTH

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_FIXED_WIDTH( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) )

A macro that returns true whenever a face object contains a font face that contains fixed-width (or ‘monospace’, ‘fixed-pitch’, etc.) glyphs.

## FT_IS_CID_KEYED

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_CID_KEYED( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_CID_KEYED ) )

A macro that returns true whenever a face object contains a CID-keyed font. See the discussion of `FT_FACE_FLAG_CID_KEYED` for more details.

If this macro is true, all functions defined in `FT_CID_H` are available.

## FT_IS_TRICKY

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_TRICKY( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_TRICKY ) )

A macro that returns true whenever a face represents a ‘tricky’ font. See the discussion of `FT_FACE_FLAG_TRICKY` for more details.

## FT_IS_NAMED_INSTANCE

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_NAMED_INSTANCE( face ) \
              ( !!( (face)->face_index & 0x7FFF0000L ) )

A macro that returns true whenever a face object is a named instance of a GX or OpenType variation font.

[Since 2.9] Changing the design coordinates with `FT_Set_Var_Design_Coordinates` or `FT_Set_Var_Blend_Coordinates` does not influence the return value of this macro (only `FT_Set_Named_Instance` does that).

#### since

2.7

## FT_IS_VARIATION

Defined in FT_FREETYPE_H (freetype/freetype.h).

    #define FT_IS_VARIATION( face ) \
              ( !!( (face)->face_flags & FT_FACE_FLAG_VARIATION ) )

A macro that returns true whenever a face object has been altered by `FT_Set_MM_Design_Coordinates`, `FT_Set_Var_Design_Coordinates`, `FT_Set_Var_Blend_Coordinates`, or `FT_Set_MM_WeightVector`.

#### since

2.9