1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
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">
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>
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>
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.
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:
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.
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.
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.
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.
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.
67 <li class="listitem"><p>
68 <code class="function">hb_font_get_glyph_advance_func_t</code>: returns
69 the advance for a glyph.
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.
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.
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.
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 .
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.
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.
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.
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.
103 <li class="listitem"><p>
104 <code class="function">hb_font_get_glyph_extents_func_t</code>: returns
105 the extents for a glyph.
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.
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).
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.
121 You can fetch the font-functions configuration for a font object
122 by calling <code class="function">hb_font_get_font_funcs()</code>:
124 <pre class="programlisting">
125 hb_font_funcs_t *ffunctions;
126 ffunctions = hb_font_get_font_funcs (font);
129 The individual methods can each be replaced with their own setter
131 <code class="function">hb_font_funcs_set_nominal_glyph_func(*ffunctions,
132 func, *user_data, destroy)</code>.
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
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.
154 <hr>Generated by GTK-Doc V1.29</div>