<?xml version='1.0' encoding='UTF-8'?> 
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
                "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="cairo-FreeType-Fonts">
<refmeta>
<refentrytitle role="top_of_page">FreeType Fonts</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>CAIRO Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>FreeType Fonts</refname>
<refpurpose>Font support for FreeType</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>



#define             <link linkend="CAIRO-HAS-FT-FONT:CAPS">CAIRO_HAS_FT_FONT</link>
<link linkend="cairo-font-face-t">cairo_font_face_t</link>*  <link linkend="cairo-ft-font-face-create-for-ft-face">cairo_ft_font_face_create_for_ft_face</link>
                                                        (<link linkend="FT-Face">FT_Face</link> face,
                                                         <link linkend="int">int</link> load_flags);
<link linkend="cairo-font-face-t">cairo_font_face_t</link>*  <link linkend="cairo-ft-font-face-create-for-pattern">cairo_ft_font_face_create_for_pattern</link>
                                                        (<link linkend="FcPattern">FcPattern</link> *pattern);
<link linkend="void">void</link>                <link linkend="cairo-ft-font-options-substitute">cairo_ft_font_options_substitute</link>    (const <link linkend="cairo-font-options-t">cairo_font_options_t</link> *options,
                                                         <link linkend="FcPattern">FcPattern</link> *pattern);
<link linkend="FT-Face">FT_Face</link>             <link linkend="cairo-ft-scaled-font-lock-face">cairo_ft_scaled_font_lock_face</link>      (<link linkend="cairo-scaled-font-t">cairo_scaled_font_t</link> *scaled_font);
<link linkend="void">void</link>                <link linkend="cairo-ft-scaled-font-unlock-face">cairo_ft_scaled_font_unlock_face</link>    (<link linkend="cairo-scaled-font-t">cairo_scaled_font_t</link> *scaled_font);
</synopsis>
</refsynopsisdiv>









<refsect1 role="desc">
<title role="desc.title">Description</title>
<para>
The FreeType font backend is primarily used to render text on GNU/Linux
systems, but can be used on other platforms too.
</para>
</refsect1>

<refsect1 role="details">
<title role="details.title">Details</title>
<refsect2>
<title><anchor id="CAIRO-HAS-FT-FONT:CAPS" role="macro"/>CAIRO_HAS_FT_FONT</title>
<indexterm><primary>CAIRO_HAS_FT_FONT</primary></indexterm><programlisting>#define CAIRO_HAS_FT_FONT 1
</programlisting>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="cairo-ft-font-face-create-for-ft-face" role="function"/>cairo_ft_font_face_create_for_ft_face ()</title>
<indexterm><primary>cairo_ft_font_face_create_for_ft_face</primary></indexterm><programlisting><link linkend="cairo-font-face-t">cairo_font_face_t</link>*  cairo_ft_font_face_create_for_ft_face
                                                        (<link linkend="FT-Face">FT_Face</link> face,
                                                         <link linkend="int">int</link> load_flags);</programlisting>
<para>
Creates a new font face for the FreeType font backend from a
pre-opened FreeType face. This font can then be used with
<link linkend="cairo-set-font-face"><function>cairo_set_font_face()</function></link> or <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link>. The
<link linkend="cairo-scaled-font-t"><type>cairo_scaled_font_t</type></link> returned from <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link> is
also for the FreeType backend and can be used with functions such
as <link linkend="cairo-ft-font-lock-face"><function>cairo_ft_font_lock_face()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>face</parameter>&nbsp;:</term>
<listitem><simpara> A FreeType face object, already opened. This must
  be kept around until the face's ref_count 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
  <link linkend="cairo-destroy-func-t"><type>cairo_destroy_func_t</type></link> to <link linkend="cairo-font-face-set-user-data"><function>cairo_font_face_set_user_data()</function></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>load_flags</parameter>&nbsp;:</term>
