From aa107e657b7940506548d003d5fda1510e8dfefa Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 30 Dec 2020 23:34:17 +0200 Subject: [PATCH] [docs] Complete hb-font docs a bit --- docs/harfbuzz-sections.txt | 4 +- src/hb-deprecated.h | 37 ++++++++-- src/hb-font.cc | 28 +++++--- src/hb-font.h | 135 ++++++++++++++++++++++++++++++++++--- 4 files changed, 179 insertions(+), 25 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 535cd6ca1..85b0fa7d9 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -329,7 +329,6 @@ hb_font_get_scale hb_font_get_user_data hb_font_get_variation_glyph hb_font_get_variation_glyph_func_t -hb_font_get_var_coords_design hb_font_get_var_coords_normalized hb_font_glyph_from_string hb_font_glyph_to_string @@ -361,6 +360,9 @@ hb_font_get_h_extents hb_font_get_v_extents hb_font_extents_t hb_glyph_extents_t + +hb_font_get_var_coords_design +hb_font_draw_glyph
diff --git a/src/hb-deprecated.h b/src/hb-deprecated.h index 43f89a4c4..52214af40 100644 --- a/src/hb-deprecated.h +++ b/src/hb-deprecated.h @@ -58,6 +58,24 @@ HB_BEGIN_DECLS #define HB_BUFFER_FLAGS_DEFAULT HB_BUFFER_FLAG_DEFAULT #define HB_BUFFER_SERIALIZE_FLAGS_DEFAULT HB_BUFFER_SERIALIZE_FLAG_DEFAULT +/** + * hb_font_get_glyph_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @unicode: The Unicode code point to query + * @variation_selector: The variation-selector code point to query + * @glyph: (out): The glyph ID retrieved + * @user_data: User data pointer passed by the caller + * + * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. + * + * This method should retrieve the glyph ID for a specified Unicode code point + * font, with an optional variation selector. + * + * Return value: %true if data found, %false otherwise + * Deprecated: 1.2.3 + * + **/ typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t unicode, hb_codepoint_t variation_selector, hb_codepoint_t *glyph, @@ -165,16 +183,25 @@ hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs, hb_codepoint_t *decomposed); +/** + * hb_font_get_glyph_v_kerning_func_t: + * + * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. + * + * This method should retrieve the kerning-adjustment value for a glyph-pair in + * the specified font, for vertical text segments. + * + **/ typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; /** * hb_font_funcs_set_glyph_v_kerning_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: + * @ffuncs: A font-function structure + * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign + * @user_data: Data to pass to @func + * @destroy: (optional): The function to call when @user_data is not needed anymore * - * + * Sets the implementation function for #hb_font_get_glyph_v_kerning_func_t. * * Since: 0.9.2 * Deprecated: 2.0.0 diff --git a/src/hb-font.cc b/src/hb-font.cc index 5d3b13187..da6ddbf4d 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -753,7 +753,7 @@ hb_font_t::has_func (unsigned int i) * @font: #hb_font_t to work upon * @extents: (out): The font extents retrieved * - * Fetches the extents for a specified font, in horizontal + * Fetches the extents for a specified font, for horizontal * text segments. * * Return value: %true if data found, %false otherwise @@ -772,7 +772,7 @@ hb_font_get_h_extents (hb_font_t *font, * @font: #hb_font_t to work upon * @extents: (out): The font extents retrieved * - * Fetches the extents for a specified font, in vertical + * Fetches the extents for a specified font, for vertical * text segments. * * Return value: %true if data found, %false otherwise @@ -841,11 +841,17 @@ hb_font_get_nominal_glyph (hb_font_t *font, /** * hb_font_get_nominal_glyphs: - * @font: a font. + * @font: #hb_font_t to work upon + * @count: number of code points to query + * @first_unicode: The first Unicode code point to query + * @unicode_stride: The stride between successive code points + * @first_glyph: (out): The first glyph ID retrieved + * @glyph_stride: The stride between successive glyph IDs * + * Fetches the nominal glyph IDs for a sequence of Unicode code points. Glyph + * IDs must be returned in a #hb_codepoint_t output parameter. * - * - * Return value: + * Return value: the number of code points processed * * Since: 2.6.3 **/ @@ -931,7 +937,7 @@ hb_font_get_glyph_v_advance (hb_font_t *font, * @first_glyph: The first glyph ID to query * @glyph_stride: The stride between successive glyph IDs * @first_advance: (out): The first advance retrieved - * @advance_stride: (out): The stride between successive advances + * @advance_stride: The stride between successive advances * * Fetches the advances for a sequence of glyph IDs in the specified * font, for horizontal text segments. @@ -1026,7 +1032,7 @@ hb_font_get_glyph_v_origin (hb_font_t *font, * @right_glyph: The glyph ID of the right glyph in the glyph pair * * Fetches the kerning-adjustment value for a glyph-pair in - * the specified font, in horizontal text segments. + * the specified font, for horizontal text segments. * * It handles legacy kerning only (as returned by the corresponding * #hb_font_funcs_t function). @@ -1051,7 +1057,7 @@ hb_font_get_glyph_h_kerning (hb_font_t *font, * @bottom_glyph: The glyph ID of the bottom glyph in the glyph pair * * Fetches the kerning-adjustment value for a glyph-pair in - * the specified font, in vertical text segments. + * the specified font, for vertical text segments. * * It handles legacy kerning only (as returned by the corresponding * #hb_font_funcs_t function). @@ -1669,7 +1675,7 @@ hb_font_destroy (hb_font_t *font) * * Attaches a user-data key/data pair to the specified font object. * - * Return value: + * Return value: %true if success, %false otherwise * * Since: 0.9.2 **/ @@ -2212,10 +2218,14 @@ hb_font_get_var_coords_normalized (hb_font_t *font, #ifdef HB_EXPERIMENTAL_API /** * hb_font_get_var_coords_design: + * @font: #hb_font_t to work upon + * @length: (out): number of coordinates * * Return value is valid as long as variation coordinates of the font * are not modified. * + * Return value: coordinates array + * * Since: EXPERIMENTAL */ const float * diff --git a/src/hb-font.h b/src/hb-font.h index 05f6c03f4..657d2fa07 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -37,7 +37,12 @@ HB_BEGIN_DECLS - +/** + * hb_font_t: + * + * Data type for holding fonts. + * + */ typedef struct hb_font_t hb_font_t; @@ -141,6 +146,16 @@ typedef struct hb_glyph_extents_t { /* func types */ +/** + * hb_font_get_font_extents_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @extents: (out): The font extents retrieved + * @user_data: User data pointer passed by the caller + * + * This method should retrieve the extents for a font. + * + **/ typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *font_data, hb_font_extents_t *extents, void *user_data); @@ -150,7 +165,7 @@ typedef hb_bool_t (*hb_font_get_font_extents_func_t) (hb_font_t *font, void *fon * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * - * This method should retrieve the extents for a font, in horizontal-direction + * This method should retrieve the extents for a font, for horizontal-direction * text segments. Extents must be returned in an #hb_glyph_extents output * parameter. * @@ -162,7 +177,7 @@ typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t; * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * - * This method should retrieve the extents for a font, in vertical-direction + * This method should retrieve the extents for a font, for vertical-direction * text segments. Extents must be returned in an #hb_glyph_extents output * parameter. * @@ -172,12 +187,19 @@ typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t; /** * hb_font_get_nominal_glyph_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @unicode: The Unicode code point to query + * @glyph: (out): The glyph ID retrieved + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the nominal glyph ID for a specified Unicode code * point. Glyph IDs must be returned in a #hb_codepoint_t output parameter. * + * Return value: %true if data found, %false otherwise + * **/ typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t unicode, @@ -186,6 +208,12 @@ typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *fo /** * hb_font_get_variation_glyph_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @unicode: The Unicode code point to query + * @variation_selector: The variation-selector code point to query + * @glyph: (out): The glyph ID retrieved + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * @@ -193,6 +221,8 @@ typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *fo * followed by a specified Variation Selector code point. Glyph IDs must be * returned in a #hb_codepoint_t output parameter. * + * Return value: %true if data found, %false otherwise + * **/ typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t unicode, hb_codepoint_t variation_selector, @@ -202,12 +232,22 @@ typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void * /** * hb_font_get_nominal_glyphs_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @count: number of code points to query + * @first_unicode: The first Unicode code point to query + * @unicode_stride: The stride between successive code points + * @first_glyph: (out): The first glyph ID retrieved + * @glyph_stride: The stride between successive glyph IDs + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the nominal glyph IDs for a sequence of * Unicode code points. Glyph IDs must be returned in a #hb_codepoint_t * output parameter. + * + * Return value: the number of code points processed * **/ typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void *font_data, @@ -220,12 +260,18 @@ typedef unsigned int (*hb_font_get_nominal_glyphs_func_t) (hb_font_t *font, void /** * hb_font_get_glyph_advance_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @glyph: The glyph ID to query + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the advance for a specified glyph. The * method must return an #hb_position_t. * + * Return value: The advance of @glyph within @font + * **/ typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t glyph, @@ -257,6 +303,14 @@ typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; /** * hb_font_get_glyph_advances_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @count: The number of glyph IDs in the sequence queried + * @first_glyph: The first glyph ID to query + * @glyph_stride: The stride between successive glyph IDs + * @first_advance: (out): The first advance retrieved + * @advance_stride: The stride between successive advances + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * @@ -295,12 +349,20 @@ typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t; /** * hb_font_get_glyph_origin_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @glyph: The glyph ID to query + * @x: (out): The X coordinate of the origin + * @y: (out): The Y coordinate of the origin + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the (X,Y) coordinates (in font units) of the * origin for a glyph. Each coordinate must be returned in an #hb_position_t * output parameter. + * + * Return value: %true if data found, %false otherwise * **/ typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, @@ -314,7 +376,7 @@ typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *fon * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the (X,Y) coordinates (in font units) of the - * origin for a glyph, in horizontal-direction text segments. Each + * origin for a glyph, for horizontal-direction text segments. Each * coordinate must be returned in an #hb_position_t output parameter. * **/ @@ -326,25 +388,53 @@ typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_h_origin_func_t; * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the (X,Y) coordinates (in font units) of the - * origin for a glyph, in vertical-direction text segments. Each coordinate + * origin for a glyph, for vertical-direction text segments. Each coordinate * must be returned in an #hb_position_t output parameter. * **/ typedef hb_font_get_glyph_origin_func_t hb_font_get_glyph_v_origin_func_t; +/** + * hb_font_get_glyph_kerning_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @first_glyph: The glyph ID of the first glyph in the glyph pair + * @second_glyph: The glyph ID of the second glyph in the glyph pair + * @user_data: User data pointer passed by the caller + * + * This method should retrieve the kerning-adjustment value for a glyph-pair in + * the specified font, for horizontal text segments. + * + **/ typedef hb_position_t (*hb_font_get_glyph_kerning_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, void *user_data); +/** + * hb_font_get_glyph_h_kerning_func_t: + * + * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. + * + * This method should retrieve the kerning-adjustment value for a glyph-pair in + * the specified font, for horizontal text segments. + * + **/ typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_h_kerning_func_t; /** * hb_font_get_glyph_extents_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @glyph: The glyph ID to query + * @extents: (out): The #hb_glyph_extents_t retrieved + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the extents for a specified glyph. Extents must be * returned in an #hb_glyph_extents output parameter. + * + * Return value: %true if data found, %false otherwise * **/ typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *font_data, @@ -354,6 +444,13 @@ typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *fo /** * hb_font_get_glyph_contour_point_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @glyph: The glyph ID to query + * @point_index: The contour-point index to query + * @x: (out): The X value retrieved for the contour point + * @y: (out): The Y value retrieved for the contour point + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * @@ -361,6 +458,8 @@ typedef hb_bool_t (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, void *fo * specified contour point in a glyph. Each coordinate must be returned as * an #hb_position_t output parameter. * + * Return value: %true if data found, %false otherwise + * **/ typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t glyph, unsigned int point_index, @@ -370,12 +469,20 @@ typedef hb_bool_t (*hb_font_get_glyph_contour_point_func_t) (hb_font_t *font, vo /** * hb_font_get_glyph_name_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @glyph: The glyph ID to query + * @name: (out) (array length=size): Name string retrieved for the glyph ID + * @size: Length of the glyph-name string retrieved + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the glyph name that corresponds to a * glyph ID. The name should be returned in a string output parameter. * + * Return value: %true if data found, %false otherwise + * **/ typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t glyph, @@ -384,12 +491,20 @@ typedef hb_bool_t (*hb_font_get_glyph_name_func_t) (hb_font_t *font, void *font_ /** * hb_font_get_glyph_from_name_func_t: + * @font: #hb_font_t to work upon + * @font_data: @font user data pointer + * @name: (array length=len): The name string to query + * @len: The length of the name queried + * @glyph: (out): The glyph ID retrieved + * @user_data: User data pointer passed by the caller * * A virtual method for the #hb_font_funcs_t of an #hb_font_t object. * * This method should retrieve the glyph ID that corresponds to a glyph-name * string. * + * Return value: %true if data found, %false otherwise + * **/ typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *font_data, const char *name, int len, /* -1 means nul-terminated */ @@ -577,12 +692,12 @@ hb_font_funcs_set_glyph_v_origin_func (hb_font_funcs_t *ffuncs, /** * hb_font_funcs_set_glyph_h_kerning_func: - * @ffuncs: font functions. - * @func: (closure user_data) (destroy destroy) (scope notified): - * @user_data: - * @destroy: - * + * @ffuncs: A font-function structure + * @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign + * @user_data: Data to pass to @func + * @destroy: (optional): The function to call when @user_data is not needed anymore * + * Sets the implementation function for #hb_font_get_glyph_h_kerning_func_t. * * Since: 0.9.2 **/