Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>cairomm: Cairo::UserFontFace Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">cairomm
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceCairo.html">Cairo</a></li><li class="navelem"><a class="el" href="classCairo_1_1UserFontFace.html">UserFontFace</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classCairo_1_1UserFontFace-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Cairo::UserFontFace Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div>  </div>
</div><!--header-->
<div class="contents">

<p>Font support with font data provided by the user.  
 <a href="classCairo_1_1UserFontFace.html#details">More...</a></p>
<div class="dynheader">
Inheritance diagram for Cairo::UserFontFace:</div>
<div class="dyncontent">
<div class="center"><img src="classCairo_1_1UserFontFace__inherit__graph.png" border="0" usemap="#Cairo_1_1UserFontFace_inherit__map" alt="Inheritance graph"/></div>
<map name="Cairo_1_1UserFontFace_inherit__map" id="Cairo_1_1UserFontFace_inherit__map">
<area shape="rect" id="node2" href="classCairo_1_1FontFace.html" title="A FontFace represents a particular font at a particular weight, slant, and other characteristic but n..." alt="" coords="21,5,141,32"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ae62d6b0a239f47fd67bda4b182187d62"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#ae62d6b0a239f47fd67bda4b182187d62">~UserFontFace</a> ()</td></tr>
<tr class="separator:ae62d6b0a239f47fd67bda4b182187d62"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classCairo_1_1FontFace"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classCairo_1_1FontFace')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classCairo_1_1FontFace.html">Cairo::FontFace</a></td></tr>
<tr class="memitem:af464d8f051930da555fcbf632add755d inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#af464d8f051930da555fcbf632add755d">FontFace</a> (cairo_font_face_t*<a class="el" href="classCairo_1_1FontFace.html#ab1631f7eb6458a98be291880a1dde3d7">cobject</a>, bool has_reference=false)</td></tr>
<tr class="memdesc:af464d8f051930da555fcbf632add755d inherit pub_methods_classCairo_1_1FontFace"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a C++ wrapper for the C instance.  <a href="#af464d8f051930da555fcbf632add755d">More...</a><br /></td></tr>
<tr class="separator:af464d8f051930da555fcbf632add755d inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae2d3222529600fbb66ce780f9a300ce1 inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#ae2d3222529600fbb66ce780f9a300ce1">FontFace</a> (const <a class="el" href="classCairo_1_1FontFace.html">FontFace</a>&amp;)=delete</td></tr>
<tr class="separator:ae2d3222529600fbb66ce780f9a300ce1 inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a09ce1c80879ef520c884c9d23982691d inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCairo_1_1FontFace.html">FontFace</a>&amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#a09ce1c80879ef520c884c9d23982691d">operator=</a> (const <a class="el" href="classCairo_1_1FontFace.html">FontFace</a>&amp;)=delete</td></tr>
<tr class="separator:a09ce1c80879ef520c884c9d23982691d inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa5d84dba43cd09c1710b458132a9ab8d inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#aa5d84dba43cd09c1710b458132a9ab8d">~FontFace</a> ()</td></tr>
<tr class="separator:aa5d84dba43cd09c1710b458132a9ab8d inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a201bec9a38120a2f77b56c2e61c0a481 inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceCairo.html#a23e1a9a5be49d16cf3871e841e8ab522">FontType</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#a201bec9a38120a2f77b56c2e61c0a481">get_type</a> () const </td></tr>
<tr class="memdesc:a201bec9a38120a2f77b56c2e61c0a481 inherit pub_methods_classCairo_1_1FontFace"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the type of the backend used to create a font face.  <a href="#a201bec9a38120a2f77b56c2e61c0a481">More...</a><br /></td></tr>
<tr class="separator:a201bec9a38120a2f77b56c2e61c0a481 inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac8b43511916adc955411051e3a29b53a inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCairo_1_1FontFace.html#ab1631f7eb6458a98be291880a1dde3d7">cobject</a>*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#ac8b43511916adc955411051e3a29b53a">cobj</a> ()</td></tr>
<tr class="separator:ac8b43511916adc955411051e3a29b53a inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf59eb8a1bd2a51e4d9c850279ae6bd6 inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">const <a class="el" href="classCairo_1_1FontFace.html#ab1631f7eb6458a98be291880a1dde3d7">cobject</a>*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#aaf59eb8a1bd2a51e4d9c850279ae6bd6">cobj</a> () const </td></tr>
<tr class="separator:aaf59eb8a1bd2a51e4d9c850279ae6bd6 inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a33876cc188930bf2ecbcd43c8604267b inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#a33876cc188930bf2ecbcd43c8604267b">reference</a> () const </td></tr>
<tr class="separator:a33876cc188930bf2ecbcd43c8604267b inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a603f1045e7fed08f9e3001be69c2bb56 inherit pub_methods_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#a603f1045e7fed08f9e3001be69c2bb56">unreference</a> () const </td></tr>
<tr class="separator:a603f1045e7fed08f9e3001be69c2bb56 inherit pub_methods_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:af3f1d3a53a7be1d84a20609984473e07"><td class="memItemLeft" align="right" valign="top">virtual ErrorStatus&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#af3f1d3a53a7be1d84a20609984473e07">init</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp; scaled_font, const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1Context.html">Context</a> &gt;&amp; cr, <a class="el" href="namespaceCairo.html#aa7da46c699a67bfbdd5400af7e6b7b39">FontExtents</a>&amp; extents)</td></tr>
<tr class="memdesc:af3f1d3a53a7be1d84a20609984473e07"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is called when a scaled-font needs to be created for a user font-face.  <a href="#af3f1d3a53a7be1d84a20609984473e07">More...</a><br /></td></tr>
<tr class="separator:af3f1d3a53a7be1d84a20609984473e07"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a43cd65b62eab686477d3773e6fd98b46"><td class="memItemLeft" align="right" valign="top">virtual ErrorStatus&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#a43cd65b62eab686477d3773e6fd98b46">unicode_to_glyph</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp; scaled_font, unsigned long unicode, unsigned long&amp; glyph)</td></tr>
<tr class="memdesc:a43cd65b62eab686477d3773e6fd98b46"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is called to convert an input Unicode character to a single glyph.  <a href="#a43cd65b62eab686477d3773e6fd98b46">More...</a><br /></td></tr>
<tr class="separator:a43cd65b62eab686477d3773e6fd98b46"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2e53435e92f9975213bd19969cb69375"><td class="memItemLeft" align="right" valign="top">virtual ErrorStatus&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#a2e53435e92f9975213bd19969cb69375">render_glyph</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp; scaled_font, unsigned long glyph, const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1Context.html">Context</a> &gt;&amp; cr, <a class="el" href="namespaceCairo.html#af6d8a4744616383984c99f8f052c7a5d">TextExtents</a>&amp; metrics)=0</td></tr>
<tr class="memdesc:a2e53435e92f9975213bd19969cb69375"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is called when a user scaled-font needs to render a glyph.  <a href="#a2e53435e92f9975213bd19969cb69375">More...</a><br /></td></tr>
<tr class="separator:a2e53435e92f9975213bd19969cb69375"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a467db4c4a08c8cced992045d791e65f2"><td class="memItemLeft" align="right" valign="top">virtual ErrorStatus&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#a467db4c4a08c8cced992045d791e65f2">text_to_glyphs</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp; scaled_font, const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01681.html#ga32db3d9898c44d3b3a578b560f7758cc">std::string</a>&amp; utf8, <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00965.html">std::vector</a>&lt; <a class="el" href="namespaceCairo.html#a2483f165322e844c095c7be95849fdc2">Glyph</a> &gt;&amp; glyphs, <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00965.html">std::vector</a>&lt; <a class="el" href="namespaceCairo.html#a3c23510889078c8a75d66add004ab288">TextCluster</a> &gt;&amp; clusters, <a class="el" href="namespaceCairo.html#a61b770cf36c555a4098b5428e030542a">TextClusterFlags</a>&amp; cluster_flags)</td></tr>
<tr class="memdesc:a467db4c4a08c8cced992045d791e65f2"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is called to convert input text to an array of glyphs.  <a href="#a467db4c4a08c8cced992045d791e65f2">More...</a><br /></td></tr>
<tr class="separator:a467db4c4a08c8cced992045d791e65f2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa63810b6ea9db5b62986e6ce9b7fa13a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#aa63810b6ea9db5b62986e6ce9b7fa13a">UserFontFace</a> ()</td></tr>
<tr class="separator:aa63810b6ea9db5b62986e6ce9b7fa13a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pub_types_classCairo_1_1FontFace"><td colspan="2" onclick="javascript:toggleInherit('pub_types_classCairo_1_1FontFace')"><img src="closed.png" alt="-"/>&#160;Public Types inherited from <a class="el" href="classCairo_1_1FontFace.html">Cairo::FontFace</a></td></tr>
<tr class="memitem:ab1631f7eb6458a98be291880a1dde3d7 inherit pub_types_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top">typedef cairo_font_face_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#ab1631f7eb6458a98be291880a1dde3d7">cobject</a></td></tr>
<tr class="separator:ab1631f7eb6458a98be291880a1dde3d7 inherit pub_types_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pro_attribs_classCairo_1_1FontFace"><td colspan="2" onclick="javascript:toggleInherit('pro_attribs_classCairo_1_1FontFace')"><img src="closed.png" alt="-"/>&#160;Protected Attributes inherited from <a class="el" href="classCairo_1_1FontFace.html">Cairo::FontFace</a></td></tr>
<tr class="memitem:ae2d03f09adca1b8f9008680f0e831b0c inherit pro_attribs_classCairo_1_1FontFace"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classCairo_1_1FontFace.html#ab1631f7eb6458a98be291880a1dde3d7">cobject</a>*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1FontFace.html#ae2d03f09adca1b8f9008680f0e831b0c">m_cobject</a></td></tr>
<tr class="separator:ae2d03f09adca1b8f9008680f0e831b0c inherit pro_attribs_classCairo_1_1FontFace"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Font support with font data provided by the user. </p>
<p>The user-font feature allows the cairo user to provide drawings for glyphs in a font. This is most useful in implementing fonts in non-standard formats, like SVG fonts and Flash fonts, but can also be used by games and other application to draw "funky" fonts.</p>
<p>To use user fonts, you must derive from this class and implement the virtual functions below. The only virtual function that absolutely must be implemented is <a class="el" href="classCairo_1_1UserFontFace.html#a2e53435e92f9975213bd19969cb69375" title="This function is called when a user scaled-font needs to render a glyph. ">render_glyph()</a>. You should make the constructor protected and provide a factory function that returns a new object in a <a class="el" href="classCairo_1_1RefPtr.html" title="RefPtr<> is a reference-counting shared smartpointer. ">RefPtr</a> since it is a refcounted object</p>
<div class="fragment"><div class="line"><span class="keyword">class </span>MyUserFont : <span class="keyword">public</span> <a class="code" href="classCairo_1_1UserFontFace.html#aa63810b6ea9db5b62986e6ce9b7fa13a">UserFontFace</a> {</div>
<div class="line"></div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line">  <span class="keyword">static</span> <a class="code" href="classCairo_1_1RefPtr.html">Cairo::RefPtr&lt;MyUserFont&gt;</a> create() {</div>
<div class="line">    <span class="keywordflow">return</span> <a class="code" href="classCairo_1_1RefPtr.html">Cairo::RefPtr&lt;MyUserFont&gt;</a>(<span class="keyword">new</span> MyUserFont);</div>
<div class="line"></div>
<div class="line"><span class="keyword">protected</span>:</div>
<div class="line">  <span class="comment">// implement render_glyph() and any other virtual functions you want to override</span></div>
<div class="line">  ErrorStatus <a class="code" href="classCairo_1_1UserFontFace.html#a2e53435e92f9975213bd19969cb69375">render_glyph</a>(<span class="keyword">const</span> RefPtr&lt;ScaledFont&gt;&amp; scaled_font,</div>
<div class="line">                           <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> glyph,</div>
<div class="line">                           <span class="keyword">const</span> RefPtr&lt;Context&gt;&amp; cr,</div>
<div class="line">                           <a class="code" href="namespaceCairo.html#af6d8a4744616383984c99f8f052c7a5d">TextExtents</a>&amp; metrics) {</div>
<div class="line">    <span class="comment">// render the glyph into cr here</span></div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  MyUserFont() : <a class="code" href="classCairo_1_1UserFontFace.html#aa63810b6ea9db5b62986e6ce9b7fa13a">UserFontFace</a>() {</div>
<div class="line">    <span class="comment">// constructor implementation</span></div>
<div class="line">  }</div>
<div class="line">};</div>
</div><!-- fragment --><dl class="section warning"><dt>Warning</dt><dd>Because of a design flaw in cairomm, it is currently necessary to keep the the <a class="el" href="classCairo_1_1UserFontFace.html" title="Font support with font data provided by the user. ">UserFontFace</a> object around until as long as you are rendering text with the user font. The following code illustrates the issue:</dd></dl>
<div class="fragment"><div class="line">{</div>
<div class="line">  <span class="keyword">auto</span> face = MyUserFont::create();</div>
<div class="line">  cr-&gt;<a class="code" href="classCairo_1_1Context.html#a9b344db51097aba30e36452e1364faef">set_font_face</a>(face);</div>
<div class="line">}  <span class="comment">// scope for demonstration purposes</span></div>
<div class="line"></div>
<div class="line"><span class="comment">// the following call will cause a crash because your user font is no longer</span></div>
<div class="line"><span class="comment">// in scope but it needs to call the virtual functions in face</span></div>
<div class="line">cr-&gt;<a class="code" href="classCairo_1_1Context.html#a584596d6f12dbea30519b908cacce038">show_text</a>(<span class="stringliteral">&quot;hello, world&quot;</span>);</div>
</div><!-- fragment --><p>The preceding is obviously a very contrived example, but the important thing to know is that you <em>must</em> cache all userfont objects yourself as long as you intend to render text with that font. A future release of cairomm will fix this requirement, but that will require ABI-incompatible changes.</p>
<dl class="section since"><dt>Since</dt><dd>1.8 </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="user-font_8cc-example.html#_a0">user-font.cc</a>.</dd>
</dl></div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="ae62d6b0a239f47fd67bda4b182187d62"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual Cairo::UserFontFace::~UserFontFace </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="aa63810b6ea9db5b62986e6ce9b7fa13a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Cairo::UserFontFace::UserFontFace </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="af3f1d3a53a7be1d84a20609984473e07"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual ErrorStatus Cairo::UserFontFace::init </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>scaled_font</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1Context.html">Context</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>cr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceCairo.html#aa7da46c699a67bfbdd5400af7e6b7b39">FontExtents</a>&amp;&#160;</td>
          <td class="paramname"><em>extents</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This function is called when a scaled-font needs to be created for a user font-face. </p>