<listitem><simpara> flags to pass to FT_Load_Glyph when loading
  glyphs from the font. These flags are OR'ed together with
  the flags derived from the <link linkend="cairo-font-options-t"><type>cairo_font_options_t</type></link> passed
  to <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link>, so only a few values such
  as <link linkend="FT-LOAD-VERTICAL-LAYOUT:CAPS"><literal>FT_LOAD_VERTICAL_LAYOUT</literal></link>, and <link linkend="FT-LOAD-FORCE-AUTOHINT:CAPS"><literal>FT_LOAD_FORCE_AUTOHINT</literal></link>
  are useful. You should not pass any of the flags affecting
  the load target, such as <link linkend="FT-LOAD-TARGET-LIGHT:CAPS"><literal>FT_LOAD_TARGET_LIGHT</literal></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a newly created <link linkend="cairo-font-face-t"><type>cairo_font_face_t</type></link>. Free with
 <link linkend="cairo-font-face-destroy"><function>cairo_font_face_destroy()</function></link> when you are done using it.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="cairo-ft-font-face-create-for-pattern" role="function"/>cairo_ft_font_face_create_for_pattern ()</title>
<indexterm><primary>cairo_ft_font_face_create_for_pattern</primary></indexterm><programlisting><link linkend="cairo-font-face-t">cairo_font_face_t</link>*  cairo_ft_font_face_create_for_pattern
                                                        (<link linkend="FcPattern">FcPattern</link> *pattern);</programlisting>
<para>
Creates a new font face for the FreeType font backend based on a
fontconfig pattern. This font can then be used with
<link linkend="cairo-set-font-face"><function>cairo_set_font_face()</function></link> or <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link>. The
<link linkend="cairo-scaled-font-t"><type>cairo_scaled_font_t</type></link> returned from <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link> is
also for the FreeType backend and can be used with functions such
as <link linkend="cairo-ft-font-lock-face"><function>cairo_ft_font_lock_face()</function></link>.
</para>
<para>
Font rendering options are represented both here and when you
call <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link>. Font options that have a representation
in a <link linkend="FcPattern"><type>FcPattern</type></link> must be passed in here; to modify <link linkend="FcPattern"><type>FcPattern</type></link>
appropriately to reflect the options in a <link linkend="cairo-font-options-t"><type>cairo_font_options_t</type></link>, call
<link linkend="cairo-ft-font-options-substitute"><function>cairo_ft_font_options_substitute()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>pattern</parameter>&nbsp;:</term>
<listitem><simpara> A fully resolved fontconfig
  pattern. A pattern can be resolved, by, among other things, calling
  <link linkend="FcConfigSubstitute"><function>FcConfigSubstitute()</function></link>, <link linkend="FcDefaultSubstitute"><function>FcDefaultSubstitute()</function></link>, then
  <link linkend="FcFontMatch"><function>FcFontMatch()</function></link>. Cairo will call <link linkend="FcPatternReference"><function>FcPatternReference()</function></link> on this
  pattern, so you should not further modify the pattern, but you can
  release your reference to the pattern with <link linkend="FcPatternDestroy"><function>FcPatternDestroy()</function></link> if
  you no longer need to access it.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a newly created <link linkend="cairo-font-face-t"><type>cairo_font_face_t</type></link>. Free with
 <link linkend="cairo-font-face-destroy"><function>cairo_font_face_destroy()</function></link> when you are done using it.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="cairo-ft-font-options-substitute" role="function"/>cairo_ft_font_options_substitute ()</title>
<indexterm><primary>cairo_ft_font_options_substitute</primary></indexterm><programlisting><link linkend="void">void</link>                cairo_ft_font_options_substitute    (const <link linkend="cairo-font-options-t">cairo_font_options_t</link> *options,
                                                         <link linkend="FcPattern">FcPattern</link> *pattern);</programlisting>
