
@c %start of fragment

@deffn Function cairo-select-font-face  (@var{cr}@tie{}@code{<cairo-t>}) (@var{family}@tie{}@code{<char>}) (@var{slant}@tie{}@code{<cairo-font-slant-t>}) (@var{weight}@tie{}@code{<cairo-font-weight-t>})
Note: The @code{cairo-select-font-face} function call is part of what
the cairo designers call the "toy" text API. It is convenient for short
demos and simple programs, but it is not expected to be adequate for
serious text-using applications.

Selects a family and style of font from a simplified description as a
family name, slant and weight. Cairo provides no operation to list
available family names on the system (this is a "toy", remember), but
the standard CSS2 generic family names, ("serif", "sans-serif",
"cursive", "fantasy", "monospace"), are likely to work as expected.

If @var{family} starts with the string "@var{cairo}:", or if no native
font backends are compiled in, cairo will use an internal font family.
The internal font family recognizes many modifiers in the @var{family}
string, most notably, it recognizes the string "monospace". That is, the
family name "@var{cairo}:monospace" will use the monospace version of
the internal font family.

For "real" font selection, see the font-backend-specific
font_face_create functions for the font backend you are using. (For
example, if you are using the freetype-based cairo-ft font backend, see
@code{cairo-ft-font-face-create-for-ft-face} or
@code{cairo-ft-font-face-create-for-pattern}.) The resulting font face
could then be used with @code{cairo-scaled-font-create} and
@code{cairo-set-scaled-font}.

Similarly, when using the "real" font support, you can call directly
into the underlying font system, (such as fontconfig or freetype), for
operations such as listing available fonts, etc.

It is expected that most applications will need to use a more
comprehensive font handling and text layout library, (for example,
pango), in conjunction with cairo.

If text is drawn without a call to @code{cairo-select-font-face}, (nor
@code{cairo-set-font-face} nor @code{cairo-set-scaled-font}), the
default family is platform-specific, but is essentially "sans-serif".
Default slant is @samp{CAIRO_FONT_SLANT_NORMAL}, and default weight is
@samp{CAIRO_FONT_WEIGHT_NORMAL}.

This function is equivalent to a call to
@code{cairo-toy-font-face-create} followed by
@code{cairo-set-font-face}.

@table @var
@item cr
a @code{<cairo-t>}

@item family
a font family name, encoded in UTF-8

@item slant
the slant for the font

@item weight
the weight for the font

@end table

@end deffn

@deffn Function cairo-set-font-size  (@var{cr}@tie{}@code{<cairo-t>}) (@var{size}@tie{}@code{<double>})
Sets the current font matrix to a scale by a factor of @var{size},
replacing any font matrix previously set with @code{cairo-set-font-size}
or @code{cairo-set-font-matrix}. This results in a font size of
@var{size} user space units. (More precisely, this matrix will result in
the font's em-square being a @var{size} by @var{size} square in user
space.)

If text is drawn without a call to @code{cairo-set-font-size}, (nor
@code{cairo-set-font-matrix} nor @code{cairo-set-scaled-font}), the
default font size is 10.0.

@table @var
@item cr
a @code{<cairo-t>}

@item size
the new font size, in user space units

@end table

@end deffn

@deffn Function cairo-set-font-matrix  (@var{cr}@tie{}@code{<cairo-t>}) (@var{matrix}@tie{}@code{<cairo-matrix-t>})
Sets the current font matrix to @var{matrix}. The font matrix gives a
transformation from the design space of the font (in this space, the
em-square is 1 unit by 1 unit) to user space. Normally, a simple scale
is used (see @code{cairo-set-font-size}), but a more complex font matrix
can be used to shear the font or stretch it unequally along the two axes

@table @var
@item cr
a @code{<cairo-t>}

@item matrix
a @code{<cairo-matrix-t>} describing a transform to be applied to the
current font.

@end table

@end deffn

@deffn Function cairo-get-font-matrix  (@var{cr}@tie{}@code{<cairo-t>}) (@var{matrix}@tie{}@code{<cairo-matrix-t>})
Stores the current font matrix into @var{matrix}. See
@code{cairo-set-font-matrix}.