<p>The <a class="el" href="classCairo_1_1Context.html" title="Context is the main class used to draw in cairomm. ">Context</a> <em>cr</em> is not used by the caller, but is prepared in font space, similar to what the cairo contexts passed to the render_glyph method will look like. The callback can use this context for extents computation for example. After the callback is called, <em>cr</em> is checked for any error status.</p>
<p>The <em>extents</em> argument is where the user font sets the font extents for scaled_font. It is in font space, which means that for most cases its ascent and descent members should add to 1.0. <em>extents</em> is preset to hold a value of 1.0 for ascent, height, and max_x_advance, and 0.0 for descent and max_y_advance members.</p>
<p>The default implementation sets the font extents as described in the previous paragraph. If you need different extents, you can override this function in your derived class.</p>
<p>Note that <em>scaled_font</em> is not fully initialized at this point and trying to use it for text operations in the callback will result in deadlock.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">scaled_font</td><td>the scaled-font being created </td></tr>
    <tr><td class="paramname">cr</td><td>cairo context, in font space </td></tr>
    <tr><td class="paramname">extents</td><td>extents to fill in, in font space </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.</dd></dl>
<dl class="section since"><dt>Since</dt><dd>1.8 </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="user-font_8cc-example.html#a2">user-font.cc</a>.</dd>
</dl>
</div>
</div>
<a class="anchor" id="a2e53435e92f9975213bd19969cb69375"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual ErrorStatus Cairo::UserFontFace::render_glyph </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>scaled_font</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long&#160;</td>
          <td class="paramname"><em>glyph</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1Context.html">Context</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>cr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceCairo.html#af6d8a4744616383984c99f8f052c7a5d">TextExtents</a>&amp;&#160;</td>
          <td class="paramname"><em>metrics</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">pure virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This function is called when a user scaled-font needs to render a glyph. </p>
