1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/harfbuzz/src/hb-font.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,507 @@ 1.4 +/* 1.5 + * Copyright © 2009 Red Hat, Inc. 1.6 + * 1.7 + * This is part of HarfBuzz, a text shaping library. 1.8 + * 1.9 + * Permission is hereby granted, without written agreement and without 1.10 + * license or royalty fees, to use, copy, modify, and distribute this 1.11 + * software and its documentation for any purpose, provided that the 1.12 + * above copyright notice and the following two paragraphs appear in 1.13 + * all copies of this software. 1.14 + * 1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 1.19 + * DAMAGE. 1.20 + * 1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 1.23 + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 1.26 + * 1.27 + * Red Hat Author(s): Behdad Esfahbod 1.28 + */ 1.29 + 1.30 +#ifndef HB_H_IN 1.31 +#error "Include <hb.h> instead." 1.32 +#endif 1.33 + 1.34 +#ifndef HB_FONT_H 1.35 +#define HB_FONT_H 1.36 + 1.37 +#include "hb-common.h" 1.38 +#include "hb-face.h" 1.39 + 1.40 +HB_BEGIN_DECLS 1.41 + 1.42 + 1.43 +typedef struct hb_font_t hb_font_t; 1.44 + 1.45 + 1.46 +/* 1.47 + * hb_font_funcs_t 1.48 + */ 1.49 + 1.50 +typedef struct hb_font_funcs_t hb_font_funcs_t; 1.51 + 1.52 +hb_font_funcs_t * 1.53 +hb_font_funcs_create (void); 1.54 + 1.55 +hb_font_funcs_t * 1.56 +hb_font_funcs_get_empty (void); 1.57 + 1.58 +hb_font_funcs_t * 1.59 +hb_font_funcs_reference (hb_font_funcs_t *ffuncs); 1.60 + 1.61 +void 1.62 +hb_font_funcs_destroy (hb_font_funcs_t *ffuncs); 1.63 + 1.64 +hb_bool_t 1.65 +hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, 1.66 + hb_user_data_key_t *key, 1.67 + void * data, 1.68 + hb_destroy_func_t destroy, 1.69 + hb_bool_t replace); 1.70 + 1.71 + 1.72 +void * 1.73 +hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, 1.74 + hb_user_data_key_t *key); 1.75 + 1.76 + 1.77 +void 1.78 +hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs); 1.79 + 1.80 +hb_bool_t 1.81 +hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs); 1.82 + 1.83 + 1.84 +/* glyph extents */ 1.85 + 1.86 +typedef struct hb_glyph_extents_t 1.87 +{ 1.88 + hb_position_t x_bearing; 1.89 + hb_position_t y_bearing; 1.90 + hb_position_t width; 1.91 + hb_position_t height; 1.92 +} hb_glyph_extents_t; 1.93 + 1.94 + 1.95 +/* func types */ 1.96 + 1.97 +typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, 1.98 + hb_codepoint_t unicode, hb_codepoint_t variation_selector, 1.99 + hb_codepoint_t *glyph, 1.100 + void *user_data); 1.101 + 1.102 + 1.103 +typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, 1.104 + hb_codepoint_t glyph, 1.105 + void *user_data); 1.106 +typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; 1.107 +typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; 1.108 + 1.109 +typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, 1.110 + hb_codepoint_t glyph, 1.111 + hb_position_t *x, hb_position_t *y, 1.112 + void *user_data); 1.113 +typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t; 1.114 +typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; 1.115 + 1.116 +typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, 1.117 + hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, 1.118 + void *user_data); 1.119 +typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t; 1.120 +typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; 1.121 + 1.122 + 1.123 +typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data, 1.124 + hb_codepoint_t glyph, 1.125 + hb_glyph_extents_t *extents, 1.126 + void *user_data); 1.127 +typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data, 1.128 + hb_codepoint_t glyph, unsigned int point_index, 1.129 + hb_position_t *x, hb_position_t *y, 1.130 + void *user_data); 1.131 + 1.132 + 1.133 +typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data, 1.134 + hb_codepoint_t glyph, 1.135 + char *name, unsigned int size, 1.136 + void *user_data); 1.137 +typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data, 1.138 + const char *name, int len, /* -1 means nul-terminated */ 1.139 + hb_codepoint_t *glyph, 1.140 + void *user_data); 1.141 + 1.142 + 1.143 +/* func setters */ 1.144 + 1.145 +/** 1.146 + * hb_font_funcs_set_glyph_func: 1.147 + * @ffuncs: font functions. 1.148 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.149 + * @user_data: 1.150 + * @destroy: 1.151 + * 1.152 + * 1.153 + * 1.154 + * Since: 1.0 1.155 + **/ 1.156 +void 1.157 +hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, 1.158 + hb_font_get_glyph_func_t func, 1.159 + void *user_data, hb_destroy_func_t destroy); 1.160 + 1.161 +/** 1.162 + * hb_font_funcs_set_glyph_h_advance_func: 1.163 + * @ffuncs: font functions. 1.164 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.165 + * @user_data: 1.166 + * @destroy: 1.167 + * 1.168 + * 1.169 + * 1.170 + * Since: 1.0 1.171 + **/ 1.172 +void 1.173 +hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs, 1.174 + hb_font_get_glyph_h_advance_func_t func, 1.175 + void *user_data, hb_destroy_func_t destroy); 1.176 + 1.177 +/** 1.178 + * hb_font_funcs_set_glyph_v_advance_func: 1.179 + * @ffuncs: font functions. 1.180 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.181 + * @user_data: 1.182 + * @destroy: 1.183 + * 1.184 + * 1.185 + * 1.186 + * Since: 1.0 1.187 + **/ 1.188 +void 1.189 +hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, 1.190 + hb_font_get_glyph_v_advance_func_t func, 1.191 + void *user_data, hb_destroy_func_t destroy); 1.192 + 1.193 +/** 1.194 + * hb_font_funcs_set_glyph_h_origin_func: 1.195 + * @ffuncs: font functions. 1.196 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.197 + * @user_data: 1.198 + * @destroy: 1.199 + * 1.200 + * 1.201 + * 1.202 + * Since: 1.0 1.203 + **/ 1.204 +void 1.205 +hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs, 1.206 + hb_font_get_glyph_h_origin_func_t func, 1.207 + void *user_data, hb_destroy_func_t destroy); 1.208 + 1.209 +/** 1.210 + * hb_font_funcs_set_glyph_v_origin_func: 1.211 + * @ffuncs: font functions. 1.212 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.213 + * @user_data: 1.214 + * @destroy: 1.215 + * 1.216 + * 1.217 + * 1.218 + * Since: 1.0 1.219 + **/ 1.220 +void 1.221 +hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, 1.222 + hb_font_get_glyph_v_origin_func_t func, 1.223 + void *user_data, hb_destroy_func_t destroy); 1.224 + 1.225 +/** 1.226 + * hb_font_funcs_set_glyph_h_kerning_func: 1.227 + * @ffuncs: font functions. 1.228 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.229 + * @user_data: 1.230 + * @destroy: 1.231 + * 1.232 + * 1.233 + * 1.234 + * Since: 1.0 1.235 + **/ 1.236 +void 1.237 +hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, 1.238 + hb_font_get_glyph_h_kerning_func_t func, 1.239 + void *user_data, hb_destroy_func_t destroy); 1.240 + 1.241 +/** 1.242 + * hb_font_funcs_set_glyph_v_kerning_func: 1.243 + * @ffuncs: font functions. 1.244 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.245 + * @user_data: 1.246 + * @destroy: 1.247 + * 1.248 + * 1.249 + * 1.250 + * Since: 1.0 1.251 + **/ 1.252 +void 1.253 +hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs, 1.254 + hb_font_get_glyph_v_kerning_func_t func, 1.255 + void *user_data, hb_destroy_func_t destroy); 1.256 + 1.257 +/** 1.258 + * hb_font_funcs_set_glyph_extents_func: 1.259 + * @ffuncs: font functions. 1.260 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.261 + * @user_data: 1.262 + * @destroy: 1.263 + * 1.264 + * 1.265 + * 1.266 + * Since: 1.0 1.267 + **/ 1.268 +void 1.269 +hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs, 1.270 + hb_font_get_glyph_extents_func_t func, 1.271 + void *user_data, hb_destroy_func_t destroy); 1.272 + 1.273 +/** 1.274 + * hb_font_funcs_set_glyph_contour_point_func: 1.275 + * @ffuncs: font functions. 1.276 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.277 + * @user_data: 1.278 + * @destroy: 1.279 + * 1.280 + * 1.281 + * 1.282 + * Since: 1.0 1.283 + **/ 1.284 +void 1.285 +hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs, 1.286 + hb_font_get_glyph_contour_point_func_t func, 1.287 + void *user_data, hb_destroy_func_t destroy); 1.288 + 1.289 +/** 1.290 + * hb_font_funcs_set_glyph_name_func: 1.291 + * @ffuncs: font functions. 1.292 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.293 + * @user_data: 1.294 + * @destroy: 1.295 + * 1.296 + * 1.297 + * 1.298 + * Since: 1.0 1.299 + **/ 1.300 +void 1.301 +hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs, 1.302 + hb_font_get_glyph_name_func_t func, 1.303 + void *user_data, hb_destroy_func_t destroy); 1.304 + 1.305 +/** 1.306 + * hb_font_funcs_set_glyph_from_name_func: 1.307 + * @ffuncs: font functions. 1.308 + * @func: (closure user_data) (destroy destroy) (scope notified): 1.309 + * @user_data: 1.310 + * @destroy: 1.311 + * 1.312 + * 1.313 + * 1.314 + * Since: 1.0 1.315 + **/ 1.316 +void 1.317 +hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs, 1.318 + hb_font_get_glyph_from_name_func_t func, 1.319 + void *user_data, hb_destroy_func_t destroy); 1.320 + 1.321 + 1.322 +/* func dispatch */ 1.323 + 1.324 +hb_bool_t 1.325 +hb_font_get_glyph (hb_font_t *font, 1.326 + hb_codepoint_t unicode, hb_codepoint_t variation_selector, 1.327 + hb_codepoint_t *glyph); 1.328 + 1.329 +hb_position_t 1.330 +hb_font_get_glyph_h_advance (hb_font_t *font, 1.331 + hb_codepoint_t glyph); 1.332 +hb_position_t 1.333 +hb_font_get_glyph_v_advance (hb_font_t *font, 1.334 + hb_codepoint_t glyph); 1.335 + 1.336 +hb_bool_t 1.337 +hb_font_get_glyph_h_origin (hb_font_t *font, 1.338 + hb_codepoint_t glyph, 1.339 + hb_position_t *x, hb_position_t *y); 1.340 +hb_bool_t 1.341 +hb_font_get_glyph_v_origin (hb_font_t *font, 1.342 + hb_codepoint_t glyph, 1.343 + hb_position_t *x, hb_position_t *y); 1.344 + 1.345 +hb_position_t 1.346 +hb_font_get_glyph_h_kerning (hb_font_t *font, 1.347 + hb_codepoint_t left_glyph, hb_codepoint_t right_glyph); 1.348 +hb_position_t 1.349 +hb_font_get_glyph_v_kerning (hb_font_t *font, 1.350 + hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph); 1.351 + 1.352 +hb_bool_t 1.353 +hb_font_get_glyph_extents (hb_font_t *font, 1.354 + hb_codepoint_t glyph, 1.355 + hb_glyph_extents_t *extents); 1.356 + 1.357 +hb_bool_t 1.358 +hb_font_get_glyph_contour_point (hb_font_t *font, 1.359 + hb_codepoint_t glyph, unsigned int point_index, 1.360 + hb_position_t *x, hb_position_t *y); 1.361 + 1.362 +hb_bool_t 1.363 +hb_font_get_glyph_name (hb_font_t *font, 1.364 + hb_codepoint_t glyph, 1.365 + char *name, unsigned int size); 1.366 +hb_bool_t 1.367 +hb_font_get_glyph_from_name (hb_font_t *font, 1.368 + const char *name, int len, /* -1 means nul-terminated */ 1.369 + hb_codepoint_t *glyph); 1.370 + 1.371 + 1.372 +/* high-level funcs, with fallback */ 1.373 + 1.374 +void 1.375 +hb_font_get_glyph_advance_for_direction (hb_font_t *font, 1.376 + hb_codepoint_t glyph, 1.377 + hb_direction_t direction, 1.378 + hb_position_t *x, hb_position_t *y); 1.379 +void 1.380 +hb_font_get_glyph_origin_for_direction (hb_font_t *font, 1.381 + hb_codepoint_t glyph, 1.382 + hb_direction_t direction, 1.383 + hb_position_t *x, hb_position_t *y); 1.384 +void 1.385 +hb_font_add_glyph_origin_for_direction (hb_font_t *font, 1.386 + hb_codepoint_t glyph, 1.387 + hb_direction_t direction, 1.388 + hb_position_t *x, hb_position_t *y); 1.389 +void 1.390 +hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, 1.391 + hb_codepoint_t glyph, 1.392 + hb_direction_t direction, 1.393 + hb_position_t *x, hb_position_t *y); 1.394 + 1.395 +void 1.396 +hb_font_get_glyph_kerning_for_direction (hb_font_t *font, 1.397 + hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, 1.398 + hb_direction_t direction, 1.399 + hb_position_t *x, hb_position_t *y); 1.400 + 1.401 +hb_bool_t 1.402 +hb_font_get_glyph_extents_for_origin (hb_font_t *font, 1.403 + hb_codepoint_t glyph, 1.404 + hb_direction_t direction, 1.405 + hb_glyph_extents_t *extents); 1.406 + 1.407 +hb_bool_t 1.408 +hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, 1.409 + hb_codepoint_t glyph, unsigned int point_index, 1.410 + hb_direction_t direction, 1.411 + hb_position_t *x, hb_position_t *y); 1.412 + 1.413 +/* Generates gidDDD if glyph has no name. */ 1.414 +void 1.415 +hb_font_glyph_to_string (hb_font_t *font, 1.416 + hb_codepoint_t glyph, 1.417 + char *s, unsigned int size); 1.418 +/* Parses gidDDD and uniUUUU strings automatically. */ 1.419 +hb_bool_t 1.420 +hb_font_glyph_from_string (hb_font_t *font, 1.421 + const char *s, int len, /* -1 means nul-terminated */ 1.422 + hb_codepoint_t *glyph); 1.423 + 1.424 + 1.425 +/* 1.426 + * hb_font_t 1.427 + */ 1.428 + 1.429 +/* Fonts are very light-weight objects */ 1.430 + 1.431 +hb_font_t * 1.432 +hb_font_create (hb_face_t *face); 1.433 + 1.434 +hb_font_t * 1.435 +hb_font_create_sub_font (hb_font_t *parent); 1.436 + 1.437 +hb_font_t * 1.438 +hb_font_get_empty (void); 1.439 + 1.440 +hb_font_t * 1.441 +hb_font_reference (hb_font_t *font); 1.442 + 1.443 +void 1.444 +hb_font_destroy (hb_font_t *font); 1.445 + 1.446 +hb_bool_t 1.447 +hb_font_set_user_data (hb_font_t *font, 1.448 + hb_user_data_key_t *key, 1.449 + void * data, 1.450 + hb_destroy_func_t destroy, 1.451 + hb_bool_t replace); 1.452 + 1.453 + 1.454 +void * 1.455 +hb_font_get_user_data (hb_font_t *font, 1.456 + hb_user_data_key_t *key); 1.457 + 1.458 +void 1.459 +hb_font_make_immutable (hb_font_t *font); 1.460 + 1.461 +hb_bool_t 1.462 +hb_font_is_immutable (hb_font_t *font); 1.463 + 1.464 +hb_font_t * 1.465 +hb_font_get_parent (hb_font_t *font); 1.466 + 1.467 +hb_face_t * 1.468 +hb_font_get_face (hb_font_t *font); 1.469 + 1.470 + 1.471 +void 1.472 +hb_font_set_funcs (hb_font_t *font, 1.473 + hb_font_funcs_t *klass, 1.474 + void *font_data, 1.475 + hb_destroy_func_t destroy); 1.476 + 1.477 +/* Be *very* careful with this function! */ 1.478 +void 1.479 +hb_font_set_funcs_data (hb_font_t *font, 1.480 + void *font_data, 1.481 + hb_destroy_func_t destroy); 1.482 + 1.483 + 1.484 +void 1.485 +hb_font_set_scale (hb_font_t *font, 1.486 + int x_scale, 1.487 + int y_scale); 1.488 + 1.489 +void 1.490 +hb_font_get_scale (hb_font_t *font, 1.491 + int *x_scale, 1.492 + int *y_scale); 1.493 + 1.494 +/* 1.495 + * A zero value means "no hinting in that direction" 1.496 + */ 1.497 +void 1.498 +hb_font_set_ppem (hb_font_t *font, 1.499 + unsigned int x_ppem, 1.500 + unsigned int y_ppem); 1.501 + 1.502 +void 1.503 +hb_font_get_ppem (hb_font_t *font, 1.504 + unsigned int *x_ppem, 1.505 + unsigned int *y_ppem); 1.506 + 1.507 + 1.508 +HB_END_DECLS 1.509 + 1.510 +#endif /* HB_FONT_H */