<para>
Add options to a <link linkend="FcPattern"><type>FcPattern</type></link> based on a <link linkend="cairo-font-options-t"><type>cairo_font_options_t</type></link> font
options object. Options that are already in the pattern, are not overridden,
so you should call this function after calling <link linkend="FcConfigSubstitute"><function>FcConfigSubstitute()</function></link> (the
user's settings should override options based on the surface type), but
before calling <link linkend="FcDefaultSubstitute"><function>FcDefaultSubstitute()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>options</parameter>&nbsp;:</term>
<listitem><simpara> a <link linkend="cairo-font-options-t"><type>cairo_font_options_t</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>pattern</parameter>&nbsp;:</term>
<listitem><simpara> an existing <link linkend="FcPattern"><type>FcPattern</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="cairo-ft-scaled-font-lock-face" role="function"/>cairo_ft_scaled_font_lock_face ()</title>
<indexterm><primary>cairo_ft_scaled_font_lock_face</primary></indexterm><programlisting><link linkend="FT-Face">FT_Face</link>             cairo_ft_scaled_font_lock_face      (<link linkend="cairo-scaled-font-t">cairo_scaled_font_t</link> *scaled_font);</programlisting>
<para>
<link linkend="cairo-ft-font-lock-face"><function>cairo_ft_font_lock_face()</function></link> gets the <link linkend="FT-Face"><type>FT_Face</type></link> object from a FreeType
backend font and scales it appropriately for the font. You must
release the face with <link linkend="cairo-ft-font-unlock-face"><function>cairo_ft_font_unlock_face()</function></link>
when you are done using it.  Since the <link linkend="FT-Face"><type>FT_Face</type></link> object can be
shared between multiple <link linkend="cairo-scaled-font-t"><type>cairo_scaled_font_t</type></link> objects, you must not
lock any other font objects until you unlock this one. A count is
kept of the number of times <link linkend="cairo-ft-font-lock-face"><function>cairo_ft_font_lock_face()</function></link> is
called. <link linkend="cairo-ft-font-unlock-face"><function>cairo_ft_font_unlock_face()</function></link> must be called the same number
of times.
</para>
<para>
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 it's
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).</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>scaled_font</parameter>&nbsp;:</term>
<listitem><simpara> A <link linkend="cairo-scaled-font-t"><type>cairo_scaled_font_t</type></link> from the FreeType font backend. Such an
  object can be created by calling <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link> on a
  FreeType backend font face (see <link linkend="cairo-ft-font-face-create-for-pattern"><function>cairo_ft_font_face_create_for_pattern()</function></link>,
  <link linkend="cairo-ft-font-face-create-for-face"><function>cairo_ft_font_face_create_for_face()</function></link>).
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> The <link linkend="FT-Face"><type>FT_Face</type></link> object for <parameter>font</parameter>, scaled appropriately,
or <link linkend="NULL:CAPS"><literal>NULL</literal></link> if <parameter>scaled_font</parameter> is in an error state (see
<link linkend="cairo-scaled-font-status"><function>cairo_scaled_font_status()</function></link>) or there is insufficient memory.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="cairo-ft-scaled-font-unlock-face" role="function"/>cairo_ft_scaled_font_unlock_face ()</title>
<indexterm><primary>cairo_ft_scaled_font_unlock_face</primary></indexterm><programlisting><link linkend="void">void</link>                cairo_ft_scaled_font_unlock_face    (<link linkend="cairo-scaled-font-t">cairo_scaled_font_t</link> *scaled_font);</programlisting>
<para>
Releases a face obtained with <link linkend="cairo-ft-scaled-font-lock-face"><function>cairo_ft_scaled_font_lock_face()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>scaled_font</parameter>&nbsp;:</term>
<listitem><simpara> A <link linkend="cairo-scaled-font-t"><type>cairo_scaled_font_t</type></link> from the FreeType font backend. Such an
  object can be created by calling <link linkend="cairo-scaled-font-create"><function>cairo_scaled_font_create()</function></link> on a
  FreeType backend font face (see <link linkend="cairo-ft-font-face-create-for-pattern"><function>cairo_ft_font_face_create_for_pattern()</function></link>,
  <link linkend="cairo-ft-font-face-create-for-ft-face"><function>cairo_ft_font_face_create_for_ft_face()</function></link>).
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>



<refsect1>
<title>See Also</title>
<para>
<itemizedlist>
<listitem><link linkend="cairo-font-face-t"><type>cairo_font_face_t</type></link></listitem>
</itemizedlist>
</para>
</refsect1>


<refsect1><refsect2 /><refsect2 /></refsect1>
</refentry>