@table @var
@item cr
a @code{<cairo-t>}

@item matrix
return value for the matrix

@end table

@end deffn

@deffn Function cairo-set-font-options  (@var{cr}@tie{}@code{<cairo-t>}) (@var{options}@tie{}@code{<cairo-font-options-t>})
Sets a set of custom font rendering options for the @code{<cairo-t>}.
Rendering options are derived by merging these options with the options
derived from underlying surface; if the value in @var{options} has a
default value (like @samp{CAIRO_ANTIALIAS_DEFAULT}), then the value from
the surface is used.

@table @var
@item cr
a @code{<cairo-t>}

@item options
font options to use

@end table

@end deffn

@deffn Function cairo-get-font-options  (@var{cr}@tie{}@code{<cairo-t>}) (@var{options}@tie{}@code{<cairo-font-options-t>})
Retrieves font rendering options set via
@code{<cairo-set-font-options>}. Note that the returned options do not
include any options derived from the underlying surface; they are
literally the options passed to @code{cairo-set-font-options}.

@table @var
@item cr
a @code{<cairo-t>}

@item options
a @code{<cairo-font-options-t>} object into which to store the retrieved
options. All existing values are overwritten

@end table

@end deffn

@deffn Function cairo-set-font-face  (@var{cr}@tie{}@code{<cairo-t>}) (@var{font-face}@tie{}@code{<cairo-font-face-t>})
Replaces the current @code{<cairo-font-face-t>} object in the
@code{<cairo-t>} with @var{font-face}. The replaced font face in the
@code{<cairo-t>} will be destroyed if there are no other references to
it.

@table @var
@item cr
a @code{<cairo-t>}