<p>You must implement this in your derived class, and it is expected to draw the glyph with code <em>glyph</em> to the <a class="el" href="classCairo_1_1Context.html" title="Context is the main class used to draw in cairomm. ">Context</a> <em>cr</em>. <em>cr</em> is prepared such that the glyph drawing is done in font space. That is, the matrix set on <em>cr</em> is the scale matrix of <em>scaled_font</em>, The <em>extents</em> argument is where the user font sets the font extents for scaled_font. However, if user prefers to draw in user space, they can achieve that by changing the matrix on <em>cr</em>. All cairo rendering operations to <em>cr</em> are permitted, however, the result is undefined if any source other than the default source on <em>cr</em> is used. That means, glyph bitmaps should be rendered using <a class="el" href="classCairo_1_1Context.html#a2ad3ea59afb6bb4fa04d000f5e9c3cf2" title="A drawing operator that paints the current source using the alpha channel of pattern as a mask...">Context::mask()</a> instead of <a class="el" href="classCairo_1_1Context.html#ad919eae3bc3b9827a3c1ceff2d86833e" title="A drawing operator that paints the current source everywhere within the current clip region...">Context::paint()</a>.</p>
<p>Other non-default settings on <em>cr</em> include a font size of 1.0 (given that it is set up to be in font space), and font options corresponding to <em>scaled_font</em>.</p>
<p>The <em>extents</em> argument is preset to have x_bearing, width, and y_advance of zero, y_bearing set to -font_extents.ascent, height to font_extents.ascent+font_extents.descent, and x_advance to font_extents.max_x_advance. The only field user needs to set in majority of cases is x_advance. If the width field is zero upon this function returning (which is its preset value), the glyph extents are automatically computed based on the drawings done to <em>cr</em>. This is in most cases exactly what the desired behavior is. However, if for any reason this function sets the extents, it must be ink extents, and include the extents of all drawing done to <em>cr</em>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">scaled_font</td><td>user scaled-font </td></tr>
    <tr><td class="paramname">glyph</td><td>glyph code to render </td></tr>
    <tr><td class="paramname">cr</td><td><a class="el" href="classCairo_1_1Context.html" title="Context is the main class used to draw in cairomm. ">Context</a> to draw to, in font space </td></tr>
    <tr><td class="paramname">extents</td><td>glyph extents to fill in, in font space </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.</dd></dl>
