blob: d1b8a8822d41f515902c5db45c483c2a447d2ec5 [file] [log] [blame]
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001/*
Behdad Esfahbod2409d5f2011-04-21 17:14:28 -04002 * Copyright © 2009 Red Hat, Inc.
Behdad Esfahbod027857d2012-07-26 17:34:25 -04003 * Copyright © 2012 Google, Inc.
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04004 *
Behdad Esfahbodc755cb32010-04-22 00:11:43 -04005 * This is part of HarfBuzz, a text shaping library.
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04006 *
7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
12 *
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 *
25 * Red Hat Author(s): Behdad Esfahbod
Behdad Esfahbod027857d2012-07-26 17:34:25 -040026 * Google Author(s): Behdad Esfahbod
Behdad Esfahbodc62b5032009-08-01 19:54:49 -040027 */
28
Behdad Esfahbodc57d4542011-04-20 18:50:27 -040029#include "hb-private.hh"
Behdad Esfahbodc62b5032009-08-01 19:54:49 -040030
Behdad Esfahbod266b3442011-05-03 00:35:53 -040031#include "hb-ot-layout-private.hh"
32
Behdad Esfahbodc57d4542011-04-20 18:50:27 -040033#include "hb-font-private.hh"
Behdad Esfahbod23c86aa2009-08-03 21:40:20 -040034#include "hb-open-file-private.hh"
Behdad Esfahbod7a750ac2011-08-17 14:19:59 +020035#include "hb-ot-head-table.hh"
Behdad Esfahbode05a9992012-11-15 16:23:21 -080036#include "hb-ot-maxp-table.hh"
Behdad Esfahbodc62b5032009-08-01 19:54:49 -040037
Behdad Esfahbod20fdb0f2012-05-17 22:04:45 -040038#include "hb-cache-private.hh"
39
Behdad Esfahbod79512792009-11-03 20:27:05 -050040#include <string.h>
41
Behdad Esfahbodacdba3f2010-07-23 15:11:18 -040042
Behdad Esfahbodc62b5032009-08-01 19:54:49 -040043/*
Behdad Esfahbod5c441882009-08-10 20:05:16 -040044 * hb_font_funcs_t
Behdad Esfahbodc62b5032009-08-01 19:54:49 -040045 */
46
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -040047static hb_bool_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -080048hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbodb4678272011-05-11 23:25:28 -040049 void *font_data HB_UNUSED,
Behdad Esfahboda513dbc2011-05-11 00:24:34 -040050 hb_codepoint_t unicode,
51 hb_codepoint_t variation_selector,
Behdad Esfahbod0fd8c2f2011-05-12 15:14:13 -040052 hb_codepoint_t *glyph,
Behdad Esfahbodb4678272011-05-11 23:25:28 -040053 void *user_data HB_UNUSED)
Behdad Esfahbod1ded6d82011-05-10 20:49:02 -040054{
Behdad Esfahbod0fd8c2f2011-05-12 15:14:13 -040055 *glyph = 0;
Behdad Esfahbod0594a242012-06-05 20:35:40 -040056 return false;
Behdad Esfahbod1ded6d82011-05-10 20:49:02 -040057}
Behdad Esfahbodda29b432015-11-04 20:22:44 -080058static hb_bool_t
59hb_font_get_glyph_parent (hb_font_t *font,
60 void *font_data HB_UNUSED,
61 hb_codepoint_t unicode,
62 hb_codepoint_t variation_selector,
63 hb_codepoint_t *glyph,
64 void *user_data HB_UNUSED)
65{
66 return font->parent->get_glyph (unicode, variation_selector, glyph);
67}
Behdad Esfahbod79512792009-11-03 20:27:05 -050068
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -040069static hb_position_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -080070hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod744970a2011-05-16 18:15:37 -040071 void *font_data HB_UNUSED,
72 hb_codepoint_t glyph,
Behdad Esfahbod744970a2011-05-16 18:15:37 -040073 void *user_data HB_UNUSED)
Behdad Esfahbod1ded6d82011-05-10 20:49:02 -040074{
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -040075 return font->x_scale;
Behdad Esfahbod744970a2011-05-16 18:15:37 -040076}
Behdad Esfahbodda29b432015-11-04 20:22:44 -080077static hb_position_t
78hb_font_get_glyph_h_advance_parent (hb_font_t *font,
79 void *font_data HB_UNUSED,
80 hb_codepoint_t glyph,
81 void *user_data HB_UNUSED)
82{
83 return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph));
84}
Behdad Esfahbod744970a2011-05-16 18:15:37 -040085
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -040086static hb_position_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -080087hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod744970a2011-05-16 18:15:37 -040088 void *font_data HB_UNUSED,
89 hb_codepoint_t glyph,
Behdad Esfahbod744970a2011-05-16 18:15:37 -040090 void *user_data HB_UNUSED)
91{
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -040092 return font->y_scale;
Behdad Esfahbod744970a2011-05-16 18:15:37 -040093}
Behdad Esfahbodda29b432015-11-04 20:22:44 -080094static hb_position_t
95hb_font_get_glyph_v_advance_parent (hb_font_t *font,
96 void *font_data HB_UNUSED,
97 hb_codepoint_t glyph,
98 void *user_data HB_UNUSED)
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -040099{
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800100 return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph));
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400101}
102
103static hb_bool_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800104hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400105 void *font_data HB_UNUSED,
106 hb_codepoint_t glyph,
Behdad Esfahbod19098182011-05-17 23:27:22 -0400107 hb_position_t *x,
108 hb_position_t *y,
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400109 void *user_data HB_UNUSED)
110{
Behdad Esfahbod19098182011-05-17 23:27:22 -0400111 *x = *y = 0;
Behdad Esfahbodc41c1452015-11-26 18:43:15 -0500112 return true;
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400113}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800114static hb_bool_t
115hb_font_get_glyph_h_origin_parent (hb_font_t *font,
116 void *font_data HB_UNUSED,
117 hb_codepoint_t glyph,
118 hb_position_t *x,
119 hb_position_t *y,
120 void *user_data HB_UNUSED)
121{
122 hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y);
123 if (ret)
124 font->parent_scale_position (x, y);
125 return ret;
126}
127
128static hb_bool_t
129hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
130 void *font_data HB_UNUSED,
131 hb_codepoint_t glyph,
132 hb_position_t *x,
133 hb_position_t *y,
134 void *user_data HB_UNUSED)
135{
136 *x = *y = 0;
137 return false;
138}
139static hb_bool_t
140hb_font_get_glyph_v_origin_parent (hb_font_t *font,
141 void *font_data HB_UNUSED,
142 hb_codepoint_t glyph,
143 hb_position_t *x,
144 hb_position_t *y,
145 void *user_data HB_UNUSED)
146{
147 hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y);
148 if (ret)
149 font->parent_scale_position (x, y);
150 return ret;
151}
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400152
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400153static hb_position_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800154hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400155 void *font_data HB_UNUSED,
156 hb_codepoint_t left_glyph,
157 hb_codepoint_t right_glyph,
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400158 void *user_data HB_UNUSED)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400159{
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400160 return 0;
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400161}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800162static hb_position_t
163hb_font_get_glyph_h_kerning_parent (hb_font_t *font,
164 void *font_data HB_UNUSED,
165 hb_codepoint_t left_glyph,
166 hb_codepoint_t right_glyph,
167 void *user_data HB_UNUSED)
168{
169 return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph));
170}
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400171
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400172static hb_position_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800173hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400174 void *font_data HB_UNUSED,
175 hb_codepoint_t top_glyph,
176 hb_codepoint_t bottom_glyph,
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400177 void *user_data HB_UNUSED)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400178{
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400179 return 0;
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400180}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800181static hb_position_t
182hb_font_get_glyph_v_kerning_parent (hb_font_t *font,
183 void *font_data HB_UNUSED,
184 hb_codepoint_t top_glyph,
185 hb_codepoint_t bottom_glyph,
186 void *user_data HB_UNUSED)
187{
188 return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
189}
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400190
191static hb_bool_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800192hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400193 void *font_data HB_UNUSED,
194 hb_codepoint_t glyph,
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400195 hb_glyph_extents_t *extents,
196 void *user_data HB_UNUSED)
197{
Behdad Esfahbod60fbb362011-05-19 18:46:15 -0400198 memset (extents, 0, sizeof (*extents));
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400199 return false;
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400200}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800201static hb_bool_t
202hb_font_get_glyph_extents_parent (hb_font_t *font,
203 void *font_data HB_UNUSED,
204 hb_codepoint_t glyph,
205 hb_glyph_extents_t *extents,
206 void *user_data HB_UNUSED)
207{
208 hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents);
209 if (ret) {
210 font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
211 font->parent_scale_distance (&extents->width, &extents->height);
212 }
213 return ret;
214}
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400215
216static hb_bool_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800217hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400218 void *font_data HB_UNUSED,
219 hb_codepoint_t glyph,
220 unsigned int point_index,
221 hb_position_t *x,
222 hb_position_t *y,
223 void *user_data HB_UNUSED)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400224{
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400225 *x = *y = 0;
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400226 return false;
Behdad Esfahbod1ded6d82011-05-10 20:49:02 -0400227}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800228static hb_bool_t
229hb_font_get_glyph_contour_point_parent (hb_font_t *font,
230 void *font_data HB_UNUSED,
231 hb_codepoint_t glyph,
232 unsigned int point_index,
233 hb_position_t *x,
234 hb_position_t *y,
235 void *user_data HB_UNUSED)
236{
237 hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y);
238 if (ret)
239 font->parent_scale_position (x, y);
240 return ret;
241}
Behdad Esfahbod79512792009-11-03 20:27:05 -0500242
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400243static hb_bool_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800244hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400245 void *font_data HB_UNUSED,
246 hb_codepoint_t glyph,
247 char *name, unsigned int size,
248 void *user_data HB_UNUSED)
249{
Behdad Esfahbod6f3a3002012-08-07 22:13:25 -0400250 if (size) *name = '\0';
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400251 return false;
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400252}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800253static hb_bool_t
254hb_font_get_glyph_name_parent (hb_font_t *font,
255 void *font_data HB_UNUSED,
256 hb_codepoint_t glyph,
257 char *name, unsigned int size,
258 void *user_data HB_UNUSED)
259{
260 return font->parent->get_glyph_name (glyph, name, size);
261}
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400262
263static hb_bool_t
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800264hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED,
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400265 void *font_data HB_UNUSED,
266 const char *name, int len, /* -1 means nul-terminated */
267 hb_codepoint_t *glyph,
268 void *user_data HB_UNUSED)
269{
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400270 *glyph = 0;
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400271 return false;
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400272}
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800273static hb_bool_t
274hb_font_get_glyph_from_name_parent (hb_font_t *font,
275 void *font_data HB_UNUSED,
276 const char *name, int len, /* -1 means nul-terminated */
277 hb_codepoint_t *glyph,
278 void *user_data HB_UNUSED)
279{
280 return font->parent->get_glyph_from_name (name, len, glyph);
281}
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400282
Behdad Esfahbod56eb5ad2011-05-04 19:27:37 -0400283
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -0400284static const hb_font_funcs_t _hb_font_funcs_nil = {
Behdad Esfahbodfca368c2011-04-21 18:24:02 -0400285 HB_OBJECT_HEADER_STATIC,
286
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400287 true, /* immutable */
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400288
Behdad Esfahbodbf36a102010-05-24 17:46:21 +0100289 {
Behdad Esfahbod28de1042015-11-04 22:00:25 -0800290#define HB_FONT_FUNC_IMPLEMENT(name) NULL,
291 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
292#undef HB_FONT_FUNC_IMPLEMENT
293 },
294 {
295#define HB_FONT_FUNC_IMPLEMENT(name) NULL,
296 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
297#undef HB_FONT_FUNC_IMPLEMENT
298 },
299 {
jfkthamef19c6db2015-11-20 08:43:49 +0000300 {
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400301#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil,
jfkthamef19c6db2015-11-20 08:43:49 +0000302 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400303#undef HB_FONT_FUNC_IMPLEMENT
jfkthamef19c6db2015-11-20 08:43:49 +0000304 }
Behdad Esfahbodbf36a102010-05-24 17:46:21 +0100305 }
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400306};
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800307static const hb_font_funcs_t _hb_font_funcs_parent = {
308 HB_OBJECT_HEADER_STATIC,
309
310 true, /* immutable */
311
312 {
Behdad Esfahbod28de1042015-11-04 22:00:25 -0800313#define HB_FONT_FUNC_IMPLEMENT(name) NULL,
314 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
315#undef HB_FONT_FUNC_IMPLEMENT
316 },
317 {
318#define HB_FONT_FUNC_IMPLEMENT(name) NULL,
319 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
320#undef HB_FONT_FUNC_IMPLEMENT
321 },
322 {
jfkthamef19c6db2015-11-20 08:43:49 +0000323 {
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800324#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent,
jfkthamef19c6db2015-11-20 08:43:49 +0000325 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800326#undef HB_FONT_FUNC_IMPLEMENT
jfkthamef19c6db2015-11-20 08:43:49 +0000327 }
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800328 }
329};
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400330
Behdad Esfahbod56eb5ad2011-05-04 19:27:37 -0400331
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400332/**
Behdad Esfahbod085d4292013-09-12 17:14:33 -0400333 * hb_font_funcs_create: (Xconstructor)
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400334 *
335 *
336 *
337 * Return value: (transfer full):
338 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430339 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400340 **/
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400341hb_font_funcs_t *
342hb_font_funcs_create (void)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400343{
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400344 hb_font_funcs_t *ffuncs;
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400345
Behdad Esfahbod47e71d92011-04-27 16:38:03 -0400346 if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -0400347 return hb_font_funcs_get_empty ();
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400348
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800349 ffuncs->get = _hb_font_funcs_parent.get;
Behdad Esfahbodf97bf4f2010-05-24 17:50:19 +0100350
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400351 return ffuncs;
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400352}
353
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400354/**
355 * hb_font_funcs_get_empty:
356 *
357 *
358 *
359 * Return value: (transfer full):
360 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430361 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400362 **/
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400363hb_font_funcs_t *
Behdad Esfahbod80a68332011-05-11 18:14:44 -0400364hb_font_funcs_get_empty (void)
365{
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800366 return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_parent);
Behdad Esfahbod80a68332011-05-11 18:14:44 -0400367}
368
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400369/**
370 * hb_font_funcs_reference: (skip)
371 * @ffuncs: font functions.
372 *
373 *
374 *
375 * Return value:
376 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430377 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400378 **/
Behdad Esfahbod80a68332011-05-11 18:14:44 -0400379hb_font_funcs_t *
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400380hb_font_funcs_reference (hb_font_funcs_t *ffuncs)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400381{
Behdad Esfahbod47e71d92011-04-27 16:38:03 -0400382 return hb_object_reference (ffuncs);
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400383}
384
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400385/**
386 * hb_font_funcs_destroy: (skip)
387 * @ffuncs: font functions.
388 *
389 *
390 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430391 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400392 **/
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400393void
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400394hb_font_funcs_destroy (hb_font_funcs_t *ffuncs)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400395{
Behdad Esfahbod47e71d92011-04-27 16:38:03 -0400396 if (!hb_object_destroy (ffuncs)) return;
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400397
Behdad Esfahbod4b6317c2011-07-07 23:14:42 -0400398#define HB_FONT_FUNC_IMPLEMENT(name) if (ffuncs->destroy.name) \
399 ffuncs->destroy.name (ffuncs->user_data.name);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400400 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
401#undef HB_FONT_FUNC_IMPLEMENT
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400402
Behdad Esfahbod5c441882009-08-10 20:05:16 -0400403 free (ffuncs);
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400404}
405
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400406/**
407 * hb_font_funcs_set_user_data: (skip)
408 * @ffuncs: font functions.
409 * @key:
410 * @data:
411 * @destroy:
412 * @replace:
413 *
414 *
415 *
416 * Return value:
417 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430418 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400419 **/
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400420hb_bool_t
421hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
422 hb_user_data_key_t *key,
423 void * data,
Behdad Esfahbod33ccc772011-08-09 00:43:24 +0200424 hb_destroy_func_t destroy,
425 hb_bool_t replace)
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400426{
Behdad Esfahbod33ccc772011-08-09 00:43:24 +0200427 return hb_object_set_user_data (ffuncs, key, data, destroy, replace);
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400428}
429
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400430/**
431 * hb_font_funcs_get_user_data: (skip)
432 * @ffuncs: font functions.
433 * @key:
434 *
435 *
436 *
437 * Return value: (transfer none):
438 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430439 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400440 **/
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400441void *
442hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs,
443 hb_user_data_key_t *key)
444{
445 return hb_object_get_user_data (ffuncs, key);
446}
447
448
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400449/**
450 * hb_font_funcs_make_immutable:
451 * @ffuncs: font functions.
452 *
453 *
454 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430455 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400456 **/
Behdad Esfahbod8d703122009-08-10 23:50:51 -0400457void
458hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
459{
Behdad Esfahbod3f310dc2014-07-22 16:26:27 -0400460 if (unlikely (hb_object_is_inert (ffuncs)))
Behdad Esfahbod8d703122009-08-10 23:50:51 -0400461 return;
462
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400463 ffuncs->immutable = true;
Behdad Esfahbod8d703122009-08-10 23:50:51 -0400464}
465
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400466/**
467 * hb_font_funcs_is_immutable:
468 * @ffuncs: font functions.
469 *
470 *
471 *
472 * Return value:
473 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430474 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400475 **/
Behdad Esfahbod645f6f22010-10-04 17:01:01 -0400476hb_bool_t
477hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs)
478{
Behdad Esfahbod3111b8a2010-10-13 10:41:53 -0400479 return ffuncs->immutable;
Behdad Esfahbod645f6f22010-10-04 17:01:01 -0400480}
481
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400482
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400483#define HB_FONT_FUNC_IMPLEMENT(name) \
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400484 \
485void \
486hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \
487 hb_font_get_##name##_func_t func, \
488 void *user_data, \
489 hb_destroy_func_t destroy) \
490{ \
Behdad Esfahbod0cd33592011-09-21 16:49:33 -0400491 if (ffuncs->immutable) { \
492 if (destroy) \
493 destroy (user_data); \
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400494 return; \
Behdad Esfahbod0cd33592011-09-21 16:49:33 -0400495 } \
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400496 \
497 if (ffuncs->destroy.name) \
498 ffuncs->destroy.name (ffuncs->user_data.name); \
499 \
500 if (func) { \
Behdad Esfahbod88e9a9b2015-11-04 21:16:26 -0800501 ffuncs->get.f.name = func; \
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400502 ffuncs->user_data.name = user_data; \
503 ffuncs->destroy.name = destroy; \
504 } else { \
Behdad Esfahbod88e9a9b2015-11-04 21:16:26 -0800505 ffuncs->get.f.name = hb_font_get_##name##_parent; \
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400506 ffuncs->user_data.name = NULL; \
507 ffuncs->destroy.name = NULL; \
508 } \
Behdad Esfahbod79512792009-11-03 20:27:05 -0500509}
510
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400511HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
512#undef HB_FONT_FUNC_IMPLEMENT
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400513
Behdad Esfahbod762770c2015-11-04 21:42:55 -0800514bool
515hb_font_t::has_func (unsigned int i)
516{
517 if (parent && parent != hb_font_get_empty () && parent->has_func (i))
518 return true;
519 return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i];
520}
Behdad Esfahbod502f4cb2010-10-27 01:13:56 -0400521
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400522/* Public getters */
523
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400524/**
525 * hb_font_get_glyph:
526 * @font: a font.
527 * @unicode:
528 * @variation_selector:
529 * @glyph: (out):
530 *
531 *
532 *
533 * Return value:
534 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430535 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400536 **/
Behdad Esfahbod0fd8c2f2011-05-12 15:14:13 -0400537hb_bool_t
Behdad Esfahbodb9d975b2011-05-10 20:41:13 -0400538hb_font_get_glyph (hb_font_t *font,
Behdad Esfahbod0fd8c2f2011-05-12 15:14:13 -0400539 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
540 hb_codepoint_t *glyph)
Behdad Esfahbod2e336692009-11-05 13:55:41 -0500541{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400542 return font->get_glyph (unicode, variation_selector, glyph);
Behdad Esfahbod2e336692009-11-05 13:55:41 -0500543}
544
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400545/**
546 * hb_font_get_glyph_h_advance:
547 * @font: a font.
548 * @glyph:
549 *
550 *
551 *
552 * Return value:
553 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430554 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400555 **/
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400556hb_position_t
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400557hb_font_get_glyph_h_advance (hb_font_t *font,
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400558 hb_codepoint_t glyph)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400559{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400560 return font->get_glyph_h_advance (glyph);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400561}
562
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400563/**
564 * hb_font_get_glyph_v_advance:
565 * @font: a font.
566 * @glyph:
567 *
568 *
569 *
570 * Return value:
571 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430572 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400573 **/
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400574hb_position_t
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400575hb_font_get_glyph_v_advance (hb_font_t *font,
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400576 hb_codepoint_t glyph)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400577{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400578 return font->get_glyph_v_advance (glyph);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400579}
580
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400581/**
582 * hb_font_get_glyph_h_origin:
583 * @font: a font.
584 * @glyph:
585 * @x: (out):
586 * @y: (out):
587 *
588 *
589 *
590 * Return value:
591 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430592 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400593 **/
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400594hb_bool_t
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400595hb_font_get_glyph_h_origin (hb_font_t *font,
596 hb_codepoint_t glyph,
Behdad Esfahbod19098182011-05-17 23:27:22 -0400597 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400598{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400599 return font->get_glyph_h_origin (glyph, x, y);
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400600}
601
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400602/**
603 * hb_font_get_glyph_v_origin:
604 * @font: a font.
605 * @glyph:
606 * @x: (out):
607 * @y: (out):
608 *
609 *
610 *
611 * Return value:
612 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430613 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400614 **/
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400615hb_bool_t
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400616hb_font_get_glyph_v_origin (hb_font_t *font,
617 hb_codepoint_t glyph,
Behdad Esfahbod19098182011-05-17 23:27:22 -0400618 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400619{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400620 return font->get_glyph_v_origin (glyph, x, y);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400621}
622
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400623/**
624 * hb_font_get_glyph_h_kerning:
625 * @font: a font.
626 * @left_glyph:
627 * @right_glyph:
628 *
629 *
630 *
631 * Return value:
632 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430633 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400634 **/
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400635hb_position_t
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400636hb_font_get_glyph_h_kerning (hb_font_t *font,
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400637 hb_codepoint_t left_glyph, hb_codepoint_t right_glyph)
Behdad Esfahbod2e336692009-11-05 13:55:41 -0500638{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400639 return font->get_glyph_h_kerning (left_glyph, right_glyph);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400640}
641
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400642/**
643 * hb_font_get_glyph_v_kerning:
644 * @font: a font.
645 * @top_glyph:
646 * @bottom_glyph:
647 *
648 *
649 *
650 * Return value:
651 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430652 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400653 **/
Behdad Esfahbod2d8ebcb2011-05-25 11:27:33 -0400654hb_position_t
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400655hb_font_get_glyph_v_kerning (hb_font_t *font,
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400656 hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400657{
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400658 return font->get_glyph_v_kerning (top_glyph, bottom_glyph);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400659}
660
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400661/**
662 * hb_font_get_glyph_extents:
663 * @font: a font.
664 * @glyph:
665 * @extents: (out):
666 *
667 *
668 *
669 * Return value:
670 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430671 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400672 **/
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400673hb_bool_t
674hb_font_get_glyph_extents (hb_font_t *font,
675 hb_codepoint_t glyph,
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400676 hb_glyph_extents_t *extents)
677{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400678 return font->get_glyph_extents (glyph, extents);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400679}
680
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400681/**
682 * hb_font_get_glyph_contour_point:
683 * @font: a font.
684 * @glyph:
685 * @point_index:
686 * @x: (out):
687 * @y: (out):
688 *
689 *
690 *
691 * Return value:
692 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430693 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400694 **/
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400695hb_bool_t
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400696hb_font_get_glyph_contour_point (hb_font_t *font,
697 hb_codepoint_t glyph, unsigned int point_index,
698 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400699{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400700 return font->get_glyph_contour_point (glyph, point_index, x, y);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400701}
702
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400703/**
704 * hb_font_get_glyph_name:
705 * @font: a font.
706 * @glyph:
707 * @name: (array length=size):
708 * @size:
709 *
710 *
711 *
712 * Return value:
713 *
Sascha Brawer01c3a882015-06-01 13:22:01 +0200714 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400715 **/
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400716hb_bool_t
717hb_font_get_glyph_name (hb_font_t *font,
718 hb_codepoint_t glyph,
719 char *name, unsigned int size)
720{
Behdad Esfahbod6f3a3002012-08-07 22:13:25 -0400721 return font->get_glyph_name (glyph, name, size);
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400722}
723
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400724/**
725 * hb_font_get_glyph_from_name:
726 * @font: a font.
727 * @name: (array length=len):
728 * @len:
729 * @glyph: (out):
730 *
731 *
732 *
733 * Return value:
734 *
Sascha Brawer01c3a882015-06-01 13:22:01 +0200735 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400736 **/
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400737hb_bool_t
738hb_font_get_glyph_from_name (hb_font_t *font,
739 const char *name, int len, /* -1 means nul-terminated */
740 hb_codepoint_t *glyph)
741{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400742 return font->get_glyph_from_name (name, len, glyph);
Behdad Esfahbodbce09552012-05-27 11:29:21 -0400743}
744
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400745
746/* A bit higher-level, and with fallback */
747
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400748/**
749 * hb_font_get_glyph_advance_for_direction:
750 * @font: a font.
751 * @glyph:
752 * @direction:
753 * @x: (out):
754 * @y: (out):
755 *
756 *
757 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430758 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400759 **/
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400760void
761hb_font_get_glyph_advance_for_direction (hb_font_t *font,
762 hb_codepoint_t glyph,
763 hb_direction_t direction,
Behdad Esfahbod19098182011-05-17 23:27:22 -0400764 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400765{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400766 return font->get_glyph_advance_for_direction (glyph, direction, x, y);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400767}
768
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400769/**
770 * hb_font_get_glyph_origin_for_direction:
771 * @font: a font.
772 * @glyph:
773 * @direction:
774 * @x: (out):
775 * @y: (out):
776 *
777 *
778 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430779 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400780 **/
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400781void
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400782hb_font_get_glyph_origin_for_direction (hb_font_t *font,
783 hb_codepoint_t glyph,
784 hb_direction_t direction,
Behdad Esfahbod19098182011-05-17 23:27:22 -0400785 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400786{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400787 return font->get_glyph_origin_for_direction (glyph, direction, x, y);
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400788}
789
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400790/**
791 * hb_font_add_glyph_origin_for_direction:
792 * @font: a font.
793 * @glyph:
794 * @direction:
795 * @x: (out):
796 * @y: (out):
797 *
798 *
799 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430800 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400801 **/
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400802void
Behdad Esfahbod8b38fae2011-05-19 13:08:00 -0400803hb_font_add_glyph_origin_for_direction (hb_font_t *font,
804 hb_codepoint_t glyph,
805 hb_direction_t direction,
806 hb_position_t *x, hb_position_t *y)
807{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400808 return font->add_glyph_origin_for_direction (glyph, direction, x, y);
Behdad Esfahbod8b38fae2011-05-19 13:08:00 -0400809}
810
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400811/**
812 * hb_font_subtract_glyph_origin_for_direction:
813 * @font: a font.
814 * @glyph:
815 * @direction:
816 * @x: (out):
817 * @y: (out):
818 *
819 *
820 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430821 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400822 **/
Behdad Esfahbod8b38fae2011-05-19 13:08:00 -0400823void
824hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
825 hb_codepoint_t glyph,
826 hb_direction_t direction,
827 hb_position_t *x, hb_position_t *y)
828{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400829 return font->subtract_glyph_origin_for_direction (glyph, direction, x, y);
Behdad Esfahbod8b38fae2011-05-19 13:08:00 -0400830}
831
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400832/**
833 * hb_font_get_glyph_kerning_for_direction:
834 * @font: a font.
835 * @first_glyph:
836 * @second_glyph:
837 * @direction:
838 * @x: (out):
839 * @y: (out):
840 *
841 *
842 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430843 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400844 **/
Behdad Esfahbod8b38fae2011-05-19 13:08:00 -0400845void
Behdad Esfahbod7e2c85d2011-05-17 17:55:03 -0400846hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
847 hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
848 hb_direction_t direction,
Behdad Esfahbod19098182011-05-17 23:27:22 -0400849 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400850{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400851 return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400852}
853
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400854/**
855 * hb_font_get_glyph_extents_for_origin:
856 * @font: a font.
857 * @glyph:
858 * @direction:
859 * @extents: (out):
860 *
861 *
862 *
863 * Return value:
864 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430865 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400866 **/
Behdad Esfahbod60fbb362011-05-19 18:46:15 -0400867hb_bool_t
868hb_font_get_glyph_extents_for_origin (hb_font_t *font,
869 hb_codepoint_t glyph,
870 hb_direction_t direction,
871 hb_glyph_extents_t *extents)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400872{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400873 return font->get_glyph_extents_for_origin (glyph, direction, extents);
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400874}
875
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400876/**
877 * hb_font_get_glyph_contour_point_for_origin:
878 * @font: a font.
879 * @glyph:
880 * @point_index:
881 * @direction:
882 * @x: (out):
883 * @y: (out):
884 *
885 *
886 *
887 * Return value:
888 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430889 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400890 **/
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400891hb_bool_t
Behdad Esfahbod60fbb362011-05-19 18:46:15 -0400892hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
893 hb_codepoint_t glyph, unsigned int point_index,
894 hb_direction_t direction,
895 hb_position_t *x, hb_position_t *y)
Behdad Esfahbod744970a2011-05-16 18:15:37 -0400896{
Behdad Esfahbod8fbfda92012-08-01 19:03:46 -0400897 return font->get_glyph_contour_point_for_origin (glyph, point_index, direction, x, y);
Behdad Esfahbod2e336692009-11-05 13:55:41 -0500898}
899
Behdad Esfahbod6f3a3002012-08-07 22:13:25 -0400900/* Generates gidDDD if glyph has no name. */
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400901/**
902 * hb_font_glyph_to_string:
903 * @font: a font.
904 * @glyph:
905 * @s: (array length=size):
906 * @size:
907 *
908 *
909 *
Sascha Brawer01c3a882015-06-01 13:22:01 +0200910 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400911 **/
Behdad Esfahbod6f3a3002012-08-07 22:13:25 -0400912void
913hb_font_glyph_to_string (hb_font_t *font,
914 hb_codepoint_t glyph,
915 char *s, unsigned int size)
916{
917 font->glyph_to_string (glyph, s, size);
918}
919
920/* Parses gidDDD and uniUUUU strings automatically. */
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400921/**
922 * hb_font_glyph_from_string:
923 * @font: a font.
Khaled Hosnya394bb62015-03-22 20:29:10 +0200924 * @s: (array length=len) (element-type uint8_t):
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400925 * @len:
926 * @glyph: (out):
927 *
928 *
929 *
930 * Return value:
931 *
Sascha Brawer01c3a882015-06-01 13:22:01 +0200932 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400933 **/
Behdad Esfahbod6f3a3002012-08-07 22:13:25 -0400934hb_bool_t
935hb_font_glyph_from_string (hb_font_t *font,
936 const char *s, int len, /* -1 means nul-terminated */
937 hb_codepoint_t *glyph)
938{
939 return font->glyph_from_string (s, len, glyph);
940}
941
Behdad Esfahbod1cebfbb2010-04-23 20:49:18 -0400942
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400943/*
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400944 * hb_font_t
945 */
946
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400947/**
Behdad Esfahbod085d4292013-09-12 17:14:33 -0400948 * hb_font_create: (Xconstructor)
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400949 * @face: a face.
950 *
951 *
952 *
953 * Return value: (transfer full):
954 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430955 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400956 **/
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400957hb_font_t *
Behdad Esfahbod72657e42011-05-02 20:46:32 -0400958hb_font_create (hb_face_t *face)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400959{
960 hb_font_t *font;
961
Behdad Esfahbod72657e42011-05-02 20:46:32 -0400962 if (unlikely (!face))
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -0400963 face = hb_face_get_empty ();
Behdad Esfahbod47e71d92011-04-27 16:38:03 -0400964 if (!(font = hb_object_create<hb_font_t> ()))
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -0400965 return hb_font_get_empty ();
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400966
Behdad Esfahbod7fc5a302011-05-12 17:48:20 -0400967 hb_face_make_immutable (face);
Behdad Esfahbodda29b432015-11-04 20:22:44 -0800968 font->parent = hb_font_get_empty ();
Behdad Esfahbod72657e42011-05-02 20:46:32 -0400969 font->face = hb_face_reference (face);
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -0400970 font->klass = hb_font_funcs_get_empty ();
Behdad Esfahbod85555a92009-11-05 18:25:56 -0500971
Behdad Esfahbod88da7bb2015-10-02 14:38:20 +0100972 font->x_scale = font->y_scale = hb_face_get_upem (face);
973
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400974 return font;
975}
976
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400977/**
978 * hb_font_create_sub_font:
979 * @parent: parent font.
980 *
981 *
982 *
983 * Return value: (transfer full):
984 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +0430985 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -0400986 **/
Behdad Esfahbodc62b5032009-08-01 19:54:49 -0400987hb_font_t *
Behdad Esfahboddefc45b2011-05-10 20:02:49 -0400988hb_font_create_sub_font (hb_font_t *parent)
989{
990 if (unlikely (!parent))
Behdad Esfahbodeb0bf3a2014-08-06 15:36:41 -0400991 parent = hb_font_get_empty ();
Behdad Esfahboddefc45b2011-05-10 20:02:49 -0400992
993 hb_font_t *font = hb_font_create (parent->face);
994
995 if (unlikely (hb_object_is_inert (font)))
996 return font;
997
Behdad Esfahboddefc45b2011-05-10 20:02:49 -0400998 font->parent = hb_font_reference (parent);
999
1000 font->x_scale = parent->x_scale;
1001 font->y_scale = parent->y_scale;
1002 font->x_ppem = parent->x_ppem;
1003 font->y_ppem = parent->y_ppem;
1004
Behdad Esfahboddefc45b2011-05-10 20:02:49 -04001005 return font;
1006}
1007
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001008/**
1009 * hb_font_get_empty:
1010 *
1011 *
1012 *
1013 * Return value: (transfer full)
1014 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301015 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001016 **/
Behdad Esfahboddefc45b2011-05-10 20:02:49 -04001017hb_font_t *
Behdad Esfahbod80a68332011-05-11 18:14:44 -04001018hb_font_get_empty (void)
1019{
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -04001020 static const hb_font_t _hb_font_nil = {
1021 HB_OBJECT_HEADER_STATIC,
1022
Behdad Esfahbod0594a242012-06-05 20:35:40 -04001023 true, /* immutable */
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -04001024
1025 NULL, /* parent */
1026 const_cast<hb_face_t *> (&_hb_face_nil),
1027
Behdad Esfahbodda29b432015-11-04 20:22:44 -08001028 1000, /* x_scale */
1029 1000, /* y_scale */
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -04001030
1031 0, /* x_ppem */
1032 0, /* y_ppem */
1033
1034 const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */
1035 NULL, /* user_data */
Behdad Esfahbodea278d32012-07-27 02:12:28 -04001036 NULL, /* destroy */
1037
1038 {
1039#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
1040#include "hb-shaper-list.hh"
1041#undef HB_SHAPER_IMPLEMENT
1042 }
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -04001043 };
1044
1045 return const_cast<hb_font_t *> (&_hb_font_nil);
Behdad Esfahbod80a68332011-05-11 18:14:44 -04001046}
1047
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001048/**
1049 * hb_font_reference: (skip)
1050 * @font: a font.
1051 *
1052 *
1053 *
1054 * Return value: (transfer full):
1055 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301056 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001057 **/
Behdad Esfahbod80a68332011-05-11 18:14:44 -04001058hb_font_t *
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001059hb_font_reference (hb_font_t *font)
1060{
Behdad Esfahbod47e71d92011-04-27 16:38:03 -04001061 return hb_object_reference (font);
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001062}
1063
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001064/**
1065 * hb_font_destroy: (skip)
1066 * @font: a font.
1067 *
1068 *
1069 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301070 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001071 **/
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001072void
1073hb_font_destroy (hb_font_t *font)
1074{
Behdad Esfahbod47e71d92011-04-27 16:38:03 -04001075 if (!hb_object_destroy (font)) return;
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001076
Behdad Esfahbod027857d2012-07-26 17:34:25 -04001077#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font);
1078#include "hb-shaper-list.hh"
1079#undef HB_SHAPER_IMPLEMENT
1080
1081 if (font->destroy)
1082 font->destroy (font->user_data);
1083
Behdad Esfahboddefc45b2011-05-10 20:02:49 -04001084 hb_font_destroy (font->parent);
Behdad Esfahbod72657e42011-05-02 20:46:32 -04001085 hb_face_destroy (font->face);
Behdad Esfahbod5c441882009-08-10 20:05:16 -04001086 hb_font_funcs_destroy (font->klass);
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001087
1088 free (font);
1089}
1090
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001091/**
1092 * hb_font_set_user_data: (skip)
1093 * @font: a font.
1094 * @key:
1095 * @data:
1096 * @destroy:
1097 * @replace:
1098 *
1099 *
1100 *
1101 * Return value:
1102 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301103 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001104 **/
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -04001105hb_bool_t
1106hb_font_set_user_data (hb_font_t *font,
1107 hb_user_data_key_t *key,
1108 void * data,
Behdad Esfahbod33ccc772011-08-09 00:43:24 +02001109 hb_destroy_func_t destroy,
1110 hb_bool_t replace)
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -04001111{
Behdad Esfahbod33ccc772011-08-09 00:43:24 +02001112 return hb_object_set_user_data (font, key, data, destroy, replace);
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -04001113}
1114
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001115/**
1116 * hb_font_get_user_data: (skip)
1117 * @font: a font.
1118 * @key:
1119 *
1120 *
1121 *
1122 * Return value: (transfer none):
1123 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301124 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001125 **/
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -04001126void *
1127hb_font_get_user_data (hb_font_t *font,
1128 hb_user_data_key_t *key)
1129{
1130 return hb_object_get_user_data (font, key);
1131}
1132
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001133/**
1134 * hb_font_make_immutable:
1135 * @font: a font.
1136 *
1137 *
1138 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301139 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001140 **/
Behdad Esfahbod74f1d892011-05-10 19:39:32 -04001141void
1142hb_font_make_immutable (hb_font_t *font)
1143{
Behdad Esfahbod3f310dc2014-07-22 16:26:27 -04001144 if (unlikely (hb_object_is_inert (font)))
Behdad Esfahbod74f1d892011-05-10 19:39:32 -04001145 return;
1146
Behdad Esfahbod1866e172015-10-02 14:21:29 +01001147 if (font->parent)
1148 hb_font_make_immutable (font->parent);
1149
Behdad Esfahbod74f1d892011-05-10 19:39:32 -04001150 font->immutable = true;
1151}
1152
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001153/**
1154 * hb_font_is_immutable:
1155 * @font: a font.
1156 *
1157 *
1158 *
1159 * Return value:
1160 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301161 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001162 **/
Behdad Esfahbod74f1d892011-05-10 19:39:32 -04001163hb_bool_t
1164hb_font_is_immutable (hb_font_t *font)
1165{
1166 return font->immutable;
1167}
1168
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001169/**
Behdad Esfahbod3e905e32015-10-08 12:51:02 -04001170 * hb_font_set_parent:
1171 * @font: a font.
1172 * @parent: new parent.
1173 *
1174 * Sets parent font of @font.
1175 *
1176 * Since: 1.0.5
1177 **/
1178void
1179hb_font_set_parent (hb_font_t *font,
1180 hb_font_t *parent)
1181{
1182 if (font->immutable)
1183 return;
1184
1185 if (!parent)
1186 parent = hb_font_get_empty ();
1187
1188 hb_font_t *old = font->parent;
1189
1190 font->parent = hb_font_reference (parent);
1191
1192 hb_font_destroy (old);
1193}
1194
1195/**
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001196 * hb_font_get_parent:
1197 * @font: a font.
1198 *
1199 *
1200 *
1201 * Return value: (transfer none):
1202 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301203 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001204 **/
Behdad Esfahboddefc45b2011-05-10 20:02:49 -04001205hb_font_t *
1206hb_font_get_parent (hb_font_t *font)
1207{
1208 return font->parent;
1209}
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -04001210
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001211/**
1212 * hb_font_get_face:
1213 * @font: a font.
1214 *
1215 *
1216 *
1217 * Return value: (transfer none):
1218 *
Sascha Brawer01c3a882015-06-01 13:22:01 +02001219 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001220 **/
Behdad Esfahbod72657e42011-05-02 20:46:32 -04001221hb_face_t *
1222hb_font_get_face (hb_font_t *font)
1223{
1224 return font->face;
1225}
1226
1227
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001228/**
1229 * hb_font_set_funcs:
1230 * @font: a font.
Behdad Esfahboda8949df2013-09-13 20:23:51 -04001231 * @klass: (closure font_data) (destroy destroy) (scope notified):
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001232 * @font_data:
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001233 * @destroy:
1234 *
1235 *
1236 *
Sascha Brawer01c3a882015-06-01 13:22:01 +02001237 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001238 **/
Behdad Esfahbod5c441882009-08-10 20:05:16 -04001239void
Behdad Esfahbod8fb3d1a2009-11-03 18:34:20 -05001240hb_font_set_funcs (hb_font_t *font,
1241 hb_font_funcs_t *klass,
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001242 void *font_data,
Behdad Esfahbod56681892011-04-20 03:03:32 -04001243 hb_destroy_func_t destroy)
Behdad Esfahbod0ead4812009-08-02 17:41:36 -04001244{
Behdad Esfahbod0cd33592011-09-21 16:49:33 -04001245 if (font->immutable) {
1246 if (destroy)
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001247 destroy (font_data);
Behdad Esfahbod5c441882009-08-10 20:05:16 -04001248 return;
Behdad Esfahbod0cd33592011-09-21 16:49:33 -04001249 }
Behdad Esfahbod0ead4812009-08-02 17:41:36 -04001250
Behdad Esfahbod8fb3d1a2009-11-03 18:34:20 -05001251 if (font->destroy)
1252 font->destroy (font->user_data);
1253
Behdad Esfahbod0465e692009-12-20 16:25:18 +01001254 if (!klass)
Behdad Esfahbodf06ab8a2012-06-05 12:31:51 -04001255 klass = hb_font_funcs_get_empty ();
Behdad Esfahbod0465e692009-12-20 16:25:18 +01001256
Behdad Esfahbod5c441882009-08-10 20:05:16 -04001257 hb_font_funcs_reference (klass);
1258 hb_font_funcs_destroy (font->klass);
1259 font->klass = klass;
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001260 font->user_data = font_data;
Behdad Esfahbod56681892011-04-20 03:03:32 -04001261 font->destroy = destroy;
Behdad Esfahbod0ead4812009-08-02 17:41:36 -04001262}
1263
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001264/**
1265 * hb_font_set_funcs_data:
1266 * @font: a font.
Behdad Esfahboda8949df2013-09-13 20:23:51 -04001267 * @font_data: (destroy destroy) (scope notified):
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001268 * @destroy:
1269 *
1270 *
1271 *
Sascha Brawer01c3a882015-06-01 13:22:01 +02001272 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001273 **/
Behdad Esfahbodb9415e72011-08-17 19:21:44 +02001274void
1275hb_font_set_funcs_data (hb_font_t *font,
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001276 void *font_data,
Behdad Esfahbodb9415e72011-08-17 19:21:44 +02001277 hb_destroy_func_t destroy)
1278{
Behdad Esfahbod0cd33592011-09-21 16:49:33 -04001279 /* Destroy user_data? */
1280 if (font->immutable) {
1281 if (destroy)
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001282 destroy (font_data);
Behdad Esfahbodb9415e72011-08-17 19:21:44 +02001283 return;
Behdad Esfahbod0cd33592011-09-21 16:49:33 -04001284 }
Behdad Esfahbodb9415e72011-08-17 19:21:44 +02001285
1286 if (font->destroy)
1287 font->destroy (font->user_data);
1288
Behdad Esfahbod70303cf2013-09-06 17:35:57 -04001289 font->user_data = font_data;
Behdad Esfahbodb9415e72011-08-17 19:21:44 +02001290 font->destroy = destroy;
1291}
1292
Behdad Esfahbod19c0eab2010-10-04 16:45:21 -04001293
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001294/**
1295 * hb_font_set_scale:
1296 * @font: a font.
1297 * @x_scale:
1298 * @y_scale:
1299 *
1300 *
1301 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301302 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001303 **/
Behdad Esfahbod19c0eab2010-10-04 16:45:21 -04001304void
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001305hb_font_set_scale (hb_font_t *font,
Behdad Esfahbodda975412011-04-21 15:08:01 -04001306 int x_scale,
1307 int y_scale)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001308{
Behdad Esfahbod74f1d892011-05-10 19:39:32 -04001309 if (font->immutable)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001310 return;
1311
1312 font->x_scale = x_scale;
1313 font->y_scale = y_scale;
1314}
1315
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001316/**
1317 * hb_font_get_scale:
1318 * @font: a font.
1319 * @x_scale: (out):
1320 * @y_scale: (out):
1321 *
1322 *
1323 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301324 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001325 **/
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001326void
Behdad Esfahbod19c0eab2010-10-04 16:45:21 -04001327hb_font_get_scale (hb_font_t *font,
Behdad Esfahbodda975412011-04-21 15:08:01 -04001328 int *x_scale,
1329 int *y_scale)
Behdad Esfahbod19c0eab2010-10-04 16:45:21 -04001330{
1331 if (x_scale) *x_scale = font->x_scale;
1332 if (y_scale) *y_scale = font->y_scale;
1333}
1334
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001335/**
1336 * hb_font_set_ppem:
1337 * @font: a font.
1338 * @x_ppem:
1339 * @y_ppem:
1340 *
1341 *
1342 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301343 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001344 **/
Behdad Esfahbod19c0eab2010-10-04 16:45:21 -04001345void
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001346hb_font_set_ppem (hb_font_t *font,
1347 unsigned int x_ppem,
1348 unsigned int y_ppem)
1349{
Behdad Esfahbod74f1d892011-05-10 19:39:32 -04001350 if (font->immutable)
Behdad Esfahbodc62b5032009-08-01 19:54:49 -04001351 return;
1352
1353 font->x_ppem = x_ppem;
1354 font->y_ppem = y_ppem;
1355}
1356
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001357/**
1358 * hb_font_get_ppem:
1359 * @font: a font.
1360 * @x_ppem: (out):
1361 * @y_ppem: (out):
1362 *
1363 *
1364 *
Behdad Esfahbod5d74ff02015-09-03 14:55:59 +04301365 * Since: 0.9.2
Behdad Esfahbod288f2892013-09-06 15:40:22 -04001366 **/
Behdad Esfahbod19c0eab2010-10-04 16:45:21 -04001367void
1368hb_font_get_ppem (hb_font_t *font,
1369 unsigned int *x_ppem,
1370 unsigned int *y_ppem)
1371{
1372 if (x_ppem) *x_ppem = font->x_ppem;
1373 if (y_ppem) *y_ppem = font->y_ppem;
1374}