@item font-face
a @code{<cairo-font-face-t>}, or @samp{@code{#f}} to restore to the
default font

@end table

@end deffn

@deffn Function cairo-get-font-face  (@var{cr}@tie{}@code{<cairo-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-font-face-t >})
Gets the current font face for a @code{<cairo-t>}.

@table @var
@item cr
a @code{<cairo-t>}

@item ret
the current font face. This object is owned by cairo. To keep a
reference to it, you must call @code{cairo-font-face-reference}. This
function never returns @samp{@code{#f}}. If memory cannot be allocated,
a special "nil" @code{<cairo-font-face-t>} object will be returned on
which @code{cairo-font-face-status} returns
@samp{CAIRO_STATUS_NO_MEMORY}. Using this nil object will cause its
error state to propagate to other objects it is passed to, (for example,
calling @code{cairo-set-font-face} with a nil font will trigger an error
that will shutdown the @code{<cairo-t>} object).

@end table

@end deffn

@deffn Function cairo-set-scaled-font  (@var{cr}@tie{}@code{<cairo-t>}) (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>})
Replaces the current font face, font matrix, and font options in the
@code{<cairo-t>} with those of the @code{<cairo-scaled-font-t>}. Except
for some translation, the current CTM of the @code{<cairo-t>} should be
the same as that of the @code{<cairo-scaled-font-t>}, which can be
accessed using @code{cairo-scaled-font-get-ctm}.

@table @var
@item cr
a @code{<cairo-t>}

@item scaled-font
a @code{<cairo-scaled-font-t>}

@end table

Since 1.2

@end deffn

@deffn Function cairo-get-scaled-font  (@var{cr}@tie{}@code{<cairo-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-scaled-font-t >})
Gets the current scaled font for a @code{<cairo-t>}.

@table @var
@item cr
a @code{<cairo-t>}

@item ret
the current scaled font. This object is owned by cairo. To keep a
reference to it, you must call @code{cairo-scaled-font-reference}. This
function never returns @samp{@code{#f}}. If memory cannot be allocated,
a special "nil" @code{<cairo-scaled-font-t>} object will be returned on
which @code{cairo-scaled-font-status} returns
@samp{CAIRO_STATUS_NO_MEMORY}. Using this nil object will cause its
error state to propagate to other objects it is passed to, (for example,
calling @code{cairo-set-scaled-font} with a nil font will trigger an
error that will shutdown the @code{<cairo-t>} object).

@end table

Since 1.4

@end deffn

@deffn Function cairo-show-text  (@var{cr}@tie{}@code{<cairo-t>}) (@var{utf8}@tie{}@code{<char>})
A drawing operator that generates the shape from a string of UTF-8
characters, rendered according to the current font_face, font_size
(font_matrix), and font_options.

This function first computes a set of glyphs for the string of text. The
first glyph is placed so that its origin is at the current point. The
origin of each subsequent glyph is offset from that of the previous
glyph by the advance values of the previous glyph.

After this call the current point is moved to the origin of where the
next glyph would be placed in this same progression. That is, the
current point will be at the origin of the final glyph offset by its
advance values. This allows for easy display of a single logical string
with multiple calls to @code{cairo-show-text}.

Note: The @code{cairo-show-text} function call is part of what the cairo
designers call the "toy" text API. It is convenient for short demos and
simple programs, but it is not expected to be adequate for serious
text-using applications. See @code{cairo-show-glyphs} for the "real"
text display API in cairo.

@table @var
@item cr
a cairo context

@item utf8
a NUL-terminated string of text encoded in UTF-8, or @samp{@code{#f}}

@end table

@end deffn

@deffn Function cairo-show-glyphs  (@var{cr}@tie{}@code{<cairo-t>}) (@var{glyphs}@tie{}@code{<cairo-glyph-t>}) (@var{num-glyphs}@tie{}@code{<int>})
A drawing operator that generates the shape from an array of glyphs,
rendered according to the current font face, font size (font matrix),
and font options.

@table @var
@item cr
a cairo context

@item glyphs
array of glyphs to show

@item num-glyphs
number of glyphs to show

@end table

@end deffn

@deffn Function cairo-show-text-glyphs  (@var{cr}@tie{}@code{<cairo-t>}) (@var{utf8}@tie{}@code{<char>}) (@var{utf8-len}@tie{}@code{<int>}) (@var{glyphs}@tie{}@code{<cairo-glyph-t>}) (@var{num-glyphs}@tie{}@code{<int>}) (@var{clusters}@tie{}@code{<cairo-text-cluster-t>}) (@var{num-clusters}@tie{}@code{<int>}) (@var{cluster-flags}@tie{}@code{<cairo-text-cluster-flags-t>})
This operation has rendering effects similar to @code{cairo-show-glyphs}
but, if the target surface supports it, uses the provided text and
cluster mapping to embed the text for the glyphs shown in the output. If
the target does not support the extended attributes, this function acts
like the basic @code{cairo-show-glyphs} as if it had been passed
@var{glyphs} and @var{num-glyphs}.

The mapping between @var{utf8} and @var{glyphs} is provided by an array
of @dfn{clusters}. Each cluster covers a number of text bytes and
glyphs, and neighboring clusters cover neighboring areas of @var{utf8}
and @var{glyphs}. The clusters should collectively cover @var{utf8} and
@var{glyphs} in entirety.

The first cluster always covers bytes from the beginning of @var{utf8}.
If @var{cluster-flags} do not have the
@samp{CAIRO_TEXT_CLUSTER_FLAG_BACKWARD} set, the first cluster also
covers the beginning of @var{glyphs}, otherwise it covers the end of the
@var{glyphs} array and following clusters move backward.

See @code{<cairo-text-cluster-t>} for constraints on valid clusters.

@table @var
@item cr
a cairo context

@item utf8
a string of text encoded in UTF-8

@item utf8-len
length of @var{utf8} in bytes, or -1 if it is NUL-terminated

@item glyphs
array of glyphs to show

@item num-glyphs
number of glyphs to show

@item clusters
array of cluster mapping information

@item num-clusters
number of clusters in the mapping

@item cluster-flags
cluster mapping flags

@end table

Since 1.8

@end deffn

@deffn Function cairo-font-extents  (@var{cr}@tie{}@code{<cairo-t>}) (@var{extents}@tie{}@code{<cairo-font-extents-t>})
Gets the font extents for the currently selected font.

@table @var
@item cr
a @code{<cairo-t>}

@item extents
a @code{<cairo-font-extents-t>} object into which the results will be
stored.

@end table

@end deffn

@deffn Function cairo-text-extents  (@var{cr}@tie{}@code{<cairo-t>}) (@var{utf8}@tie{}@code{<char>}) (@var{extents}@tie{}@code{<cairo-text-extents-t>})
Gets the extents for a string of text. The extents describe a user-space
rectangle that encloses the "inked" portion of the text, (as it would be
drawn by @code{cairo-show-text}). Additionally, the x_advance and
y_advance values indicate the amount by which the current point would be
advanced by @code{cairo-show-text}.

Note that whitespace characters do not directly contribute to the size
of the rectangle (extents.width and extents.height). They do contribute
indirectly by changing the position of non-whitespace characters. In
particular, trailing whitespace characters are likely to not affect the
size of the rectangle, though they will affect the x_advance and
y_advance values.

@table @var
@item cr
a @code{<cairo-t>}

@item utf8
a NUL-terminated string of text encoded in UTF-8, or @samp{@code{#f}}

@item extents
a @code{<cairo-text-extents-t>} object into which the results will be
stored

@end table

@end deffn

@deffn Function cairo-glyph-extents  (@var{cr}@tie{}@code{<cairo-t>}) (@var{glyphs}@tie{}@code{<cairo-glyph-t>}) (@var{num-glyphs}@tie{}@code{<int>}) (@var{extents}@tie{}@code{<cairo-text-extents-t>})
Gets the extents for an array of glyphs. The extents describe a
user-space rectangle that encloses the "inked" portion of the glyphs,
(as they would be drawn by @code{cairo-show-glyphs}). Additionally, the
x_advance and y_advance values indicate the amount by which the current
point would be advanced by @code{cairo-show-glyphs}.

Note that whitespace glyphs do not contribute to the size of the
rectangle (extents.width and extents.height).

@table @var
@item cr
a @code{<cairo-t>}

@item glyphs
an array of @code{<cairo-glyph-t>} objects

@item num-glyphs
the number of elements in @var{glyphs}

@item extents
a @code{<cairo-text-extents-t>} object into which the results will be
stored

@end table

@end deffn

@deffn Function cairo-toy-font-face-create  (@var{family}@tie{}@code{<char>}) (@var{slant}@tie{}@code{<cairo-font-slant-t>}) (@var{weight}@tie{}@code{<cairo-font-weight-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-font-face-t >})
Creates a font face from a triplet of family, slant, and weight. These
font faces are used in implementation of the the @code{<cairo-t>} "toy"
font API.

If @var{family} is the zero-length string "", the platform-specific
default family is assumed. The default family then can be queried using
@code{cairo-toy-font-face-get-family}.

The @code{cairo-select-font-face} function uses this to create font
faces. See that function for limitations and other details of toy font
faces.

@table @var
@item family
a font family name, encoded in UTF-8

@item slant
the slant for the font

@item weight
the weight for the font

@item ret
a newly created @code{<cairo-font-face-t>}. Free with
@code{cairo-font-face-destroy} when you are done using it.

@end table

Since 1.8

@end deffn

@deffn Function cairo-toy-font-face-get-family  (@var{font-face}@tie{}@code{<cairo-font-face-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<char >})
Gets the familly name of a toy font.

@table @var
@item font-face
A toy font face

@item ret
The family name. This string is owned by the font face and remains valid
as long as the font face is alive (referenced).

@end table

Since 1.8

@end deffn

@deffn Function cairo-toy-font-face-get-slant  (@var{font-face}@tie{}@code{<cairo-font-face-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-font-slant-t>})
Gets the slant a toy font.

@table @var
@item font-face
A toy font face

@item ret
The slant value

@end table

Since 1.8

@end deffn

@deffn Function cairo-toy-font-face-get-weight  (@var{font-face}@tie{}@code{<cairo-font-face-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-font-weight-t>})
Gets the weight a toy font.

@table @var
@item font-face
A toy font face

@item ret
The weight value

@end table

Since 1.8

@end deffn


@c %end of fragment