<dl class="section since"><dt>Since</dt><dd>1.8 </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="user-font_8cc-example.html#a5">user-font.cc</a>.</dd>
</dl>
</div>
</div>
<a class="anchor" id="a467db4c4a08c8cced992045d791e65f2"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual ErrorStatus Cairo::UserFontFace::text_to_glyphs </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>scaled_font</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01681.html#ga32db3d9898c44d3b3a578b560f7758cc">std::string</a> &amp;&#160;</td>
          <td class="paramname"><em>utf8</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00965.html">std::vector</a>&lt; <a class="el" href="namespaceCairo.html#a2483f165322e844c095c7be95849fdc2">Glyph</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>glyphs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00965.html">std::vector</a>&lt; <a class="el" href="namespaceCairo.html#a3c23510889078c8a75d66add004ab288">TextCluster</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>clusters</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceCairo.html#a61b770cf36c555a4098b5428e030542a">TextClusterFlags</a>&amp;&#160;</td>
          <td class="paramname"><em>cluster_flags</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This function is called to convert input text to an array of glyphs. </p>
<p>This is used by the <a class="el" href="classCairo_1_1Context.html#a584596d6f12dbea30519b908cacce038" title="A drawing operator that generates the shape from a string of UTF-8 characters, rendered according to ...">Context::show_text()</a> operation.</p>
<p>Using this function, the user-font has full control on glyphs and their positions. That means, it allows for features like ligatures and kerning, as well as complex shaping required for scripts like Arabic and Indic.</p>
<p>This function should populate the glyph indices and positions (in font space) assuming that the text is to be shown at the origin.</p>
<p>If clusters is not empty, cluster mapping should be computed.</p>
<p>If you do not override this virtual function in your derived class, the unicode_to_glyph function is used instead.</p>
<p>Note: While cairo does not impose any limitation on glyph indices, some applications may assume that a glyph index fits in a 16-bit unsigned integer. As such, it is advised that user-fonts keep their glyphs in the 0 to 65535 range. Furthermore, some applications may assume that glyph 0 is a special glyph-not-found glyph. User-fonts are advised to use glyph 0 for such purposes and do not use that glyph value for other purposes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">scaled_font</td><td>the scaled-font being created </td></tr>
    <tr><td class="paramname">utf8</td><td>a string of text encoded in UTF-8 </td></tr>
    <tr><td class="paramname">glyphs</td><td>array of glyphs to fill, in font space </td></tr>
    <tr><td class="paramname">clusters</td><td>array of cluster mapping information to fill </td></tr>
    <tr><td class="paramname">cluster_flags</td><td>a variable to set the cluster flags corresponding to the output clusters </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error. </dd></dl>
