1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>cairomm: Cairo::UserFontFace Class Reference</title>
<link href="cairomm.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related 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 class="tabs">
<ul>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<div class="navpath"><a class="el" href="namespaceCairo.html">Cairo</a>::<a class="el" href="classCairo_1_1UserFontFace.html">UserFontFace</a>
</div>
</div>
<div class="contents">
<h1>Cairo::UserFontFace Class Reference</h1><!-- doxytag: class="Cairo::UserFontFace" --><!-- doxytag: inherits="Cairo::FontFace" -->Font support with font data provided by the user.
<a href="#_details">More...</a>
<p>
Inherits <a class="el" href="classCairo_1_1FontFace.html">Cairo::FontFace</a>.
<p>
<p>
<a href="classCairo_1_1UserFontFace-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#e62d6b0a239f47fd67bda4b182187d62">~UserFontFace</a> ()</td></tr>
<tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual ErrorStatus </td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#f3f1d3a53a7be1d84a20609984473e07">init</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& scaled_font, const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>< <a class="el" href="classCairo_1_1Context.html">Context</a> >& cr, <a class="el" href="namespaceCairo.html#a7da46c699a67bfbdd5400af7e6b7b39">FontExtents</a>& extents)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This function is called when a scaled-font needs to be created for a user font-face. <a href="#f3f1d3a53a7be1d84a20609984473e07"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual ErrorStatus </td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#43cd65b62eab686477d3773e6fd98b46">unicode_to_glyph</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& scaled_font, unsigned long unicode, unsigned long& glyph)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This function is called to convert an input Unicode character to a single glyph. <a href="#43cd65b62eab686477d3773e6fd98b46"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual ErrorStatus </td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#2e53435e92f9975213bd19969cb69375">render_glyph</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& scaled_font, unsigned long glyph, const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>< <a class="el" href="classCairo_1_1Context.html">Context</a> >& cr, <a class="el" href="namespaceCairo.html#f6d8a4744616383984c99f8f052c7a5d">TextExtents</a>& metrics)=0</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This function is called when a user scaled-font needs to render a glyph. <a href="#2e53435e92f9975213bd19969cb69375"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual ErrorStatus </td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#467db4c4a08c8cced992045d791e65f2">text_to_glyphs</a> (const <a class="el" href="classCairo_1_1RefPtr.html">RefPtr</a>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& 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/a00218.html">std::string</a>& utf8, <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00599.html">std::vector</a>< <a class="el" href="namespaceCairo.html#2483f165322e844c095c7be95849fdc2">Glyph</a> >& glyphs, <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00599.html">std::vector</a>< <a class="el" href="namespaceCairo.html#3c23510889078c8a75d66add004ab288">TextCluster</a> >& clusters, <a class="el" href="namespaceCairo.html#61b770cf36c555a4098b5428e030542a">TextClusterFlags</a>& cluster_flags)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This function is called to convert input text to an array of glyphs. <a href="#467db4c4a08c8cced992045d791e65f2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classCairo_1_1UserFontFace.html#a63810b6ea9db5b62986e6ce9b7fa13a">UserFontFace</a> ()</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Font support with font data provided by the user.
<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>
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#2e53435e92f9975213bd19969cb69375" 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"><pre class="fragment"> <span class="keyword">class </span>MyUserFont : <span class="keyword">public</span> <a class="code" href="classCairo_1_1UserFontFace.html#a63810b6ea9db5b62986e6ce9b7fa13a">UserFontFace</a> {
<span class="keyword">public</span>:
<span class="keyword">static</span> <a class="code" href="classCairo_1_1RefPtr.html" title="RefPtr&lt;&gt; is a reference-counting shared smartpointer.">Cairo::RefPtr<MyUserFont></a> create() {
<span class="keywordflow">return</span> <a class="code" href="classCairo_1_1RefPtr.html" title="RefPtr&lt;&gt; is a reference-counting shared smartpointer.">Cairo::RefPtr<MyUserFont></a>(<span class="keyword">new</span> MyUserFont);
<span class="keyword">protected</span>:
<span class="comment">// implement render_glyph() and any other virtual functions you want to override</span>
ErrorStatus <a class="code" href="classCairo_1_1UserFontFace.html#2e53435e92f9975213bd19969cb69375" title="This function is called when a user scaled-font needs to render a glyph.">render_glyph</a>(<span class="keyword">const</span> RefPtr<ScaledFont>& scaled_font,
<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> glyph,
<span class="keyword">const</span> RefPtr<Context>& cr,
<a class="code" href="namespaceCairo.html#f6d8a4744616383984c99f8f052c7a5d" title="See the cairo_text_extents_t reference in the cairo manual for more information.">TextExtents</a>& metrics) {
<span class="comment">// render the glyph into cr here</span>
}
MyUserFont() : <a class="code" href="classCairo_1_1UserFontFace.html#a63810b6ea9db5b62986e6ce9b7fa13a">UserFontFace</a>() {
<span class="comment">// constructor implementation</span>
}
};
</pre></div><p>
<dl class="warning" compact><dt><b>Warning:</b></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"><pre class="fragment"> {
<a class="code" href="classCairo_1_1RefPtr.html" title="RefPtr&lt;&gt; is a reference-counting shared smartpointer.">Cairo::RefPtr<MyUserFont></a> face = MyUserFont::create();
cr->set_font_face(face);
} <span class="comment">// scope for demonstration purposes</span>
<span class="comment">// the following call will cause a crash because your user font is no longer</span>
<span class="comment">// in scope but it needs to call the virtual functions in face</span>
cr->show_text(<span class="stringliteral">"hello, world"</span>);
</pre></div><p>
The preceding is obviously a very contrived example, but the important thing to know is that you *must* 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="since" compact><dt><b>Since:</b></dt><dd>1.8 </dd></dl>
<hr><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" name="e62d6b0a239f47fd67bda4b182187d62"></a><!-- doxytag: member="Cairo::UserFontFace::~UserFontFace" ref="e62d6b0a239f47fd67bda4b182187d62" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">virtual Cairo::UserFontFace::~UserFontFace </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
</div>
</div><p>
<a class="anchor" name="a63810b6ea9db5b62986e6ce9b7fa13a"></a><!-- doxytag: member="Cairo::UserFontFace::UserFontFace" ref="a63810b6ea9db5b62986e6ce9b7fa13a" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Cairo::UserFontFace::UserFontFace </td>
<td>(</td>
<td class="paramname"> </td>
<td> ) </td>
<td><code> [protected]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
</div>
</div><p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="f3f1d3a53a7be1d84a20609984473e07"></a><!-- doxytag: member="Cairo::UserFontFace::init" ref="f3f1d3a53a7be1d84a20609984473e07" args="(const RefPtr< ScaledFont > &scaled_font, const RefPtr< Context > &cr, FontExtents &extents)" -->
<div class="memitem">
<div class="memproto">
<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>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& </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>< <a class="el" href="classCairo_1_1Context.html">Context</a> >& </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#a7da46c699a67bfbdd5400af7e6b7b39">FontExtents</a>& </td>
<td class="paramname"> <em>extents</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [protected, virtual]</code></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>
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>
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>
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>
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 compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>scaled_font</em> </td><td>the scaled-font being created </td></tr>
<tr><td valign="top"></td><td valign="top"><em>cr</em> </td><td>cairo context, in font space </td></tr>
<tr><td valign="top"></td><td valign="top"><em>extents</em> </td><td>extents to fill in, in font space </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.</dd></dl>
<dl class="since" compact><dt><b>Since:</b></dt><dd>1.8 </dd></dl>
</div>
</div><p>
<a class="anchor" name="2e53435e92f9975213bd19969cb69375"></a><!-- doxytag: member="Cairo::UserFontFace::render_glyph" ref="2e53435e92f9975213bd19969cb69375" args="(const RefPtr< ScaledFont > &scaled_font, unsigned long glyph, const RefPtr< Context > &cr, TextExtents &metrics)=0" -->
<div class="memitem">
<div class="memproto">
<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>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& </td>
<td class="paramname"> <em>scaled_font</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned long </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>< <a class="el" href="classCairo_1_1Context.html">Context</a> >& </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#f6d8a4744616383984c99f8f052c7a5d">TextExtents</a>& </td>
<td class="paramname"> <em>metrics</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [protected, pure virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This function is called when a user scaled-font needs to render a glyph.
<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#2ad3ea59afb6bb4fa04d000f5e9c3cf2" title="A drawing operator that paints the current source using the alpha channel of pattern...">Context::mask()</a> instead of <a class="el" href="classCairo_1_1Context.html#d919eae3bc3b9827a3c1ceff2d86833e" title="A drawing operator that paints the current source everywhere within the current clip...">Context::paint()</a>.<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>
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 compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>scaled_font</em> </td><td>user scaled-font </td></tr>
<tr><td valign="top"></td><td valign="top"><em>glyph</em> </td><td>glyph code to render </td></tr>
<tr><td valign="top"></td><td valign="top"><em>cr</em> </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 valign="top"></td><td valign="top"><em>extents</em> </td><td>glyph extents to fill in, in font space </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error.</dd></dl>
<dl class="since" compact><dt><b>Since:</b></dt><dd>1.8 </dd></dl>
</div>
</div><p>
<a class="anchor" name="467db4c4a08c8cced992045d791e65f2"></a><!-- doxytag: member="Cairo::UserFontFace::text_to_glyphs" ref="467db4c4a08c8cced992045d791e65f2" args="(const RefPtr< ScaledFont > &scaled_font, const std::string &utf8, std::vector< Glyph > &glyphs, std::vector< TextCluster > &clusters, TextClusterFlags &cluster_flags)" -->
<div class="memitem">
<div class="memproto">
<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>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& </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/a00218.html">std::string</a> & </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/a00599.html">std::vector</a>< <a class="el" href="namespaceCairo.html#2483f165322e844c095c7be95849fdc2">Glyph</a> >& </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/a00599.html">std::vector</a>< <a class="el" href="namespaceCairo.html#3c23510889078c8a75d66add004ab288">TextCluster</a> >& </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#61b770cf36c555a4098b5428e030542a">TextClusterFlags</a>& </td>
<td class="paramname"> <em>cluster_flags</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [protected, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This function is called to convert input text to an array of glyphs.
<p>
This is used by the <a class="el" href="classCairo_1_1Context.html#584596d6f12dbea30519b908cacce038">Context::show_text()</a> operation.<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>
This function should populate the glyph indices and positions (in font space) assuming that the text is to be shown at the origin.<p>
If clusters is not empty, cluster mapping should be computed.<p>
If you do not override this virtual function in your derived class, the unicode_to_glyph function is used instead.<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 compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>scaled_font</em> </td><td>the scaled-font being created </td></tr>
<tr><td valign="top"></td><td valign="top"><em>utf8</em> </td><td>a string of text encoded in UTF-8 </td></tr>
<tr><td valign="top"></td><td valign="top"><em>glyphs</em> </td><td>array of glyphs to fill, in font space </td></tr>
<tr><td valign="top"></td><td valign="top"><em>clusters</em> </td><td>array of cluster mapping information to fill </td></tr>
<tr><td valign="top"></td><td valign="top"><em>cluster_flags</em> </td><td>a variable to set the cluster flags corresponding to the output clusters </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error. </dd></dl>
<dl class="since" compact><dt><b>Since:</b></dt><dd>1.8 </dd></dl>
</div>
</div><p>
<a class="anchor" name="43cd65b62eab686477d3773e6fd98b46"></a><!-- doxytag: member="Cairo::UserFontFace::unicode_to_glyph" ref="43cd65b62eab686477d3773e6fd98b46" args="(const RefPtr< ScaledFont > &scaled_font, unsigned long unicode, unsigned long &glyph)" -->
<div class="memitem">
<div class="memproto">
<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>< <a class="el" href="classCairo_1_1ScaledFont.html">ScaledFont</a> >& </td>
<td class="paramname"> <em>scaled_font</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned long </td>
<td class="paramname"> <em>unicode</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned long & </td>
<td class="paramname"> <em>glyph</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [protected, virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This function is called to convert an input Unicode character to a single glyph.
<p>
This is used by the <a class="el" href="classCairo_1_1Context.html#584596d6f12dbea30519b908cacce038">Context::show_text()</a> operation.<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>
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>
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 compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>scaled_font</em> </td><td>the scaled-font being created </td></tr>
<tr><td valign="top"></td><td valign="top"><em>unicode</em> </td><td>input unicode character code-point </td></tr>
<tr><td valign="top"></td><td valign="top"><em>glyph_index</em> </td><td>output glyph index </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>CAIRO_STATUS_SUCCESS upon success, or CAIRO_STATUS_USER_FONT_ERROR or any other error status on error. </dd></dl>
<dl class="since" compact><dt><b>Since:</b></dt><dd>1.8 </dd></dl>
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>cairomm/fontface.h</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Aug 13 11:40:14 2009 for cairomm by 
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>
|