michael@0: /* michael@0: * Copyright © 2009 Red Hat, Inc. michael@0: * michael@0: * This is part of HarfBuzz, a text shaping library. michael@0: * michael@0: * Permission is hereby granted, without written agreement and without michael@0: * license or royalty fees, to use, copy, modify, and distribute this michael@0: * software and its documentation for any purpose, provided that the michael@0: * above copyright notice and the following two paragraphs appear in michael@0: * all copies of this software. michael@0: * michael@0: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR michael@0: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES michael@0: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN michael@0: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH michael@0: * DAMAGE. michael@0: * michael@0: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, michael@0: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND michael@0: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS michael@0: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO michael@0: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. michael@0: * michael@0: * Red Hat Author(s): Behdad Esfahbod michael@0: */ michael@0: michael@0: #ifndef HB_H_IN michael@0: #error "Include instead." michael@0: #endif michael@0: michael@0: #ifndef HB_FONT_H michael@0: #define HB_FONT_H michael@0: michael@0: #include "hb-common.h" michael@0: #include "hb-face.h" michael@0: michael@0: HB_BEGIN_DECLS michael@0: michael@0: michael@0: typedef struct hb_font_t hb_font_t; michael@0: michael@0: michael@0: /* michael@0: * hb_font_funcs_t michael@0: */ michael@0: michael@0: typedef struct hb_font_funcs_t hb_font_funcs_t; michael@0: michael@0: hb_font_funcs_t * michael@0: hb_font_funcs_create (void); michael@0: michael@0: hb_font_funcs_t * michael@0: hb_font_funcs_get_empty (void); michael@0: michael@0: hb_font_funcs_t * michael@0: hb_font_funcs_reference (hb_font_funcs_t *ffuncs); michael@0: michael@0: void michael@0: hb_font_funcs_destroy (hb_font_funcs_t *ffuncs); michael@0: michael@0: hb_bool_t michael@0: hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs, michael@0: hb_user_data_key_t *key, michael@0: void * data, michael@0: hb_destroy_func_t destroy, michael@0: hb_bool_t replace); michael@0: michael@0: michael@0: void * michael@0: hb_font_funcs_get_user_data (hb_font_funcs_t *ffuncs, michael@0: hb_user_data_key_t *key); michael@0: michael@0: michael@0: void michael@0: hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs); michael@0: michael@0: hb_bool_t michael@0: hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs); michael@0: michael@0: michael@0: /* glyph extents */ michael@0: michael@0: typedef struct hb_glyph_extents_t michael@0: { michael@0: hb_position_t x_bearing; michael@0: hb_position_t y_bearing; michael@0: hb_position_t width; michael@0: hb_position_t height; michael@0: } hb_glyph_extents_t; michael@0: michael@0: michael@0: /* func types */ michael@0: michael@0: typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t unicode, hb_codepoint_t variation_selector, michael@0: hb_codepoint_t *glyph, michael@0: void *user_data); michael@0: michael@0: michael@0: typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t glyph, michael@0: void *user_data); michael@0: typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; michael@0: typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; michael@0: michael@0: typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t glyph, michael@0: hb_position_t *x, hb_position_t *y, michael@0: void *user_data); michael@0: typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t; michael@0: typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; michael@0: michael@0: typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, michael@0: void *user_data); michael@0: typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t; michael@0: typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; michael@0: michael@0: michael@0: typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t glyph, michael@0: hb_glyph_extents_t *extents, michael@0: void *user_data); michael@0: typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t glyph, unsigned int point_index, michael@0: hb_position_t *x, hb_position_t *y, michael@0: void *user_data); michael@0: michael@0: michael@0: typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data, michael@0: hb_codepoint_t glyph, michael@0: char *name, unsigned int size, michael@0: void *user_data); michael@0: typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data, michael@0: const char *name, int len, /* -1 means nul-terminated */ michael@0: hb_codepoint_t *glyph, michael@0: void *user_data); michael@0: michael@0: michael@0: /* func setters */ michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_h_advance_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_h_advance_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_h_advance_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_v_advance_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_v_advance_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_v_advance_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_h_origin_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_h_origin_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_h_origin_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_v_origin_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_v_origin_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_h_kerning_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_h_kerning_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_v_kerning_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_v_kerning_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_extents_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_extents_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_contour_point_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_contour_point_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_contour_point_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_name_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_name_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_name_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: /** michael@0: * hb_font_funcs_set_glyph_from_name_func: michael@0: * @ffuncs: font functions. michael@0: * @func: (closure user_data) (destroy destroy) (scope notified): michael@0: * @user_data: michael@0: * @destroy: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs, michael@0: hb_font_get_glyph_from_name_func_t func, michael@0: void *user_data, hb_destroy_func_t destroy); michael@0: michael@0: michael@0: /* func dispatch */ michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph (hb_font_t *font, michael@0: hb_codepoint_t unicode, hb_codepoint_t variation_selector, michael@0: hb_codepoint_t *glyph); michael@0: michael@0: hb_position_t michael@0: hb_font_get_glyph_h_advance (hb_font_t *font, michael@0: hb_codepoint_t glyph); michael@0: hb_position_t michael@0: hb_font_get_glyph_v_advance (hb_font_t *font, michael@0: hb_codepoint_t glyph); michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph_h_origin (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_position_t *x, hb_position_t *y); michael@0: hb_bool_t michael@0: hb_font_get_glyph_v_origin (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_position_t *x, hb_position_t *y); michael@0: michael@0: hb_position_t michael@0: hb_font_get_glyph_h_kerning (hb_font_t *font, michael@0: hb_codepoint_t left_glyph, hb_codepoint_t right_glyph); michael@0: hb_position_t michael@0: hb_font_get_glyph_v_kerning (hb_font_t *font, michael@0: hb_codepoint_t top_glyph, hb_codepoint_t bottom_glyph); michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph_extents (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_glyph_extents_t *extents); michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph_contour_point (hb_font_t *font, michael@0: hb_codepoint_t glyph, unsigned int point_index, michael@0: hb_position_t *x, hb_position_t *y); michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph_name (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: char *name, unsigned int size); michael@0: hb_bool_t michael@0: hb_font_get_glyph_from_name (hb_font_t *font, michael@0: const char *name, int len, /* -1 means nul-terminated */ michael@0: hb_codepoint_t *glyph); michael@0: michael@0: michael@0: /* high-level funcs, with fallback */ michael@0: michael@0: void michael@0: hb_font_get_glyph_advance_for_direction (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_direction_t direction, michael@0: hb_position_t *x, hb_position_t *y); michael@0: void michael@0: hb_font_get_glyph_origin_for_direction (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_direction_t direction, michael@0: hb_position_t *x, hb_position_t *y); michael@0: void michael@0: hb_font_add_glyph_origin_for_direction (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_direction_t direction, michael@0: hb_position_t *x, hb_position_t *y); michael@0: void michael@0: hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_direction_t direction, michael@0: hb_position_t *x, hb_position_t *y); michael@0: michael@0: void michael@0: hb_font_get_glyph_kerning_for_direction (hb_font_t *font, michael@0: hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, michael@0: hb_direction_t direction, michael@0: hb_position_t *x, hb_position_t *y); michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph_extents_for_origin (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: hb_direction_t direction, michael@0: hb_glyph_extents_t *extents); michael@0: michael@0: hb_bool_t michael@0: hb_font_get_glyph_contour_point_for_origin (hb_font_t *font, michael@0: hb_codepoint_t glyph, unsigned int point_index, michael@0: hb_direction_t direction, michael@0: hb_position_t *x, hb_position_t *y); michael@0: michael@0: /* Generates gidDDD if glyph has no name. */ michael@0: void michael@0: hb_font_glyph_to_string (hb_font_t *font, michael@0: hb_codepoint_t glyph, michael@0: char *s, unsigned int size); michael@0: /* Parses gidDDD and uniUUUU strings automatically. */ michael@0: hb_bool_t michael@0: hb_font_glyph_from_string (hb_font_t *font, michael@0: const char *s, int len, /* -1 means nul-terminated */ michael@0: hb_codepoint_t *glyph); michael@0: michael@0: michael@0: /* michael@0: * hb_font_t michael@0: */ michael@0: michael@0: /* Fonts are very light-weight objects */ michael@0: michael@0: hb_font_t * michael@0: hb_font_create (hb_face_t *face); michael@0: michael@0: hb_font_t * michael@0: hb_font_create_sub_font (hb_font_t *parent); michael@0: michael@0: hb_font_t * michael@0: hb_font_get_empty (void); michael@0: michael@0: hb_font_t * michael@0: hb_font_reference (hb_font_t *font); michael@0: michael@0: void michael@0: hb_font_destroy (hb_font_t *font); michael@0: michael@0: hb_bool_t michael@0: hb_font_set_user_data (hb_font_t *font, michael@0: hb_user_data_key_t *key, michael@0: void * data, michael@0: hb_destroy_func_t destroy, michael@0: hb_bool_t replace); michael@0: michael@0: michael@0: void * michael@0: hb_font_get_user_data (hb_font_t *font, michael@0: hb_user_data_key_t *key); michael@0: michael@0: void michael@0: hb_font_make_immutable (hb_font_t *font); michael@0: michael@0: hb_bool_t michael@0: hb_font_is_immutable (hb_font_t *font); michael@0: michael@0: hb_font_t * michael@0: hb_font_get_parent (hb_font_t *font); michael@0: michael@0: hb_face_t * michael@0: hb_font_get_face (hb_font_t *font); michael@0: michael@0: michael@0: void michael@0: hb_font_set_funcs (hb_font_t *font, michael@0: hb_font_funcs_t *klass, michael@0: void *font_data, michael@0: hb_destroy_func_t destroy); michael@0: michael@0: /* Be *very* careful with this function! */ michael@0: void michael@0: hb_font_set_funcs_data (hb_font_t *font, michael@0: void *font_data, michael@0: hb_destroy_func_t destroy); michael@0: michael@0: michael@0: void michael@0: hb_font_set_scale (hb_font_t *font, michael@0: int x_scale, michael@0: int y_scale); michael@0: michael@0: void michael@0: hb_font_get_scale (hb_font_t *font, michael@0: int *x_scale, michael@0: int *y_scale); michael@0: michael@0: /* michael@0: * A zero value means "no hinting in that direction" michael@0: */ michael@0: void michael@0: hb_font_set_ppem (hb_font_t *font, michael@0: unsigned int x_ppem, michael@0: unsigned int y_ppem); michael@0: michael@0: void michael@0: hb_font_get_ppem (hb_font_t *font, michael@0: unsigned int *x_ppem, michael@0: unsigned int *y_ppem); michael@0: michael@0: michael@0: HB_END_DECLS michael@0: michael@0: #endif /* HB_FONT_H */