/** * hb_cairo_font_face_create_for_font: * @font: a #hb_font_t * * Creates a #cairo_font_face_t for rendering text according * to @font. * * Note that the scale of @font does not affect the rendering, * but the variations and slant that are set on @font do. * * Returns: (transfer full): a newly created #cairo_font_face_t * * Since: 7.0.0
*/
cairo_font_face_t *
hb_cairo_font_face_create_for_font (hb_font_t *font)
{
hb_font_make_immutable (font);
auto *cairo_face = user_font_face_create (font->face);
/** * hb_cairo_font_face_get_font: * @font_face: a #cairo_font_face_t * * Gets the #hb_font_t that @font_face was created from. * * Returns: (nullable) (transfer none): the #hb_font_t that @font_face was created from * * Since: 7.0.0
*/
hb_font_t *
hb_cairo_font_face_get_font (cairo_font_face_t *font_face)
{ return (hb_font_t *) cairo_font_face_get_user_data (font_face,
&hb_cairo_font_user_data_key);
}
/** * hb_cairo_font_face_create_for_face: * @face: a #hb_face_t * * Creates a #cairo_font_face_t for rendering text according * to @face. * * Returns: (transfer full): a newly created #cairo_font_face_t * * Since: 7.0.0
*/
cairo_font_face_t *
hb_cairo_font_face_create_for_face (hb_face_t *face)
{
hb_face_make_immutable (face);
return user_font_face_create (face);
}
/** * hb_cairo_font_face_get_face: * @font_face: a #cairo_font_face_t * * Gets the #hb_face_t associated with @font_face. * * Returns: (nullable) (transfer none): the #hb_face_t associated with @font_face * * Since: 7.0.0
*/
hb_face_t *
hb_cairo_font_face_get_face (cairo_font_face_t *font_face)
{ return (hb_face_t *) cairo_font_face_get_user_data (font_face,
&hb_cairo_face_user_data_key);
}
/** * hb_cairo_font_face_set_font_init_func: * @font_face: a #cairo_font_face_t * @func: The virtual method to use * @user_data: user data accompanying the method * @destroy: function to call when @user_data is not needed anymore * * Set the virtual method to be called when a cairo * face created using hb_cairo_font_face_create_for_face() * creates an #hb_font_t for a #cairo_scaled_font_t. * * Since: 7.0.0
*/ void
hb_cairo_font_face_set_font_init_func (cairo_font_face_t *font_face,
hb_cairo_font_init_func_t func, void *user_data,
hb_destroy_func_t destroy)
{
cairo_font_face_set_user_data (font_face,
&hb_cairo_font_init_func_user_data_key,
(void *) func,
nullptr); if (unlikely (CAIRO_STATUS_SUCCESS != cairo_font_face_set_user_data (font_face,
&hb_cairo_font_init_user_data_user_data_key,
(void *) user_data,
destroy)) && destroy)
{
destroy (user_data);
cairo_font_face_set_user_data (font_face,
&hb_cairo_font_init_func_user_data_key,
nullptr,
nullptr);
}
}
/** * hb_cairo_scaled_font_get_font: * @scaled_font: a #cairo_scaled_font_t * * Gets the #hb_font_t associated with @scaled_font. * * Returns: (nullable) (transfer none): the #hb_font_t associated with @scaled_font * * Since: 7.0.0
*/
hb_font_t *
hb_cairo_scaled_font_get_font (cairo_scaled_font_t *scaled_font)
{ return (hb_font_t *) cairo_scaled_font_get_user_data (scaled_font, &hb_cairo_font_user_data_key);
}
/** * hb_cairo_font_face_set_scale_factor: * @scale_factor: The scale factor to use. See below * @font_face: a #cairo_font_face_t * * Sets the scale factor of the @font_face. Default scale * factor is zero. * * When a #cairo_font_face_t is created from a #hb_face_t using * hb_cairo_font_face_create_for_face(), such face will create * #hb_font_t objects during scaled-font creation. The scale * factor defines how the scale set on such #hb_font_t objects * relates to the font-matrix (as such font size) of the cairo * scaled-font. * * If the scale-factor is zero (default), then the scale of the * #hb_font_t object will be left at default, which is the UPEM * value of the respective #hb_face_t. * * If the scale-factor is set to non-zero, then the X and Y scale * of the #hb_font_t object will be respectively set to the * @scale_factor times the xx and yy elements of the scale-matrix * of the cairo scaled-font being created. * * When using the hb_cairo_glyphs_from_buffer() API to convert the * HarfBuzz glyph buffer that resulted from shaping with such a #hb_font_t, * if the scale-factor was non-zero, you can pass it directly to * that API as both X and Y scale factors. * * If the scale-factor was zero however, or the cairo face was * created using the alternative constructor * hb_cairo_font_face_create_for_font(), you need to calculate the * correct X/Y scale-factors to pass to hb_cairo_glyphs_from_buffer() * by dividing the #hb_font_t X/Y scale-factors by the * cairo scaled-font's scale-matrix XX/YY components respectively * and use those values. Or if you know that relationship offhand * (because you set the scale of the #hb_font_t yourself), use * the conversion rate involved. * * Since: 7.0.0
*/ void
hb_cairo_font_face_set_scale_factor (cairo_font_face_t *font_face, unsignedint scale_factor)
{
cairo_font_face_set_user_data (font_face,
&hb_cairo_scale_factor_user_data_key,
(void *) (uintptr_t) scale_factor,
nullptr);
}
/** * hb_cairo_font_face_get_scale_factor: * @font_face: a #cairo_font_face_t * * Gets the scale factor set on the @font_face. Defaults to zero. * See hb_cairo_font_face_set_scale_factor() for details. * * Returns: the scale factor of @font_face * * Since: 7.0.0
*/ unsignedint
hb_cairo_font_face_get_scale_factor (cairo_font_face_t *font_face)
{ return (unsignedint) (uintptr_t)
cairo_font_face_get_user_data (font_face,
&hb_cairo_scale_factor_user_data_key);
}
/** * hb_cairo_glyphs_from_buffer: * @buffer: a #hb_buffer_t containing glyphs * @utf8_clusters: `true` if @buffer clusters are in bytes, instead of characters * @x_scale_factor: scale factor to divide #hb_position_t Y values by * @y_scale_factor: scale factor to divide #hb_position_t X values by * @x: X position to place first glyph * @y: Y position to place first glyph * @utf8: (nullable): the text that was shaped in @buffer * @utf8_len: the length of @utf8 in bytes * @glyphs: (out): return location for an array of #cairo_glyph_t * @num_glyphs: (inout): return location for the length of @glyphs * @clusters: (out) (nullable): return location for an array of cluster positions * @num_clusters: (inout) (nullable): return location for the length of @clusters * @cluster_flags: (out) (nullable): return location for cluster flags * * Extracts information from @buffer in a form that can be * passed to cairo_show_text_glyphs() or cairo_show_glyphs(). * This API is modeled after cairo_scaled_font_text_to_glyphs() and * cairo_user_scaled_font_text_to_glyphs_func_t. * * The @num_glyphs argument should be preset to the number of glyph entries available * in the @glyphs buffer. If the @glyphs buffer is `NULL`, the value of * @num_glyphs must be zero. If the provided glyph array is too short for * the conversion (or for convenience), a new glyph array may be allocated * using cairo_glyph_allocate() and placed in @glyphs. Upon return, * @num_glyphs should contain the number of generated glyphs. If the value * @glyphs points at has changed after the call, the caller will free the * allocated glyph array using cairo_glyph_free(). The caller will also free * the original value of @glyphs, so this function shouldn't do so. * * If @clusters is not `NULL`, then @num_clusters and @cluster_flags * should not be either, and @utf8 must be provided, and cluster * mapping will be computed. The semantics of how * cluster array allocation works is similar to the glyph array. That is, * if @clusters initially points to a non-`NULL` value, that array may be used * as a cluster buffer, and @num_clusters points to the number of cluster * entries available there. If the provided cluster array is too short for * the conversion (or for convenience), a new cluster array may be allocated * using cairo_text_cluster_allocate() and placed in @clusters. In this case, * the original value of @clusters will still be freed by the caller. Upon * return, @num_clusters will contain the number of generated clusters. * If the value @clusters points at has changed after the call, the caller * will free the allocated cluster array using cairo_text_cluster_free(). * * See hb_cairo_font_face_set_scale_factor() for the details of * the @scale_factor argument. * * The returned @glyphs vector actually has `@num_glyphs + 1` entries in * it and the x,y values of the extra entry at the end add up the advance * x,y of all the glyphs in the @buffer. * * Since: 7.0.0
*/ void
hb_cairo_glyphs_from_buffer (hb_buffer_t *buffer,
hb_bool_t utf8_clusters, double x_scale_factor, double y_scale_factor, double x, double y, constchar *utf8, int utf8_len,
cairo_glyph_t **glyphs, unsignedint *num_glyphs,
cairo_text_cluster_t **clusters, unsignedint *num_clusters,
cairo_text_cluster_flags_t *cluster_flags)
{ if (utf8 && utf8_len < 0)
utf8_len = strlen (utf8);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.