/* * Copyright © 2012 Google, Inc. * * This is part of HarfBuzz, a text shaping library. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this * software and its documentation for any purpose, provided that the * above copyright notice and the following two paragraphs appear in * all copies of this software. * * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * Google Author(s): Behdad Esfahbod */ #include "hb.hh" #include "hb-shape-plan.hh" #include "hb-shaper.hh" #include "hb-font.hh" #include "hb-buffer.hh" #ifndef HB_NO_SHAPER /** * SECTION:hb-shape-plan * @title: hb-shape-plan * @short_description: Object representing a shaping plan * @include: hb.h * * Shape plans are an internal mechanism. Each plan contains state * describing how HarfBuzz will shape a particular text segment, based on * the combination of segment properties and the capabilities in the * font face in use. * * Shape plans are not used for shaping directly, but can be queried to * access certain information about how shaping will perform, given a set * of specific input parameters (script, language, direction, features, * etc.). * * Most client programs will not need to deal with shape plans directly. **/ /* * hb_shape_plan_key_t */ bool hb_shape_plan_key_t::init (bool copy, hb_face_t *face, const hb_segment_properties_t *props, const hb_feature_t *user_features, unsigned int num_user_features, const int *coords, unsigned int num_coords, const char * const *shaper_list) { … } bool hb_shape_plan_key_t::user_features_match (const hb_shape_plan_key_t *other) { … } bool hb_shape_plan_key_t::equal (const hb_shape_plan_key_t *other) { … } /* * hb_shape_plan_t */ /** * hb_shape_plan_create: * @face: #hb_face_t to use * @props: The #hb_segment_properties_t of the segment * @user_features: (array length=num_user_features): The list of user-selected features * @num_user_features: The number of user-selected features * @shaper_list: (array zero-terminated=1): List of shapers to try * * Constructs a shaping plan for a combination of @face, @user_features, @props, * and @shaper_list. * * Return value: (transfer full): The shaping plan * * Since: 0.9.7 **/ hb_shape_plan_t * hb_shape_plan_create (hb_face_t *face, const hb_segment_properties_t *props, const hb_feature_t *user_features, unsigned int num_user_features, const char * const *shaper_list) { … } /** * hb_shape_plan_create2: * @face: #hb_face_t to use * @props: The #hb_segment_properties_t of the segment * @user_features: (array length=num_user_features): The list of user-selected features * @num_user_features: The number of user-selected features * @coords: (array length=num_coords): The list of variation-space coordinates * @num_coords: The number of variation-space coordinates * @shaper_list: (array zero-terminated=1): List of shapers to try * * The variable-font version of #hb_shape_plan_create. * Constructs a shaping plan for a combination of @face, @user_features, @props, * and @shaper_list, plus the variation-space coordinates @coords. * * Return value: (transfer full): The shaping plan * * Since: 1.4.0 **/ hb_shape_plan_t * hb_shape_plan_create2 (hb_face_t *face, const hb_segment_properties_t *props, const hb_feature_t *user_features, unsigned int num_user_features, const int *coords, unsigned int num_coords, const char * const *shaper_list) { … } /** * hb_shape_plan_get_empty: * * Fetches the singleton empty shaping plan. * * Return value: (transfer full): The empty shaping plan * * Since: 0.9.7 **/ hb_shape_plan_t * hb_shape_plan_get_empty () { … } /** * hb_shape_plan_reference: (skip) * @shape_plan: A shaping plan * * Increases the reference count on the given shaping plan. * * Return value: (transfer full): @shape_plan * * Since: 0.9.7 **/ hb_shape_plan_t * hb_shape_plan_reference (hb_shape_plan_t *shape_plan) { … } /** * hb_shape_plan_destroy: (skip) * @shape_plan: A shaping plan * * Decreases the reference count on the given shaping plan. When the * reference count reaches zero, the shaping plan is destroyed, * freeing all memory. * * Since: 0.9.7 **/ void hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) { … } /** * hb_shape_plan_set_user_data: (skip) * @shape_plan: A shaping plan * @key: The user-data key to set * @data: A pointer to the user data * @destroy: (nullable): A callback to call when @data is not needed anymore * @replace: Whether to replace an existing data with the same key * * Attaches a user-data key/data pair to the given shaping plan. * * Return value: `true` if success, `false` otherwise. * * Since: 0.9.7 **/ hb_bool_t hb_shape_plan_set_user_data (hb_shape_plan_t *shape_plan, hb_user_data_key_t *key, void * data, hb_destroy_func_t destroy, hb_bool_t replace) { … } /** * hb_shape_plan_get_user_data: (skip) * @shape_plan: A shaping plan * @key: The user-data key to query * * Fetches the user data associated with the specified key, * attached to the specified shaping plan. * * Return value: (transfer none): A pointer to the user data * * Since: 0.9.7 **/ void * hb_shape_plan_get_user_data (const hb_shape_plan_t *shape_plan, hb_user_data_key_t *key) { … } /** * hb_shape_plan_get_shaper: * @shape_plan: A shaping plan * * Fetches the shaper from a given shaping plan. * * Return value: (transfer none): The shaper * * Since: 0.9.7 **/ const char * hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan) { … } static bool _hb_shape_plan_execute_internal (hb_shape_plan_t *shape_plan, hb_font_t *font, hb_buffer_t *buffer, const hb_feature_t *features, unsigned int num_features) { … } /** * hb_shape_plan_execute: * @shape_plan: A shaping plan * @font: The #hb_font_t to use * @buffer: The #hb_buffer_t to work upon * @features: (array length=num_features): Features to enable * @num_features: The number of features to enable * * Executes the given shaping plan on the specified buffer, using * the given @font and @features. * * Return value: `true` if success, `false` otherwise. * * Since: 0.9.7 **/ hb_bool_t hb_shape_plan_execute (hb_shape_plan_t *shape_plan, hb_font_t *font, hb_buffer_t *buffer, const hb_feature_t *features, unsigned int num_features) { … } /* * Caching */ /** * hb_shape_plan_create_cached: * @face: #hb_face_t to use * @props: The #hb_segment_properties_t of the segment * @user_features: (array length=num_user_features): The list of user-selected features * @num_user_features: The number of user-selected features * @shaper_list: (array zero-terminated=1): List of shapers to try * * Creates a cached shaping plan suitable for reuse, for a combination * of @face, @user_features, @props, and @shaper_list. * * Return value: (transfer full): The shaping plan * * Since: 0.9.7 **/ hb_shape_plan_t * hb_shape_plan_create_cached (hb_face_t *face, const hb_segment_properties_t *props, const hb_feature_t *user_features, unsigned int num_user_features, const char * const *shaper_list) { … } /** * hb_shape_plan_create_cached2: * @face: #hb_face_t to use * @props: The #hb_segment_properties_t of the segment * @user_features: (array length=num_user_features): The list of user-selected features * @num_user_features: The number of user-selected features * @coords: (array length=num_coords): The list of variation-space coordinates * @num_coords: The number of variation-space coordinates * @shaper_list: (array zero-terminated=1): List of shapers to try * * The variable-font version of #hb_shape_plan_create_cached. * Creates a cached shaping plan suitable for reuse, for a combination * of @face, @user_features, @props, and @shaper_list, plus the * variation-space coordinates @coords. * * Return value: (transfer full): The shaping plan * * Since: 1.4.0 **/ hb_shape_plan_t * hb_shape_plan_create_cached2 (hb_face_t *face, const hb_segment_properties_t *props, const hb_feature_t *user_features, unsigned int num_user_features, const int *coords, unsigned int num_coords, const char * const *shaper_list) { … } #endif