<dl class="section since"><dt>Since</dt><dd>1.8 </dd></dl>

</div>
</div>
<a class="anchor" id="a43cd65b62eab686477d3773e6fd98b46"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual ErrorStatus Cairo::UserFontFace::unicode_to_glyph </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>&lt; <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> &gt;&amp;&#160;</td>
          <td class="paramname"><em>scaled_font</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long&#160;</td>
          <td class="paramname"><em>unicode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long &amp;&#160;</td>
          <td class="paramname"><em>glyph</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>This function is called to convert an input Unicode character to a single glyph. </p>
<p>This is used by the <a class="el" href="classCairo_1_1Context.html#a584596d6f12dbea30519b908cacce038" title="A drawing operator that generates the shape from a string of UTF-8 characters, rendered according to ...">Context::show_text()</a> operation.</p>
<p>This function is used to provide the same functionality as the text_to_glyphs callback does but has much less control on the output, in exchange for increased ease of use. The inherent assumption to using this callback is that each character maps to one glyph, and that the mapping is context independent. It also assumes that glyphs are positioned according to their advance width. These mean no ligatures, kerning, or complex scripts can be implemented using this callback.</p>
<p>The default implementation of this function is an identity mapping from Unicode code-points to glyph indices. If you need different behavior, you may override this virtual function in your derived class.</p>
<p>Note: While cairo does not impose any limitation on glyph indices, some applications may assume that a glyph index fits in a 16-bit unsigned integer. As such, it is advised that user-fonts keep their glyphs in the 0 to 65535 range. Furthermore, some applications may assume that glyph 0 is a special glyph-not-found glyph. User-fonts are advised to use glyph 0 for such purposes and do not use that glyph value for other purposes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">scaled_font</td><td>the scaled-font being created </td></tr>
    <tr><td class="paramname">unicode</td><td>input unicode character code-point </td></tr>
    <tr><td class="paramname">glyph_index</td><td>output glyph index </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error. </dd></dl>
<dl class="section since"><dt>Since</dt><dd>1.8 </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="user-font_8cc-example.html#a4">user-font.cc</a>.</dd>
</dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>cairomm/fontface.h</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Sep 21 2015 21:56:36 for cairomm by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>