## FreeType Fonts

FreeType Fonts —

## Synopsis

    cairo_font_face_t* cairo_ft_font_face_create_for_pattern
                                                (FcPattern *pattern);
    cairo_font_face_t* cairo_ft_font_face_create_for_ft_face
                                                (FT_Face face,
                                                 int load_flags);
    FT_Face     cairo_ft_scaled_font_lock_face  (cairo_scaled_font_t *scaled_font);
    void        cairo_ft_scaled_font_unlock_face
                                                (cairo_scaled_font_t *scaled_font);

## Description

## Details

### cairo_ft_font_face_create_for_pattern ()

    cairo_font_face_t* cairo_ft_font_face_create_for_pattern
                                                (FcPattern *pattern);

Creates a new font face for the FreeType font backend based on a fontconfig pattern. This font can then be used with `cairo_set_font_face()` or `cairo_font_create()`. The cairo_scaled_font_t returned from `cairo_font_create()` is also for the FreeType backend and can be used with functions such as `cairo_ft_font_lock_face()`.

`pattern` : | A fully resolved fontconfig pattern. A pattern can be resolved, by, among other things, calling `FcConfigSubstitute()`, `FcDefaultSubstitute()`, then `FcFontMatch()`. Cairo will call `FcPatternReference()` on this pattern, so you should not further modify the pattern, but you can release your reference to the pattern with `FcPatternDestroy()` if you no longer need to access it.
Returns : | a newly created cairo_font_face_t. Free with `cairo_font_face_destroy()` when you are done using it.

### cairo_ft_font_face_create_for_ft_face ()

    cairo_font_face_t* cairo_ft_font_face_create_for_ft_face
                                                (FT_Face face,
                                                 int load_flags);

Creates a new font face for the FreeType font backend from a pre-opened FreeType face. This font can then be used with `cairo_set_font_face()` or `cairo_font_create()`. The cairo_scaled_font_t returned from `cairo_font_create()` is also for the FreeType backend and can be used with functions such as `cairo_ft_font_lock_face()`.

`face` : | A FreeType face object, already opened. This must be kept around until the face's refcount drops to zero and it is freed. Since the face may be referenced internally to Cairo, the best way to determine when it is safe to free the face is to pass a cairo_destroy_func_t to `cairo_font_face_set_user_data()`
`load_flags` : | The flags to pass to FT_Load_Glyph when loading glyphs from the font. These flags control aspects of rendering such as hinting and antialiasing. See the FreeType docs for full information.
Returns : | a newly created cairo_font_face_t. Free with `cairo_font_face_destroy()` when you are done using it.

### cairo_ft_scaled_font_lock_face ()

    FT_Face     cairo_ft_scaled_font_lock_face  (cairo_scaled_font_t *scaled_font);

`cairo_ft_font_lock_face()` gets the FT_Face object from a FreeType backend font and scales it appropriately for the font. You must release the face with `cairo_ft_font_unlock_face()` when you are done using it. Since the FT_Face object can be shared between multiple cairo_scaled_font_t objects, you must not lock any other font objects until you unlock this one. A count is kept of the number of times `cairo_ft_font_lock_face()` is called. `cairo_ft_font_unlock_face()` must be called the same number of times.

You must be careful when using this function in a library or in a threaded application, because other threads may lock faces that share the same FT_Face object. For this reason, you must call `cairo_ft_lock()` before locking any face objects, and `cairo_ft_unlock()` after you are done. (These functions are not yet implemented, so this function cannot be currently safely used in a threaded application.)

`scaled_font` : | A cairo_scaled_font_t from the FreeType font backend. Such an object can be created by calling `cairo_scaled_font_create()` on a FreeType backend font face (see `cairo_ft_font_face_create_for_pattern()`, `cairo_ft_font_face_create_for_face()`).
Returns : | The FT_Face object for `font`, scaled appropriately.

### cairo_ft_scaled_font_unlock_face ()

    void        cairo_ft_scaled_font_unlock_face
                                                (cairo_scaled_font_t *scaled_font);

Releases a face obtained with `cairo_ft_font_lock_face()`. See the documentation for that function for full details.

`scaled_font` : | A cairo_scaled_font_t from the FreeType font backend. Such an object can be created by calling `cairo_scaled_font_create()` on a FreeType backend font face (see `cairo_ft_font_face_create_for_pattern()`, `cairo_ft_font_face_create_for_face()`).