2 * Copyright © 2009 Red Hat, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Red Hat Author(s): Behdad Esfahbod
30 #include "hb-common.h"
36 typedef struct _hb_face_t hb_face_t;
37 typedef struct _hb_font_t hb_font_t;
44 hb_face_create_for_data (hb_blob_t *blob,
47 typedef hb_blob_t * (*hb_get_table_func_t) (hb_tag_t tag, void *user_data);
49 /* calls destroy() when not needing user_data anymore */
51 hb_face_create_for_tables (hb_get_table_func_t get_table,
53 hb_destroy_func_t destroy);
56 hb_face_reference (hb_face_t *face);
59 hb_face_destroy (hb_face_t *face);
62 hb_face_set_user_data (hb_face_t *face,
63 hb_user_data_key_t *key,
65 hb_destroy_func_t destroy);
69 hb_face_get_user_data (hb_face_t *face,
70 hb_user_data_key_t *key);
74 hb_face_reference_table (hb_face_t *face,
78 hb_face_get_upem (hb_face_t *face);
85 typedef struct _hb_font_funcs_t hb_font_funcs_t;
88 hb_font_funcs_create (void);
91 hb_font_funcs_reference (hb_font_funcs_t *ffuncs);
94 hb_font_funcs_destroy (hb_font_funcs_t *ffuncs);
97 hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
98 hb_user_data_key_t *key,
100 hb_destroy_func_t destroy);
104 hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
105 hb_user_data_key_t *key);
109 hb_font_funcs_copy (hb_font_funcs_t *ffuncs);
112 hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs);
115 hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
119 typedef struct _hb_glyph_extents_t
121 hb_position_t x_bearing;
122 hb_position_t y_bearing;
124 hb_position_t height;
125 } hb_glyph_extents_t;
127 typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
128 hb_codepoint_t unicode, hb_codepoint_t variation_selector);
129 typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
130 hb_codepoint_t glyph,
131 hb_position_t *x_advance, hb_position_t *y_advance);
132 typedef void (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
133 hb_codepoint_t glyph,
134 hb_glyph_extents_t *extents);
135 typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
136 unsigned int point_index, hb_codepoint_t glyph,
137 hb_position_t *x, hb_position_t *y);
138 typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
139 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
143 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
144 hb_font_get_glyph_func_t glyph_func);
147 hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
148 hb_font_get_glyph_advance_func_t glyph_advance_func);
151 hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
152 hb_font_get_glyph_extents_func_t glyph_extents_func);
155 hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
156 hb_font_get_contour_point_func_t contour_point_func);
159 hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
160 hb_font_get_kerning_func_t kerning_func);
163 /* These never return NULL. Return fallback defaults instead. */
165 hb_font_get_glyph_func_t
166 hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs);
168 hb_font_get_glyph_advance_func_t
169 hb_font_funcs_get_glyph_advance_func (hb_font_funcs_t *ffuncs);
171 hb_font_get_glyph_extents_func_t
172 hb_font_funcs_get_glyph_extents_func (hb_font_funcs_t *ffuncs);
174 hb_font_get_contour_point_func_t
175 hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs);
177 hb_font_get_kerning_func_t
178 hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs);
182 hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
183 hb_codepoint_t unicode, hb_codepoint_t variation_selector);
186 hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face,
187 hb_codepoint_t glyph,
188 hb_position_t *x_advance, hb_position_t *y_advance);
191 hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face,
192 hb_codepoint_t glyph,
193 hb_glyph_extents_t *extents);
196 hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
197 unsigned int point_index, hb_codepoint_t glyph,
198 hb_position_t *x, hb_position_t *y);
201 hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
202 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
209 /* Fonts are very light-weight objects */
212 hb_font_create (void);
215 hb_font_reference (hb_font_t *font);
218 hb_font_destroy (hb_font_t *font);
221 hb_font_set_user_data (hb_font_t *font,
222 hb_user_data_key_t *key,
224 hb_destroy_func_t destroy);
228 hb_font_get_user_data (hb_font_t *font,
229 hb_user_data_key_t *key);
233 hb_font_set_funcs (hb_font_t *font,
234 hb_font_funcs_t *klass,
236 hb_destroy_func_t destroy);
238 /* Returns what was set and unsets it, but doesn't destroy(user_data).
239 * This is useful for wrapping / chaining font_funcs_t's.
241 * The client is responsible for:
243 * - Take ownership of the reference on the returned klass,
245 * - Calling "destroy(user_data)" exactly once if returned destroy func
246 * is not NULL and the returned info is not needed anymore.
249 hb_font_unset_funcs (hb_font_t *font,
250 hb_font_funcs_t **klass,
252 hb_destroy_func_t *destroy);
256 * We should add support for full matrices.
259 hb_font_set_scale (hb_font_t *font,
264 hb_font_get_scale (hb_font_t *font,
269 * A zero value means "no hinting in that direction"
272 hb_font_set_ppem (hb_font_t *font,
274 unsigned int y_ppem);
277 hb_font_get_ppem (hb_font_t *font,
278 unsigned int *x_ppem,
279 unsigned int *y_ppem);
284 #endif /* HB_FONT_H */