Functions
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_scaled_font_create(). The
cairo_scaled_font_t returned from cairo_scaled_font_create() is
also for the FreeType backend and can be used with functions such
as cairo_ft_scaled_font_lock_face(). Note that Cairo may keep a reference
to the FT_Face alive in a font-cache and the exact lifetime of the reference
depends highly upon the exact usage pattern and is subject to external
factors. You must not call FT_Done_Face() before the last reference to the
cairo_font_face_t has been dropped.
As an example, below is how one might correctly couple the lifetime of
the FreeType face object to the cairo_font_face_t.
Since: 1.0
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_scaled_font_create(). The
cairo_scaled_font_t returned from cairo_scaled_font_create() is
also for the FreeType backend and can be used with functions such
as cairo_ft_scaled_font_lock_face().
Font rendering options are represented both here and when you
call cairo_scaled_font_create(). Font options that have a representation
in a FcPattern must be passed in here; to modify FcPattern
appropriately to reflect the options in a cairo_font_options_t, call
cairo_ft_font_options_substitute().
The pattern's FC_FT_FACE element is inspected first and if that is set,
that will be the FreeType font face associated with the returned cairo
font face. Otherwise the FC_FILE element is checked. If it's set,
that and the value of the FC_INDEX element (defaults to zero) of pattern
are used to load a font face from file.
If both steps from the previous paragraph fails, pattern
will be passed
to FcConfigSubstitute, FcDefaultSubstitute, and finally FcFontMatch,
and the resulting font pattern is used.
If the FC_FT_FACE element of pattern
is set, the user is responsible
for making sure that the referenced FT_Face remains valid for the life
time of the returned cairo_font_face_t. See
cairo_ft_font_face_create_for_ft_face() for an example of how to couple
the life time of the FT_Face to that of the cairo font-face.
Since: 1.0
cairo_ft_font_options_substitute ()
void
cairo_ft_font_options_substitute (const cairo_font_options_t *options,
FcPattern *pattern);
Add options to a FcPattern based on a cairo_font_options_t font
options object. Options that are already in the pattern, are not overridden,
so you should call this function after calling FcConfigSubstitute() (the
user's settings should override options based on the surface type), but
before calling FcDefaultSubstitute().
Since: 1.0
cairo_ft_scaled_font_lock_face ()
FT_Face
cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *scaled_font);
cairo_ft_scaled_font_lock_face() gets the FT_Face object from a FreeType
backend font and scales it appropriately for the font and applies OpenType
font variations if applicable. You must
release the face with cairo_ft_scaled_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_scaled_font_lock_face() is
called. cairo_ft_scaled_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 freetype's design makes it unsafe to
call freetype functions simultaneously from multiple threads, (even
if using distinct FT_Face objects). Because of this, application
code that acquires an FT_Face object with this call must add its
own locking to protect any use of that object, (and which also must
protect any other calls into cairo as almost any cairo function
might result in a call into the freetype library).
Returns
The FT_Face object for font
, scaled appropriately,
or NULL if scaled_font
is in an error state (see
cairo_scaled_font_status()) or there is insufficient memory.
Since: 1.0
cairo_ft_font_face_get_synthesize ()
unsigned int
cairo_ft_font_face_get_synthesize (cairo_font_face_t *font_face);
See cairo_ft_synthesize_t.
Returns
the current set of synthesis options.
Since: 1.12
cairo_ft_font_face_set_synthesize ()
void
cairo_ft_font_face_set_synthesize (cairo_font_face_t *font_face,
unsigned int synth_flags);
FreeType provides the ability to synthesize different glyphs from a base
font, which is useful if you lack those glyphs from a true bold or oblique
font. See also cairo_ft_synthesize_t.
Since: 1.12
Types and Values
CAIRO_HAS_FT_FONT
#define CAIRO_HAS_FT_FONT 1
Defined if the FreeType font backend is available.
This macro can be used to conditionally compile backend-specific code.
Since: 1.0
CAIRO_HAS_FC_FONT
#define CAIRO_HAS_FC_FONT 1
Defined if the Fontconfig-specific functions of the FreeType font backend
are available.
This macro can be used to conditionally compile backend-specific code.
Since: 1.10