80221f2e9adb8dca39b6399c5bc69795ff06f466
[platform/upstream/harfbuzz.git] / docs / html / fonts-and-faces-custom-functions.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Customizing font functions: HarfBuzz Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
7 <link rel="home" href="index.html" title="HarfBuzz Manual">
8 <link rel="up" href="fonts-and-faces.html" title="Fonts, faces, and output">
9 <link rel="prev" href="fonts-and-faces.html" title="Fonts, faces, and output">
10 <link rel="next" href="fonts-and-faces-native-opentype.html" title="Font objects and HarfBuzz's native OpenType implementation">
11 <meta name="generator" content="GTK-Doc V1.29 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts"></td>
17 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
18 <td><a accesskey="u" href="fonts-and-faces.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="fonts-and-faces.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="fonts-and-faces-native-opentype.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div class="section">
23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
24 <a name="fonts-and-faces-custom-functions"></a>Customizing font functions</h2></div></div></div>
25 <p>
26       During shaping, HarfBuzz frequently needs to query font objects
27       to get at the contents and parameters of the glyphs in a font
28       file. It includes a built-in set of functions that is tailored
29       to working with OpenType fonts. However, as was the case with
30       Unicode functions in the buffers chapter, HarfBuzz also wants to
31       make it easy for you to assign a substitute set of font
32       functions if you are developing a program to work with a library
33       or platform that provides its own font functions. 
34     </p>
35 <p>
36       Therefore, the HarfBuzz API defines a set of virtual
37       methods for accessing font-object properties, and you can
38       replace the defaults with your own selections without
39       interfering with the shaping process. Each font object in
40       HarfBuzz includes a structure called
41       <code class="literal">font_funcs</code> that serves as a vtable for the
42       font object. The virtual methods in
43       <code class="literal">font_funcs</code> are:
44     </p>
45 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
46 <li class="listitem"><p>
47       <code class="function">hb_font_get_font_h_extents_func_t</code>: returns
48       the extents of the font for horizontal text.
49     </p></li>
50 <li class="listitem"><p>
51       <code class="function">hb_font_get_font_v_extents_func_t</code>: returns
52       the extents of the font for vertical text.
53     </p></li>
54 <li class="listitem"><p>
55       <code class="function">hb_font_get_nominal_glyph_func_t</code>: returns
56       the font's nominal glyph for a given code point.
57     </p></li>
58 <li class="listitem"><p>
59       <code class="function">hb_font_get_variation_glyph_func_t</code>: returns
60       the font's glyph for a given code point when it is followed by a
61       given Variation Selector.
62     </p></li>
63 <li class="listitem"><p>
64       <code class="function">hb_font_get_nominal_glyphs_func_t</code>: returns
65       the font's nominal glyphs for a series of code points.
66     </p></li>
67 <li class="listitem"><p>
68       <code class="function">hb_font_get_glyph_advance_func_t</code>: returns
69       the advance for a glyph.
70     </p></li>
71 <li class="listitem"><p>
72       <code class="function">hb_font_get_glyph_h_advance_func_t</code>: returns
73       the advance for a glyph for horizontal text.
74     </p></li>
75 <li class="listitem"><p>
76       <code class="function">hb_font_get_glyph_v_advance_func_t</code>:returns
77       the advance for a glyph for vertical text.
78     </p></li>
79 <li class="listitem"><p>
80       <code class="function">hb_font_get_glyph_advances_func_t</code>: returns
81       the advances for a series of glyphs.
82     </p></li>
83 <li class="listitem"><p>
84       <code class="function">hb_font_get_glyph_h_advances_func_t</code>: returns
85       the advances for a series of glyphs for horizontal text .
86     </p></li>
87 <li class="listitem"><p>
88       <code class="function">hb_font_get_glyph_v_advances_func_t</code>: returns
89       the advances for a series of glyphs for vertical text.
90     </p></li>
91 <li class="listitem"><p>
92       <code class="function">hb_font_get_glyph_origin_func_t</code>: returns
93       the origin coordinates of a glyph.
94     </p></li>
95 <li class="listitem"><p>
96       <code class="function">hb_font_get_glyph_h_origin_func_t</code>: returns
97       the origin coordinates of a glyph for horizontal text.
98     </p></li>
99 <li class="listitem"><p>
100       <code class="function">hb_font_get_glyph_v_origin_func_t</code>: returns
101       the origin coordinates of a glyph for vertical text.
102     </p></li>
103 <li class="listitem"><p>
104       <code class="function">hb_font_get_glyph_extents_func_t</code>: returns
105       the extents for a glyph.
106     </p></li>
107 <li class="listitem"><p>
108       <code class="function">hb_font_get_glyph_contour_point_func_t</code>:
109       returns the coordinates of a specific contour point from a glyph.
110     </p></li>
111 <li class="listitem"><p>
112       <code class="function">hb_font_get_glyph_name_func_t</code>: returns the
113       name of a glyph (from its glyph index).
114     </p></li>
115 <li class="listitem"><p>
116       <code class="function">hb_font_get_glyph_from_name_func_t</code>: returns
117       the glyph index that corresponds to a given glyph name.
118     </p></li>
119 </ul></div>
120 <p>
121       You can fetch the font-functions configuration for a font object
122       by calling <code class="function">hb_font_get_font_funcs()</code>:
123     </p>
124 <pre class="programlisting">
125       hb_font_funcs_t *ffunctions;
126       ffunctions = hb_font_get_font_funcs (font);
127     </pre>
128 <p>
129       The individual methods can each be replaced with their own setter
130       function, such as
131       <code class="function">hb_font_funcs_set_nominal_glyph_func(*ffunctions,
132       func, *user_data, destroy)</code>. 
133     </p>
134 <p>
135       Font-functions structures can be reused for multiple font
136       objects, and can be reference counted with
137       <code class="function">hb_font_funcs_reference()</code> and
138       <code class="function">hb_font_funcs_destroy()</code>. Just like other
139       objects in HarfBuzz, you can set user-data for each
140       font-functions structure and assign a destroy callback for
141       it.
142     </p>
143 <p>
144       You can also mark a font-functions structure as immutable,
145       with <code class="function">hb_font_funcs_make_immutable()</code>. This
146       is especially useful if your code is a library or framework that
147       will have its own client programs. By marking your
148       font-functions structures as immutable, you prevent your client
149       programs from changing the configuration and introducing
150       inconsistencies and errors downstream.
151     </p>
152 </div>
153 <div class="footer">
154 <hr>Generated by GTK-Doc V1.29</div>
155 </body>
156 </html>