2009-08-02 01:54:49 +02:00
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
* Copyright © 2009 Red Hat, Inc.
|
2012-07-26 23:34:25 +02:00
|
|
|
* Copyright © 2012 Google, Inc.
|
2009-08-02 01:54:49 +02:00
|
|
|
*
|
2010-04-22 06:11:43 +02:00
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
2009-08-02 01:54:49 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Red Hat Author(s): Behdad Esfahbod
|
2012-07-26 23:34:25 +02:00
|
|
|
* Google Author(s): Behdad Esfahbod
|
2009-08-02 01:54:49 +02:00
|
|
|
*/
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb.hh"
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-font.hh"
|
2022-02-05 22:01:15 +01:00
|
|
|
#include "hb-draw.hh"
|
2022-12-14 12:22:00 +01:00
|
|
|
#include "hb-paint.hh"
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-machinery.hh"
|
2009-11-04 02:27:05 +01:00
|
|
|
|
2018-10-09 21:39:51 +02:00
|
|
|
#include "hb-ot.h"
|
|
|
|
|
2019-08-14 16:12:51 +02:00
|
|
|
#include "hb-ot-var-avar-table.hh"
|
|
|
|
#include "hb-ot-var-fvar-table.hh"
|
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
2018-10-27 13:07:33 +02:00
|
|
|
/**
|
|
|
|
* SECTION:hb-font
|
2018-10-27 13:50:38 +02:00
|
|
|
* @title: hb-font
|
2018-10-27 13:28:40 +02:00
|
|
|
* @short_description: Font objects
|
2018-10-27 13:07:33 +02:00
|
|
|
* @include: hb.h
|
|
|
|
*
|
2019-04-17 15:44:25 +02:00
|
|
|
* Functions for working with font objects.
|
|
|
|
*
|
|
|
|
* A font object represents a font face at a specific size and with
|
2019-04-22 16:31:24 +02:00
|
|
|
* certain other parameters (pixels-per-em, points-per-em, variation
|
2019-04-17 15:44:25 +02:00
|
|
|
* settings) specified. Font objects are created from font face
|
|
|
|
* objects, and are used as input to hb_shape(), among other things.
|
2019-04-22 16:31:24 +02:00
|
|
|
*
|
|
|
|
* Client programs can optionally pass in their own functions that
|
|
|
|
* implement the basic, lower-level queries of font objects. This set
|
|
|
|
* of font functions is defined by the virtual methods in
|
|
|
|
* #hb_font_funcs_t.
|
|
|
|
*
|
|
|
|
* HarfBuzz provides a built-in set of lightweight default
|
|
|
|
* functions for each method in #hb_font_funcs_t.
|
2018-10-27 13:07:33 +02:00
|
|
|
**/
|
|
|
|
|
|
|
|
|
2009-08-02 01:54:49 +02:00
|
|
|
/*
|
2009-08-11 02:05:16 +02:00
|
|
|
* hb_font_funcs_t
|
2009-08-02 01:54:49 +02:00
|
|
|
*/
|
|
|
|
|
2015-10-26 08:23:22 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_font_h_extents_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
2018-10-31 22:22:31 +01:00
|
|
|
hb_font_extents_t *extents,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-10-26 08:23:22 +01:00
|
|
|
{
|
2022-11-22 20:50:36 +01:00
|
|
|
hb_memset (extents, 0, sizeof (*extents));
|
2015-10-26 08:23:22 +01:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-10-26 08:23:22 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_font_h_extents_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
2018-10-31 22:22:31 +01:00
|
|
|
hb_font_extents_t *extents,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-10-26 08:23:22 +01:00
|
|
|
{
|
2018-10-31 22:22:31 +01:00
|
|
|
hb_bool_t ret = font->parent->get_font_h_extents (extents);
|
2015-10-26 08:23:22 +01:00
|
|
|
if (ret) {
|
2018-10-31 22:22:31 +01:00
|
|
|
extents->ascender = font->parent_scale_y_distance (extents->ascender);
|
|
|
|
extents->descender = font->parent_scale_y_distance (extents->descender);
|
|
|
|
extents->line_gap = font->parent_scale_y_distance (extents->line_gap);
|
2015-10-26 08:23:22 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_font_v_extents_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
2018-10-31 22:22:31 +01:00
|
|
|
hb_font_extents_t *extents,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-10-26 08:23:22 +01:00
|
|
|
{
|
2022-11-22 20:50:36 +01:00
|
|
|
hb_memset (extents, 0, sizeof (*extents));
|
2015-10-26 08:23:22 +01:00
|
|
|
return false;
|
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-10-26 08:23:22 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_font_v_extents_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
2018-10-31 22:22:31 +01:00
|
|
|
hb_font_extents_t *extents,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-10-26 08:23:22 +01:00
|
|
|
{
|
2018-10-31 22:22:31 +01:00
|
|
|
hb_bool_t ret = font->parent->get_font_v_extents (extents);
|
2015-10-26 08:23:22 +01:00
|
|
|
if (ret) {
|
2018-10-31 22:22:31 +01:00
|
|
|
extents->ascender = font->parent_scale_x_distance (extents->ascender);
|
|
|
|
extents->descender = font->parent_scale_x_distance (extents->descender);
|
|
|
|
extents->line_gap = font->parent_scale_x_distance (extents->line_gap);
|
2015-10-26 08:23:22 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-05-11 02:41:13 +02:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode HB_UNUSED,
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2016-02-24 11:05:23 +01:00
|
|
|
{
|
|
|
|
*glyph = 0;
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_nominal_glyph_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode,
|
2018-08-06 18:45:17 +02:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2016-02-24 11:05:23 +01:00
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
if (font->has_nominal_glyphs_func_set ())
|
2018-10-09 15:23:51 +02:00
|
|
|
{
|
|
|
|
return font->get_nominal_glyphs (1, &unicode, 0, glyph, 0);
|
|
|
|
}
|
2016-02-24 11:05:23 +01:00
|
|
|
return font->parent->get_nominal_glyph (unicode, glyph);
|
|
|
|
}
|
|
|
|
|
2018-10-09 15:23:51 +02:00
|
|
|
#define hb_font_get_nominal_glyphs_nil hb_font_get_nominal_glyphs_default
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2018-10-09 15:23:51 +02:00
|
|
|
static unsigned int
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_nominal_glyphs_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
unsigned int count,
|
2018-10-09 15:23:51 +02:00
|
|
|
const hb_codepoint_t *first_unicode,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned int unicode_stride,
|
|
|
|
hb_codepoint_t *first_glyph,
|
|
|
|
unsigned int glyph_stride,
|
|
|
|
void *user_data HB_UNUSED)
|
2018-10-09 15:23:51 +02:00
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
if (font->has_nominal_glyph_func_set ())
|
2018-10-09 15:23:51 +02:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (!font->get_nominal_glyph (*first_unicode, first_glyph))
|
2019-01-22 12:45:40 +01:00
|
|
|
return i;
|
2018-10-09 15:23:51 +02:00
|
|
|
|
2019-01-22 12:45:40 +01:00
|
|
|
first_unicode = &StructAtOffsetUnaligned<hb_codepoint_t> (first_unicode, unicode_stride);
|
|
|
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
2018-10-09 15:23:51 +02:00
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return font->parent->get_nominal_glyphs (count,
|
|
|
|
first_unicode, unicode_stride,
|
|
|
|
first_glyph, glyph_stride);
|
|
|
|
}
|
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode HB_UNUSED,
|
|
|
|
hb_codepoint_t variation_selector HB_UNUSED,
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
|
|
|
*glyph = 0;
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_variation_glyph_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t unicode,
|
|
|
|
hb_codepoint_t variation_selector,
|
2018-08-06 18:45:17 +02:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
2016-02-24 11:05:23 +01:00
|
|
|
return font->parent->get_variation_glyph (unicode, variation_selector, glyph);
|
2015-11-05 05:22:44 +01:00
|
|
|
}
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
|
2011-05-25 17:27:33 +02:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_advance_nil (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-11 02:49:02 +02:00
|
|
|
{
|
2011-05-25 17:27:33 +02:00
|
|
|
return font->x_scale;
|
2011-05-11 02:49:02 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_advance_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
if (font->has_glyph_h_advances_func_set ())
|
2018-09-30 11:27:39 +02:00
|
|
|
{
|
|
|
|
hb_position_t ret;
|
|
|
|
font->get_glyph_h_advances (1, &glyph, 0, &ret, 0);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-11-05 05:22:44 +01:00
|
|
|
return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph));
|
|
|
|
}
|
2009-11-04 02:27:05 +01:00
|
|
|
|
2011-05-25 17:27:33 +02:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_advance_nil (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-11 02:49:02 +02:00
|
|
|
{
|
2016-06-02 01:57:29 +02:00
|
|
|
/* TODO use font_extents.ascender+descender */
|
2011-05-25 17:27:33 +02:00
|
|
|
return font->y_scale;
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_advance_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
if (font->has_glyph_v_advances_func_set ())
|
2018-09-30 11:27:39 +02:00
|
|
|
{
|
|
|
|
hb_position_t ret;
|
|
|
|
font->get_glyph_v_advances (1, &glyph, 0, &ret, 0);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-11-05 05:22:44 +01:00
|
|
|
return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph));
|
|
|
|
}
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2018-08-07 18:37:52 +02:00
|
|
|
#define hb_font_get_glyph_h_advances_nil hb_font_get_glyph_h_advances_default
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2018-08-06 18:45:17 +02:00
|
|
|
static void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_advances_default (hb_font_t* font,
|
|
|
|
void* font_data HB_UNUSED,
|
|
|
|
unsigned int count,
|
2018-10-09 14:01:49 +02:00
|
|
|
const hb_codepoint_t *first_glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned int glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned int advance_stride,
|
|
|
|
void *user_data HB_UNUSED)
|
2018-08-06 18:45:17 +02:00
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
if (font->has_glyph_h_advance_func_set ())
|
2018-08-06 18:45:17 +02:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
*first_advance = font->get_glyph_h_advance (*first_glyph);
|
2019-01-22 12:45:40 +01:00
|
|
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
|
|
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
2018-08-06 18:45:17 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
font->parent->get_glyph_h_advances (count,
|
|
|
|
first_glyph, glyph_stride,
|
|
|
|
first_advance, advance_stride);
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
*first_advance = font->parent_scale_x_distance (*first_advance);
|
2019-01-22 12:45:40 +01:00
|
|
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
2018-08-06 18:45:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 18:37:52 +02:00
|
|
|
#define hb_font_get_glyph_v_advances_nil hb_font_get_glyph_v_advances_default
|
2018-08-06 18:45:17 +02:00
|
|
|
static void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_advances_default (hb_font_t* font,
|
|
|
|
void* font_data HB_UNUSED,
|
|
|
|
unsigned int count,
|
2018-10-09 14:01:49 +02:00
|
|
|
const hb_codepoint_t *first_glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned int glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned int advance_stride,
|
|
|
|
void *user_data HB_UNUSED)
|
2018-08-06 18:45:17 +02:00
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
if (font->has_glyph_v_advance_func_set ())
|
2018-08-06 18:45:17 +02:00
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
*first_advance = font->get_glyph_v_advance (*first_glyph);
|
2019-01-22 12:45:40 +01:00
|
|
|
first_glyph = &StructAtOffsetUnaligned<hb_codepoint_t> (first_glyph, glyph_stride);
|
|
|
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
2018-08-06 18:45:17 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
font->parent->get_glyph_v_advances (count,
|
|
|
|
first_glyph, glyph_stride,
|
|
|
|
first_advance, advance_stride);
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
*first_advance = font->parent_scale_y_distance (*first_advance);
|
2019-01-22 12:45:40 +01:00
|
|
|
first_advance = &StructAtOffsetUnaligned<hb_position_t> (first_advance, advance_stride);
|
2018-08-06 18:45:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-17 23:55:03 +02:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-17 23:55:03 +02:00
|
|
|
{
|
2011-05-18 05:27:22 +02:00
|
|
|
*x = *y = 0;
|
2015-11-27 00:43:15 +01:00
|
|
|
return true;
|
2011-05-17 23:55:03 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_origin_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y);
|
|
|
|
if (ret)
|
|
|
|
font->parent_scale_position (x, y);
|
|
|
|
return ret;
|
|
|
|
}
|
2011-05-17 23:55:03 +02:00
|
|
|
|
2011-05-17 00:15:37 +02:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2011-05-18 05:27:22 +02:00
|
|
|
*x = *y = 0;
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_origin_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y);
|
|
|
|
if (ret)
|
|
|
|
font->parent_scale_position (x, y);
|
|
|
|
return ret;
|
|
|
|
}
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2011-05-25 17:27:33 +02:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t left_glyph HB_UNUSED,
|
|
|
|
hb_codepoint_t right_glyph HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2011-05-25 17:27:33 +02:00
|
|
|
return 0;
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_kerning_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t left_glyph,
|
|
|
|
hb_codepoint_t right_glyph,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph));
|
|
|
|
}
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2019-06-17 23:02:47 +02:00
|
|
|
#ifndef HB_DISABLE_DEPRECATED
|
2011-05-25 17:27:33 +02:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t top_glyph HB_UNUSED,
|
|
|
|
hb_codepoint_t bottom_glyph HB_UNUSED,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2011-05-25 17:27:33 +02:00
|
|
|
return 0;
|
2011-05-11 02:49:02 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_kerning_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t top_glyph,
|
|
|
|
hb_codepoint_t bottom_glyph,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
|
|
|
|
}
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2009-11-04 02:27:05 +01:00
|
|
|
|
2011-05-17 00:15:37 +02:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
2011-05-11 06:24:34 +02:00
|
|
|
hb_glyph_extents_t *extents,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2011-05-11 02:49:02 +02:00
|
|
|
{
|
2022-11-22 20:50:36 +01:00
|
|
|
hb_memset (extents, 0, sizeof (*extents));
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2011-05-11 02:49:02 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_extents_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
2018-08-06 18:45:17 +02:00
|
|
|
hb_glyph_extents_t *extents,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents);
|
|
|
|
if (ret) {
|
|
|
|
font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
|
|
|
|
font->parent_scale_distance (&extents->width, &extents->height);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2010-10-27 07:13:56 +02:00
|
|
|
|
2011-05-17 00:15:37 +02:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
unsigned int point_index HB_UNUSED,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y,
|
|
|
|
void *user_data HB_UNUSED)
|
2011-05-11 02:49:02 +02:00
|
|
|
{
|
2011-05-17 00:15:37 +02:00
|
|
|
*x = *y = 0;
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2011-05-11 02:49:02 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_contour_point_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
unsigned int point_index,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y);
|
|
|
|
if (ret)
|
|
|
|
font->parent_scale_position (x, y);
|
|
|
|
return ret;
|
|
|
|
}
|
2009-11-04 02:27:05 +01:00
|
|
|
|
2012-05-27 17:29:21 +02:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_name_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
char *name,
|
|
|
|
unsigned int size,
|
|
|
|
void *user_data HB_UNUSED)
|
2012-05-27 17:29:21 +02:00
|
|
|
{
|
2012-08-08 04:13:25 +02:00
|
|
|
if (size) *name = '\0';
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2012-05-27 17:29:21 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_name_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
char *name,
|
|
|
|
unsigned int size,
|
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
return font->parent->get_glyph_name (glyph, name, size);
|
|
|
|
}
|
2012-05-27 17:29:21 +02:00
|
|
|
|
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_from_name_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
const char *name HB_UNUSED,
|
|
|
|
int len HB_UNUSED, /* -1 means nul-terminated */
|
2012-05-27 17:29:21 +02:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2012-05-27 17:29:21 +02:00
|
|
|
{
|
|
|
|
*glyph = 0;
|
2012-06-06 02:35:40 +02:00
|
|
|
return false;
|
2012-05-27 17:29:21 +02:00
|
|
|
}
|
2019-04-22 16:31:24 +02:00
|
|
|
|
2015-11-05 05:22:44 +01:00
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_from_name_default (hb_font_t *font,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
const char *name,
|
|
|
|
int len, /* -1 means nul-terminated */
|
2018-08-06 18:45:17 +02:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data HB_UNUSED)
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
|
|
|
return font->parent->get_glyph_from_name (name, len, glyph);
|
|
|
|
}
|
2012-05-27 17:29:21 +02:00
|
|
|
|
2022-02-03 08:14:47 +01:00
|
|
|
static void
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_draw_funcs_t *draw_funcs,
|
|
|
|
void *draw_data,
|
|
|
|
void *user_data HB_UNUSED)
|
2022-02-03 08:14:47 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-12-14 12:22:00 +01:00
|
|
|
static void
|
2022-12-19 19:45:45 +01:00
|
|
|
hb_font_paint_glyph_nil (hb_font_t *font HB_UNUSED,
|
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph HB_UNUSED,
|
|
|
|
hb_paint_funcs_t *paint_funcs HB_UNUSED,
|
|
|
|
void *paint_data HB_UNUSED,
|
2022-12-21 20:04:32 +01:00
|
|
|
unsigned int palette HB_UNUSED,
|
|
|
|
hb_color_t foreground HB_UNUSED,
|
2022-12-19 19:45:45 +01:00
|
|
|
void *user_data HB_UNUSED)
|
2022-12-14 12:22:00 +01:00
|
|
|
{
|
|
|
|
}
|
2022-02-05 22:01:15 +01:00
|
|
|
|
2022-12-19 19:53:49 +01:00
|
|
|
typedef struct hb_font_draw_glyph_default_adaptor_t {
|
2022-02-05 22:01:15 +01:00
|
|
|
hb_draw_funcs_t *draw_funcs;
|
|
|
|
void *draw_data;
|
|
|
|
float x_scale;
|
|
|
|
float y_scale;
|
2022-11-24 00:31:37 +01:00
|
|
|
float slant;
|
2022-12-19 19:53:49 +01:00
|
|
|
} hb_font_draw_glyph_default_adaptor_t;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
hb_draw_move_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED,
|
|
|
|
void *draw_data,
|
|
|
|
hb_draw_state_t *st,
|
|
|
|
float to_x, float to_y,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
2022-02-05 22:01:15 +01:00
|
|
|
float x_scale = adaptor->x_scale;
|
|
|
|
float y_scale = adaptor->y_scale;
|
2022-11-24 00:31:37 +01:00
|
|
|
float slant = adaptor->slant;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
|
|
|
adaptor->draw_funcs->emit_move_to (adaptor->draw_data, *st,
|
2022-11-24 00:31:37 +01:00
|
|
|
x_scale * to_x + slant * to_y, y_scale * to_y);
|
2022-02-05 22:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hb_draw_line_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
|
|
|
hb_draw_state_t *st,
|
|
|
|
float to_x, float to_y,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
2022-02-05 22:01:15 +01:00
|
|
|
float x_scale = adaptor->x_scale;
|
|
|
|
float y_scale = adaptor->y_scale;
|
2022-11-24 00:31:37 +01:00
|
|
|
float slant = adaptor->slant;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
2022-11-24 00:31:37 +01:00
|
|
|
st->current_x = st->current_x * x_scale + st->current_y * slant;
|
|
|
|
st->current_y = st->current_y * y_scale;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
|
|
|
adaptor->draw_funcs->emit_line_to (adaptor->draw_data, *st,
|
2022-11-24 00:31:37 +01:00
|
|
|
x_scale * to_x + slant * to_y, y_scale * to_y);
|
2022-02-05 22:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hb_draw_quadratic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
|
|
|
hb_draw_state_t *st,
|
|
|
|
float control_x, float control_y,
|
|
|
|
float to_x, float to_y,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
2022-02-05 22:01:15 +01:00
|
|
|
float x_scale = adaptor->x_scale;
|
|
|
|
float y_scale = adaptor->y_scale;
|
2022-11-24 00:31:37 +01:00
|
|
|
float slant = adaptor->slant;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
2022-11-24 00:31:37 +01:00
|
|
|
st->current_x = st->current_x * x_scale + st->current_y * slant;
|
|
|
|
st->current_y = st->current_y * y_scale;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
|
|
|
adaptor->draw_funcs->emit_quadratic_to (adaptor->draw_data, *st,
|
2022-11-24 00:31:37 +01:00
|
|
|
x_scale * control_x + slant * control_y, y_scale * control_y,
|
|
|
|
x_scale * to_x + slant * to_y, y_scale * to_y);
|
2022-02-05 22:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hb_draw_cubic_to_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
|
|
|
hb_draw_state_t *st,
|
|
|
|
float control1_x, float control1_y,
|
|
|
|
float control2_x, float control2_y,
|
|
|
|
float to_x, float to_y,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
2022-02-05 22:01:15 +01:00
|
|
|
float x_scale = adaptor->x_scale;
|
|
|
|
float y_scale = adaptor->y_scale;
|
2022-11-24 00:31:37 +01:00
|
|
|
float slant = adaptor->slant;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
2022-11-24 00:31:37 +01:00
|
|
|
st->current_x = st->current_x * x_scale + st->current_y * slant;
|
|
|
|
st->current_y = st->current_y * y_scale;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
|
|
|
adaptor->draw_funcs->emit_cubic_to (adaptor->draw_data, *st,
|
2022-11-24 00:31:37 +01:00
|
|
|
x_scale * control1_x + slant * control1_y, y_scale * control1_y,
|
|
|
|
x_scale * control2_x + slant * control2_y, y_scale * control2_y,
|
|
|
|
x_scale * to_x + slant * to_y, y_scale * to_y);
|
2022-02-05 22:01:15 +01:00
|
|
|
}
|
|
|
|
|
2022-02-03 08:14:47 +01:00
|
|
|
static void
|
2022-02-05 22:01:15 +01:00
|
|
|
hb_draw_close_path_default (hb_draw_funcs_t *dfuncs HB_UNUSED, void *draw_data,
|
|
|
|
hb_draw_state_t *st,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default_adaptor_t *adaptor = (hb_font_draw_glyph_default_adaptor_t *) draw_data;
|
2022-02-05 22:01:15 +01:00
|
|
|
|
|
|
|
adaptor->draw_funcs->emit_close_path (adaptor->draw_data, *st);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const hb_draw_funcs_t _hb_draw_funcs_default = {
|
|
|
|
HB_OBJECT_HEADER_STATIC,
|
|
|
|
|
|
|
|
{
|
|
|
|
#define HB_DRAW_FUNC_IMPLEMENT(name) hb_draw_##name##_default,
|
|
|
|
HB_DRAW_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_DRAW_FUNC_IMPLEMENT
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default (hb_font_t *font,
|
2022-02-03 08:14:47 +01:00
|
|
|
void *font_data HB_UNUSED,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_draw_funcs_t *draw_funcs,
|
|
|
|
void *draw_data,
|
|
|
|
void *user_data HB_UNUSED)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_font_draw_glyph_default_adaptor_t adaptor = {
|
2022-02-05 22:01:15 +01:00
|
|
|
draw_funcs,
|
|
|
|
draw_data,
|
2022-11-24 00:45:46 +01:00
|
|
|
font->parent->x_scale ? (float) font->x_scale / (float) font->parent->x_scale : 0.f,
|
|
|
|
font->parent->y_scale ? (float) font->y_scale / (float) font->parent->y_scale : 0.f,
|
|
|
|
font->parent->y_scale ? (font->slant - font->parent->slant) *
|
|
|
|
(float) font->x_scale / (float) font->parent->y_scale : 0.f
|
2022-02-05 22:01:15 +01:00
|
|
|
};
|
|
|
|
|
2022-12-19 19:53:49 +01:00
|
|
|
font->parent->draw_glyph (glyph,
|
2022-02-05 22:01:15 +01:00
|
|
|
const_cast<hb_draw_funcs_t *> (&_hb_draw_funcs_default),
|
|
|
|
&adaptor);
|
2022-02-03 08:14:47 +01:00
|
|
|
}
|
|
|
|
|
2022-12-14 12:22:00 +01:00
|
|
|
static void
|
2022-12-19 19:45:45 +01:00
|
|
|
hb_font_paint_glyph_default (hb_font_t *font,
|
|
|
|
void *font_data,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_paint_funcs_t *paint_funcs,
|
|
|
|
void *paint_data,
|
2022-12-21 20:04:32 +01:00
|
|
|
unsigned int palette,
|
|
|
|
hb_color_t foreground,
|
2022-12-19 19:45:45 +01:00
|
|
|
void *user_data)
|
2022-12-14 12:22:00 +01:00
|
|
|
{
|
2022-12-18 21:33:54 +01:00
|
|
|
paint_funcs->push_transform (paint_data,
|
|
|
|
font->parent->x_scale ? (float) font->x_scale / (float) font->parent->x_scale : 0.f,
|
|
|
|
font->parent->y_scale ? (font->slant - font->parent->slant) *
|
|
|
|
(float) font->x_scale / (float) font->parent->y_scale : 0.f,
|
|
|
|
0.f,
|
|
|
|
font->parent->y_scale ? (float) font->y_scale / (float) font->parent->y_scale : 0.f,
|
2022-12-21 22:43:19 +01:00
|
|
|
0.f, 0.f);
|
2022-12-18 21:33:54 +01:00
|
|
|
|
2022-12-21 20:04:32 +01:00
|
|
|
font->parent->paint_glyph (glyph, paint_funcs, paint_data, palette, foreground);
|
2022-12-18 21:33:54 +01:00
|
|
|
|
2022-12-21 22:43:19 +01:00
|
|
|
paint_funcs->pop_transform (paint_data);
|
2022-12-14 12:22:00 +01:00
|
|
|
}
|
|
|
|
|
2018-08-06 15:17:48 +02:00
|
|
|
DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
|
|
|
|
{
|
2011-04-22 00:24:02 +02:00
|
|
|
HB_OBJECT_HEADER_STATIC,
|
|
|
|
|
2022-06-01 16:44:07 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2010-05-24 18:46:21 +02:00
|
|
|
{
|
2015-11-20 09:43:49 +01:00
|
|
|
{
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) hb_font_##get_##name##_nil,
|
2015-11-20 09:43:49 +01:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
2011-05-17 00:15:37 +02:00
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
2015-11-20 09:43:49 +01:00
|
|
|
}
|
2010-05-24 18:46:21 +02:00
|
|
|
}
|
2009-08-02 01:54:49 +02:00
|
|
|
};
|
2018-08-06 15:17:48 +02:00
|
|
|
|
2018-08-06 18:45:17 +02:00
|
|
|
static const hb_font_funcs_t _hb_font_funcs_default = {
|
2015-11-05 05:22:44 +01:00
|
|
|
HB_OBJECT_HEADER_STATIC,
|
|
|
|
|
2022-06-01 16:44:07 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2015-11-05 05:22:44 +01:00
|
|
|
{
|
2015-11-20 09:43:49 +01:00
|
|
|
{
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) hb_font_##get_##name##_default,
|
2015-11-20 09:43:49 +01:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
2015-11-05 05:22:44 +01:00
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
2015-11-20 09:43:49 +01:00
|
|
|
}
|
2015-11-05 05:22:44 +01:00
|
|
|
}
|
|
|
|
};
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2011-05-05 01:27:37 +02:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
2022-06-05 08:55:35 +02:00
|
|
|
* hb_font_funcs_create:
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Creates a new #hb_font_funcs_t structure of font functions.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer full): The font-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_font_funcs_t *
|
2018-12-17 19:01:01 +01:00
|
|
|
hb_font_funcs_create ()
|
2009-08-02 01:54:49 +02:00
|
|
|
{
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_font_funcs_t *ffuncs;
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2011-04-27 22:38:03 +02:00
|
|
|
if (!(ffuncs = hb_object_create<hb_font_funcs_t> ()))
|
2012-06-05 18:31:51 +02:00
|
|
|
return hb_font_funcs_get_empty ();
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2018-08-06 18:45:17 +02:00
|
|
|
ffuncs->get = _hb_font_funcs_default.get;
|
2010-05-24 18:50:19 +02:00
|
|
|
|
2009-08-11 02:05:16 +02:00
|
|
|
return ffuncs;
|
2009-08-02 01:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_get_empty:
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches an empty font-functions structure.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer full): The font-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-12 00:14:44 +02:00
|
|
|
hb_font_funcs_t *
|
2018-12-17 19:01:01 +01:00
|
|
|
hb_font_funcs_get_empty ()
|
2011-05-12 00:14:44 +02:00
|
|
|
{
|
2018-08-06 18:45:17 +02:00
|
|
|
return const_cast<hb_font_funcs_t *> (&_hb_font_funcs_default);
|
2011-05-12 00:14:44 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_reference: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Increases the reference count on a font-functions structure.
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: The font-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_font_funcs_t *
|
|
|
|
hb_font_funcs_reference (hb_font_funcs_t *ffuncs)
|
2009-08-02 01:54:49 +02:00
|
|
|
{
|
2011-04-27 22:38:03 +02:00
|
|
|
return hb_object_reference (ffuncs);
|
2009-08-02 01:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_destroy: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Decreases the reference count on a font-functions structure. When
|
|
|
|
* the reference count reaches zero, the font-functions structure is
|
|
|
|
* destroyed, freeing all memory.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-02 01:54:49 +02:00
|
|
|
void
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_font_funcs_destroy (hb_font_funcs_t *ffuncs)
|
2009-08-02 01:54:49 +02:00
|
|
|
{
|
2011-04-27 22:38:03 +02:00
|
|
|
if (!hb_object_destroy (ffuncs)) return;
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2022-06-01 16:44:07 +02:00
|
|
|
if (ffuncs->destroy)
|
|
|
|
{
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) if (ffuncs->destroy->name) \
|
2022-06-01 16:44:07 +02:00
|
|
|
ffuncs->destroy->name (!ffuncs->user_data ? nullptr : ffuncs->user_data->name);
|
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
2011-05-17 00:15:37 +02:00
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
2022-06-01 16:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hb_free (ffuncs->destroy);
|
|
|
|
hb_free (ffuncs->user_data);
|
2011-05-11 02:41:13 +02:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (ffuncs);
|
2009-08-02 01:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_set_user_data: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
|
|
|
* @key: The user-data key to set
|
|
|
|
* @data: A pointer to the user data set
|
2020-12-30 23:19:29 +01:00
|
|
|
* @destroy: (nullable): A callback to call when @data is not needed anymore
|
2019-04-22 16:31:24 +02:00
|
|
|
* @replace: Whether to replace an existing data with the same key
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-01-02 17:28:28 +01:00
|
|
|
* Attaches a user-data key/data pair to the specified font-functions structure.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if success, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-28 03:46:01 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_font_funcs_set_user_data (hb_font_funcs_t *ffuncs,
|
|
|
|
hb_user_data_key_t *key,
|
|
|
|
void * data,
|
2019-04-22 16:31:24 +02:00
|
|
|
hb_destroy_func_t destroy /* May be NULL. */,
|
2011-08-09 00:43:24 +02:00
|
|
|
hb_bool_t replace)
|
2011-04-28 03:46:01 +02:00
|
|
|
{
|
2011-08-09 00:43:24 +02:00
|
|
|
return hb_object_set_user_data (ffuncs, key, data, destroy, replace);
|
2011-04-28 03:46:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_get_user_data: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
|
|
|
* @key: The user-data key to query
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the user data associated with the specified key,
|
|
|
|
* attached to the specified font-functions structure.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer none): A pointer to the user data
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-28 03:46:01 +02:00
|
|
|
void *
|
2022-07-25 18:45:55 +02:00
|
|
|
hb_font_funcs_get_user_data (const hb_font_funcs_t *ffuncs,
|
|
|
|
hb_user_data_key_t *key)
|
2011-04-28 03:46:01 +02:00
|
|
|
{
|
|
|
|
return hb_object_get_user_data (ffuncs, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_make_immutable:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Makes a font-functions structure immutable.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 05:50:51 +02:00
|
|
|
void
|
|
|
|
hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (ffuncs))
|
2018-09-26 21:03:07 +02:00
|
|
|
return;
|
2009-08-11 05:50:51 +02:00
|
|
|
|
2018-11-03 19:51:38 +01:00
|
|
|
hb_object_make_immutable (ffuncs);
|
2010-10-04 23:01:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_funcs_is_immutable:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Tests whether a font-functions structure is immutable.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if @ffuncs is immutable, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2010-10-04 23:01:01 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
return hb_object_is_immutable (ffuncs);
|
2009-08-11 05:50:51 +02:00
|
|
|
}
|
|
|
|
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2022-11-19 22:47:45 +01:00
|
|
|
static bool
|
2022-11-19 23:06:23 +01:00
|
|
|
_hb_font_funcs_set_preamble (hb_font_funcs_t *ffuncs,
|
|
|
|
bool func_is_null,
|
|
|
|
void **user_data,
|
|
|
|
hb_destroy_func_t *destroy)
|
2022-11-19 22:47:45 +01:00
|
|
|
{
|
|
|
|
if (hb_object_is_immutable (ffuncs))
|
|
|
|
{
|
|
|
|
if (*destroy)
|
|
|
|
(*destroy) (*user_data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (func_is_null)
|
|
|
|
{
|
|
|
|
if (*destroy)
|
|
|
|
(*destroy) (*user_data);
|
|
|
|
*destroy = nullptr;
|
|
|
|
*user_data = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2022-11-19 23:06:23 +01:00
|
|
|
_hb_font_funcs_set_middle (hb_font_funcs_t *ffuncs,
|
|
|
|
void *user_data,
|
|
|
|
hb_destroy_func_t destroy)
|
2022-11-19 22:47:45 +01:00
|
|
|
{
|
|
|
|
if (user_data && !ffuncs->user_data)
|
|
|
|
{
|
|
|
|
ffuncs->user_data = (decltype (ffuncs->user_data)) hb_calloc (1, sizeof (*ffuncs->user_data));
|
|
|
|
if (unlikely (!ffuncs->user_data))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (destroy && !ffuncs->destroy)
|
|
|
|
{
|
|
|
|
ffuncs->destroy = (decltype (ffuncs->destroy)) hb_calloc (1, sizeof (*ffuncs->destroy));
|
|
|
|
if (unlikely (!ffuncs->destroy))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (destroy)
|
|
|
|
(destroy) (user_data);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) \
|
2019-08-24 15:27:14 +02:00
|
|
|
\
|
2011-05-11 02:41:13 +02:00
|
|
|
void \
|
|
|
|
hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \
|
2022-12-19 19:45:45 +01:00
|
|
|
hb_font_##get_##name##_func_t func, \
|
2019-08-24 15:27:14 +02:00
|
|
|
void *user_data, \
|
|
|
|
hb_destroy_func_t destroy) \
|
2011-05-11 02:41:13 +02:00
|
|
|
{ \
|
2022-11-19 23:06:23 +01:00
|
|
|
if (!_hb_font_funcs_set_preamble (ffuncs, !func, &user_data, &destroy))\
|
2022-11-19 22:47:45 +01:00
|
|
|
return; \
|
2022-06-01 16:44:07 +02:00
|
|
|
\
|
|
|
|
if (ffuncs->destroy && ffuncs->destroy->name) \
|
|
|
|
ffuncs->destroy->name (!ffuncs->user_data ? nullptr : ffuncs->user_data->name); \
|
|
|
|
\
|
2022-11-19 23:06:23 +01:00
|
|
|
if (!_hb_font_funcs_set_middle (ffuncs, user_data, destroy)) \
|
2022-11-19 22:47:45 +01:00
|
|
|
return; \
|
2019-08-24 15:27:14 +02:00
|
|
|
\
|
2022-11-19 23:08:50 +01:00
|
|
|
if (func) \
|
2015-11-05 06:16:26 +01:00
|
|
|
ffuncs->get.f.name = func; \
|
2022-11-19 23:08:50 +01:00
|
|
|
else \
|
2022-12-19 19:45:45 +01:00
|
|
|
ffuncs->get.f.name = hb_font_##get_##name##_default; \
|
2022-11-19 23:08:50 +01:00
|
|
|
\
|
|
|
|
if (ffuncs->user_data) \
|
|
|
|
ffuncs->user_data->name = user_data; \
|
|
|
|
if (ffuncs->destroy) \
|
|
|
|
ffuncs->destroy->name = destroy; \
|
2009-11-04 02:27:05 +01:00
|
|
|
}
|
|
|
|
|
2011-05-17 00:15:37 +02:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
|
|
|
|
2018-10-20 04:12:33 +02:00
|
|
|
bool
|
|
|
|
hb_font_t::has_func_set (unsigned int i)
|
|
|
|
{
|
|
|
|
return this->klass->get.array[i] != _hb_font_funcs_default.get.array[i];
|
|
|
|
}
|
|
|
|
|
2015-11-05 06:42:55 +01:00
|
|
|
bool
|
|
|
|
hb_font_t::has_func (unsigned int i)
|
|
|
|
{
|
2018-10-20 04:12:33 +02:00
|
|
|
return has_func_set (i) ||
|
2018-08-06 18:45:17 +02:00
|
|
|
(parent && parent != &_hb_Null_hb_font_t && parent->has_func (i));
|
2015-11-05 06:42:55 +01:00
|
|
|
}
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2012-08-02 01:03:46 +02:00
|
|
|
/* Public getters */
|
|
|
|
|
2015-10-26 08:23:22 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_h_extents:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @extents: (out): The font extents retrieved
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2020-12-30 22:34:17 +01:00
|
|
|
* Fetches the extents for a specified font, for horizontal
|
2019-04-22 16:31:24 +02:00
|
|
|
* text segments.
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2015-12-16 17:08:36 +01:00
|
|
|
* Since: 1.1.3
|
2015-10-26 08:23:22 +01:00
|
|
|
**/
|
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_h_extents (hb_font_t *font,
|
2015-10-26 08:23:22 +01:00
|
|
|
hb_font_extents_t *extents)
|
|
|
|
{
|
|
|
|
return font->get_font_h_extents (extents);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_get_v_extents:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @extents: (out): The font extents retrieved
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2020-12-30 22:34:17 +01:00
|
|
|
* Fetches the extents for a specified font, for vertical
|
2019-04-22 16:31:24 +02:00
|
|
|
* text segments.
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2015-12-16 17:08:36 +01:00
|
|
|
* Since: 1.1.3
|
2015-10-26 08:23:22 +01:00
|
|
|
**/
|
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_v_extents (hb_font_t *font,
|
2015-10-26 08:23:22 +01:00
|
|
|
hb_font_extents_t *extents)
|
|
|
|
{
|
|
|
|
return font->get_font_v_extents (extents);
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @unicode: The Unicode code point to query
|
2020-12-30 23:27:49 +01:00
|
|
|
* @variation_selector: A variation-selector code point
|
2019-04-22 16:31:24 +02:00
|
|
|
* @glyph: (out): The glyph ID retrieved
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the glyph ID for a Unicode code point in the specified
|
|
|
|
* font, with an optional variation selector.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* If @variation_selector is 0, calls hb_font_get_nominal_glyph();
|
|
|
|
* otherwise calls hb_font_get_variation_glyph().
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-17 00:15:37 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph (hb_font_t *font,
|
|
|
|
hb_codepoint_t unicode,
|
|
|
|
hb_codepoint_t variation_selector,
|
2011-05-17 00:15:37 +02:00
|
|
|
hb_codepoint_t *glyph)
|
|
|
|
{
|
2016-02-24 11:05:23 +01:00
|
|
|
if (unlikely (variation_selector))
|
|
|
|
return font->get_variation_glyph (unicode, variation_selector, glyph);
|
|
|
|
return font->get_nominal_glyph (unicode, glyph);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_get_nominal_glyph:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @unicode: The Unicode code point to query
|
|
|
|
* @glyph: (out): The glyph ID retrieved
|
2016-02-24 11:05:23 +01:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the nominal glyph ID for a Unicode code point in the
|
2022-01-02 17:28:28 +01:00
|
|
|
* specified font.
|
2016-02-24 11:05:23 +01:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* This version of the function should not be used to fetch glyph IDs
|
|
|
|
* for code points modified by variation selectors. For variation-selector
|
|
|
|
* support, user hb_font_get_variation_glyph() or use hb_font_get_glyph().
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2016-02-24 11:05:23 +01:00
|
|
|
*
|
|
|
|
* Since: 1.2.3
|
|
|
|
**/
|
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_nominal_glyph (hb_font_t *font,
|
|
|
|
hb_codepoint_t unicode,
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_codepoint_t *glyph)
|
|
|
|
{
|
|
|
|
return font->get_nominal_glyph (unicode, glyph);
|
|
|
|
}
|
|
|
|
|
2019-10-28 22:02:47 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_nominal_glyphs:
|
2020-12-30 22:34:17 +01:00
|
|
|
* @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
|
2019-10-28 22:02:47 +01:00
|
|
|
*
|
2020-12-30 22:34:17 +01:00
|
|
|
* Fetches the nominal glyph IDs for a sequence of Unicode code points. Glyph
|
2023-01-30 19:21:08 +01:00
|
|
|
* IDs must be returned in a #hb_codepoint_t output parameter. Stopes at the
|
|
|
|
* first unsupported glyph ID.
|
2019-10-28 22:02:47 +01:00
|
|
|
*
|
2020-12-30 22:34:17 +01:00
|
|
|
* Return value: the number of code points processed
|
2019-10-28 22:02:47 +01:00
|
|
|
*
|
2019-10-28 22:45:31 +01:00
|
|
|
* Since: 2.6.3
|
2019-10-28 22:02:47 +01:00
|
|
|
**/
|
|
|
|
unsigned int
|
|
|
|
hb_font_get_nominal_glyphs (hb_font_t *font,
|
|
|
|
unsigned int count,
|
|
|
|
const hb_codepoint_t *first_unicode,
|
|
|
|
unsigned int unicode_stride,
|
|
|
|
hb_codepoint_t *first_glyph,
|
|
|
|
unsigned int glyph_stride)
|
|
|
|
{
|
|
|
|
return font->get_nominal_glyphs (count,
|
|
|
|
first_unicode, unicode_stride,
|
|
|
|
first_glyph, glyph_stride);
|
|
|
|
}
|
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_variation_glyph:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @unicode: The Unicode code point to query
|
|
|
|
* @variation_selector: The variation-selector code point to query
|
|
|
|
* @glyph: (out): The glyph ID retrieved
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the glyph ID for a Unicode code point when followed by
|
|
|
|
* by the specified variation-selector code point, in the specified
|
|
|
|
* font.
|
2016-02-24 11:05:23 +01:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2016-02-24 11:05:23 +01:00
|
|
|
*
|
|
|
|
* Since: 1.2.3
|
|
|
|
**/
|
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_variation_glyph (hb_font_t *font,
|
|
|
|
hb_codepoint_t unicode,
|
|
|
|
hb_codepoint_t variation_selector,
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_codepoint_t *glyph)
|
|
|
|
{
|
|
|
|
return font->get_variation_glyph (unicode, variation_selector, glyph);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_h_advance:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the advance for a glyph ID in the specified font,
|
|
|
|
* for horizontal text segments.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: The advance of @glyph within @font
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-25 17:27:33 +02:00
|
|
|
hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_advance (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_h_advance (glyph);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_v_advance:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the advance for a glyph ID in the specified font,
|
|
|
|
* for vertical text segments.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: The advance of @glyph within @font
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-25 17:27:33 +02:00
|
|
|
hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_advance (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_v_advance (glyph);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
|
|
|
|
2018-08-07 18:47:00 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_h_advances:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @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
|
2020-12-30 22:34:17 +01:00
|
|
|
* @advance_stride: The stride between successive advances
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the advances for a sequence of glyph IDs in the specified
|
2022-01-02 17:28:28 +01:00
|
|
|
* font, for horizontal text segments.
|
2018-08-07 18:47:00 +02:00
|
|
|
*
|
2018-08-07 18:55:42 +02:00
|
|
|
* Since: 1.8.6
|
2018-08-07 18:47:00 +02:00
|
|
|
**/
|
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_advances (hb_font_t* font,
|
|
|
|
unsigned int count,
|
2018-10-09 14:01:49 +02:00
|
|
|
const hb_codepoint_t *first_glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned advance_stride)
|
2018-08-07 18:47:00 +02:00
|
|
|
{
|
|
|
|
font->get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_v_advances:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @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: (out): The stride between successive advances
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the advances for a sequence of glyph IDs in the specified
|
2022-01-02 17:28:28 +01:00
|
|
|
* font, for vertical text segments.
|
2018-08-07 18:47:00 +02:00
|
|
|
*
|
2018-08-07 18:55:42 +02:00
|
|
|
* Since: 1.8.6
|
2018-08-07 18:47:00 +02:00
|
|
|
**/
|
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_advances (hb_font_t* font,
|
|
|
|
unsigned int count,
|
2018-10-09 14:01:49 +02:00
|
|
|
const hb_codepoint_t *first_glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned advance_stride)
|
2018-08-07 18:47:00 +02:00
|
|
|
{
|
|
|
|
font->get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_h_origin:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @x: (out): The X coordinate of the origin
|
|
|
|
* @y: (out): The Y coordinate of the origin
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the (X,Y) coordinates of the origin for a glyph ID
|
|
|
|
* in the specified font, for horizontal text segments.
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-17 23:55:03 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_origin (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2011-05-17 23:55:03 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_h_origin (glyph, x, y);
|
2011-05-17 23:55:03 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_v_origin:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @x: (out): The X coordinate of the origin
|
|
|
|
* @y: (out): The Y coordinate of the origin
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the (X,Y) coordinates of the origin for a glyph ID
|
|
|
|
* in the specified font, for vertical text segments.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-17 00:15:37 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_origin (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_v_origin (glyph, x, y);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_h_kerning:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @left_glyph: The glyph ID of the left glyph in the glyph pair
|
|
|
|
* @right_glyph: The glyph ID of the right glyph in the glyph pair
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the kerning-adjustment value for a glyph-pair in
|
2020-12-30 22:34:17 +01:00
|
|
|
* the specified font, for horizontal text segments.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2020-12-24 21:34:02 +01:00
|
|
|
* <note>It handles legacy kerning only (as returned by the corresponding
|
|
|
|
* #hb_font_funcs_t function).</note>
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: The kerning adjustment value
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-25 17:27:33 +02:00
|
|
|
hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_h_kerning (hb_font_t *font,
|
|
|
|
hb_codepoint_t left_glyph,
|
|
|
|
hb_codepoint_t right_glyph)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_h_kerning (left_glyph, right_glyph);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2009-11-04 02:27:05 +01:00
|
|
|
|
2019-06-17 23:02:47 +02:00
|
|
|
#ifndef HB_DISABLE_DEPRECATED
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_v_kerning:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @top_glyph: The glyph ID of the top glyph in the glyph pair
|
|
|
|
* @bottom_glyph: The glyph ID of the bottom glyph in the glyph pair
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the kerning-adjustment value for a glyph-pair in
|
2020-12-30 22:34:17 +01:00
|
|
|
* the specified font, for vertical text segments.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2020-12-24 21:34:02 +01:00
|
|
|
* <note>It handles legacy kerning only (as returned by the corresponding
|
|
|
|
* #hb_font_funcs_t function).</note>
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: The kerning adjustment value
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2019-06-17 23:02:47 +02:00
|
|
|
* Deprecated: 2.0.0
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-25 17:27:33 +02:00
|
|
|
hb_position_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_v_kerning (hb_font_t *font,
|
|
|
|
hb_codepoint_t top_glyph,
|
|
|
|
hb_codepoint_t bottom_glyph)
|
2011-05-17 00:15:37 +02:00
|
|
|
{
|
2013-09-06 21:40:22 +02:00
|
|
|
return font->get_glyph_v_kerning (top_glyph, bottom_glyph);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2009-11-04 02:27:05 +01:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_extents:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @extents: (out): The #hb_glyph_extents_t retrieved
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the #hb_glyph_extents_t data for a glyph ID
|
|
|
|
* in the specified font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-17 00:15:37 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_extents (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
2011-05-17 00:15:37 +02:00
|
|
|
hb_glyph_extents_t *extents)
|
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_extents (glyph, extents);
|
2011-05-17 00:15:37 +02:00
|
|
|
}
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_contour_point:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @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
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the (x,y) coordinates of a specified contour-point index
|
|
|
|
* in the specified glyph, within the specified font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-11 02:41:13 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_contour_point (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
unsigned int point_index,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2009-11-05 19:55:41 +01:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_contour_point (glyph, point_index, x, y);
|
2009-11-05 19:55:41 +01:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_name:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @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
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the glyph-name string for a glyph ID in the specified @font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2023-01-25 02:24:27 +01:00
|
|
|
* According to the OpenType specification, glyph names are limited to 63
|
|
|
|
* characters and can only contain (a subset of) ASCII.
|
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2012-05-27 17:29:21 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_name (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
char *name,
|
|
|
|
unsigned int size)
|
2012-05-27 17:29:21 +02:00
|
|
|
{
|
2012-08-08 04:13:25 +02:00
|
|
|
return font->get_glyph_name (glyph, name, size);
|
2012-05-27 17:29:21 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_from_name:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @name: (array length=len): The name string to query
|
|
|
|
* @len: The length of the name queried
|
|
|
|
* @glyph: (out): The glyph ID retrieved
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the glyph ID that corresponds to a name string in the specified @font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* <note>Note: @len == -1 means the name string is null-terminated.</note>
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2012-05-27 17:29:21 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_from_name (hb_font_t *font,
|
|
|
|
const char *name,
|
|
|
|
int len, /* -1 means nul-terminated */
|
2012-05-27 17:29:21 +02:00
|
|
|
hb_codepoint_t *glyph)
|
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_from_name (name, len, glyph);
|
2012-05-27 17:29:21 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 08:14:47 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_shape:
|
|
|
|
* @font: #hb_font_t to work upon
|
2023-03-03 12:14:05 +01:00
|
|
|
* @glyph: The glyph ID
|
2022-02-08 01:38:00 +01:00
|
|
|
* @dfuncs: #hb_draw_funcs_t to draw to
|
|
|
|
* @draw_data: User data to pass to draw callbacks
|
2022-02-03 08:14:47 +01:00
|
|
|
*
|
|
|
|
* Fetches the glyph shape that corresponds to a glyph in the specified @font.
|
2022-12-15 06:32:11 +01:00
|
|
|
* The shape is returned by way of calls to the callbacks of the @dfuncs
|
2022-02-08 01:04:36 +01:00
|
|
|
* objects, with @draw_data passed to them.
|
2022-02-03 08:14:47 +01:00
|
|
|
*
|
2022-12-21 06:20:37 +01:00
|
|
|
* Since: 4.0.0
|
2023-02-11 22:44:58 +01:00
|
|
|
* Deprecated: 7.0.0: Use hb_font_draw_glyph() instead
|
2022-12-19 19:53:49 +01:00
|
|
|
*/
|
2022-02-03 08:14:47 +01:00
|
|
|
void
|
|
|
|
hb_font_get_glyph_shape (hb_font_t *font,
|
2022-12-19 19:53:49 +01:00
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_draw_funcs_t *dfuncs, void *draw_data)
|
|
|
|
{
|
|
|
|
hb_font_draw_glyph (font, glyph, dfuncs, draw_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_draw_glyph:
|
|
|
|
* @font: #hb_font_t to work upon
|
2023-03-03 12:14:05 +01:00
|
|
|
* @glyph: The glyph ID
|
2022-12-19 19:53:49 +01:00
|
|
|
* @dfuncs: #hb_draw_funcs_t to draw to
|
|
|
|
* @draw_data: User data to pass to draw callbacks
|
|
|
|
*
|
2022-12-21 06:20:37 +01:00
|
|
|
* Draws the outline that corresponds to a glyph in the specified @font.
|
|
|
|
*
|
|
|
|
* The outline is returned by way of calls to the callbacks of the @dfuncs
|
2022-12-19 19:53:49 +01:00
|
|
|
* objects, with @draw_data passed to them.
|
|
|
|
*
|
2023-02-11 22:44:58 +01:00
|
|
|
* Since: 7.0.0
|
2022-12-19 19:53:49 +01:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
hb_font_draw_glyph (hb_font_t *font,
|
2022-02-03 08:14:47 +01:00
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_draw_funcs_t *dfuncs, void *draw_data)
|
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
font->draw_glyph (glyph, dfuncs, draw_data);
|
2022-02-03 08:14:47 +01:00
|
|
|
}
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2022-12-17 16:02:30 +01:00
|
|
|
/**
|
|
|
|
* hb_font_paint_glyph:
|
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID
|
2022-12-18 21:46:32 +01:00
|
|
|
* @pfuncs: #hb_paint_funcs_t to paint with
|
2022-12-17 16:02:30 +01:00
|
|
|
* @paint_data: User data to pass to paint callbacks
|
2023-01-19 04:39:36 +01:00
|
|
|
* @palette_index: The index of the font's color palette to use
|
2022-12-23 06:18:40 +01:00
|
|
|
* @foreground: The foreground color, unpremultipled
|
2022-12-17 16:02:30 +01:00
|
|
|
*
|
|
|
|
* Paints the glyph.
|
|
|
|
*
|
2022-12-23 06:18:40 +01:00
|
|
|
* The painting instructions are returned by way of calls to
|
|
|
|
* the callbacks of the @funcs object, with @paint_data passed
|
|
|
|
* to them.
|
2022-12-17 16:02:30 +01:00
|
|
|
*
|
2022-12-23 06:18:40 +01:00
|
|
|
* If the font has color palettes (see hb_ot_color_has_palettes()),
|
2023-01-19 04:44:05 +01:00
|
|
|
* then @palette_index selects the palette to use. If the font only
|
2023-01-20 21:01:22 +01:00
|
|
|
* has one palette, this will be 0.
|
2022-12-18 08:43:25 +01:00
|
|
|
*
|
2023-02-11 22:44:58 +01:00
|
|
|
* Since: 7.0.0
|
2022-12-17 16:02:30 +01:00
|
|
|
*/
|
2022-12-14 12:22:00 +01:00
|
|
|
void
|
|
|
|
hb_font_paint_glyph (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
2022-12-21 20:04:32 +01:00
|
|
|
hb_paint_funcs_t *pfuncs, void *paint_data,
|
2023-01-19 04:39:36 +01:00
|
|
|
unsigned int palette_index,
|
2022-12-21 20:04:32 +01:00
|
|
|
hb_color_t foreground)
|
2022-12-14 12:22:00 +01:00
|
|
|
{
|
2023-01-19 04:39:36 +01:00
|
|
|
font->paint_glyph (glyph, pfuncs, paint_data, palette_index, foreground);
|
2022-12-14 12:22:00 +01:00
|
|
|
}
|
|
|
|
|
2011-05-17 00:15:37 +02:00
|
|
|
/* A bit higher-level, and with fallback */
|
|
|
|
|
2015-10-26 08:23:22 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_extents_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @direction: The direction of the text segment
|
2021-01-20 21:35:34 +01:00
|
|
|
* @extents: (out): The #hb_font_extents_t retrieved
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the extents for a font in a text segment of the
|
|
|
|
* specified direction.
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2015-10-26 08:23:22 +01:00
|
|
|
*
|
2015-12-16 17:08:36 +01:00
|
|
|
* Since: 1.1.3
|
2015-10-26 08:23:22 +01:00
|
|
|
**/
|
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_extents_for_direction (hb_font_t *font,
|
|
|
|
hb_direction_t direction,
|
2015-10-26 08:23:22 +01:00
|
|
|
hb_font_extents_t *extents)
|
|
|
|
{
|
2022-02-14 02:38:59 +01:00
|
|
|
font->get_extents_for_direction (direction, extents);
|
2015-10-26 08:23:22 +01:00
|
|
|
}
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_advance_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @direction: The direction of the text segment
|
|
|
|
* @x: (out): The horizontal advance retrieved
|
|
|
|
* @y: (out): The vertical advance retrieved
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the advance for a glyph ID from the specified font,
|
|
|
|
* in a text segment of the specified direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2010-10-27 07:13:56 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_advance_for_direction (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2010-10-27 07:13:56 +02:00
|
|
|
{
|
2022-02-14 02:38:59 +01:00
|
|
|
font->get_glyph_advance_for_direction (glyph, direction, x, y);
|
2011-05-20 01:08:57 +02:00
|
|
|
}
|
2018-08-07 18:52:06 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_advances_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @direction: The direction of the text segment
|
|
|
|
* @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: (out): The stride between successive advances
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the advances for a sequence of glyph IDs in the specified
|
|
|
|
* font, in a text segment of the specified direction.
|
2018-08-07 18:52:06 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2018-08-07 18:52:06 +02:00
|
|
|
*
|
2018-08-07 18:55:42 +02:00
|
|
|
* Since: 1.8.6
|
2018-08-07 18:52:06 +02:00
|
|
|
**/
|
|
|
|
HB_EXTERN void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_advances_for_direction (hb_font_t* font,
|
|
|
|
hb_direction_t direction,
|
|
|
|
unsigned int count,
|
2018-10-09 14:01:49 +02:00
|
|
|
const hb_codepoint_t *first_glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned advance_stride)
|
2018-08-07 18:52:06 +02:00
|
|
|
{
|
|
|
|
font->get_glyph_advances_for_direction (direction, count, first_glyph, glyph_stride, first_advance, advance_stride);
|
|
|
|
}
|
2011-05-20 01:08:57 +02:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_origin_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @direction: The direction of the text segment
|
|
|
|
* @x: (out): The X coordinate retrieved for the origin
|
|
|
|
* @y: (out): The Y coordinate retrieved for the origin
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the (X,Y) coordinates of the origin for a glyph in
|
|
|
|
* the specified font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2010-10-27 07:13:56 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_origin_for_direction (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2011-05-17 23:55:03 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_origin_for_direction (glyph, direction, x, y);
|
2011-05-17 23:55:03 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_add_glyph_origin_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @direction: The direction of the text segment
|
2022-01-02 17:28:28 +01:00
|
|
|
* @x: (inout): Input = The original X coordinate
|
2019-04-22 16:31:24 +02:00
|
|
|
* Output = The X coordinate plus the X-coordinate of the origin
|
|
|
|
* @y: (inout): Input = The original Y coordinate
|
|
|
|
* Output = The Y coordinate plus the Y-coordinate of the origin
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Adds the origin coordinates to an (X,Y) point coordinate, in
|
|
|
|
* the specified glyph ID in the specified font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-19 19:08:00 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_add_glyph_origin_for_direction (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2011-05-19 19:08:00 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->add_glyph_origin_for_direction (glyph, direction, x, y);
|
2011-05-19 19:08:00 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_subtract_glyph_origin_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @direction: The direction of the text segment
|
2022-01-02 17:28:28 +01:00
|
|
|
* @x: (inout): Input = The original X coordinate
|
2019-04-22 16:31:24 +02:00
|
|
|
* Output = The X coordinate minus the X-coordinate of the origin
|
|
|
|
* @y: (inout): Input = The original Y coordinate
|
|
|
|
* Output = The Y coordinate minus the Y-coordinate of the origin
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Subtracts the origin coordinates from an (X,Y) point coordinate,
|
|
|
|
* in the specified glyph ID in the specified font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-19 19:08:00 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_subtract_glyph_origin_for_direction (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2011-05-19 19:08:00 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->subtract_glyph_origin_for_direction (glyph, direction, x, y);
|
2011-05-19 19:08:00 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_kerning_for_direction:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @first_glyph: The glyph ID of the first glyph in the glyph pair to query
|
|
|
|
* @second_glyph: The glyph ID of the second glyph in the glyph pair to query
|
|
|
|
* @direction: The direction of the text segment
|
|
|
|
* @x: (out): The horizontal kerning-adjustment value retrieved
|
|
|
|
* @y: (out): The vertical kerning-adjustment value retrieved
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the kerning-adjustment value for a glyph-pair in the specified font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-17 23:55:03 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_kerning_for_direction (hb_font_t *font,
|
|
|
|
hb_codepoint_t first_glyph,
|
|
|
|
hb_codepoint_t second_glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2010-10-27 07:13:56 +02:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_kerning_for_direction (first_glyph, second_glyph, direction, x, y);
|
2010-10-27 07:13:56 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_extents_for_origin:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @direction: The direction of the text segment
|
|
|
|
* @extents: (out): The #hb_glyph_extents_t retrieved
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the #hb_glyph_extents_t data for a glyph ID
|
|
|
|
* in the specified font, with respect to the origin in
|
|
|
|
* a text segment in the specified direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-20 00:46:15 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_extents_for_origin (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
2011-05-20 00:46:15 +02:00
|
|
|
hb_glyph_extents_t *extents)
|
2009-11-05 19:55:41 +01:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_extents_for_origin (glyph, direction, extents);
|
2009-11-05 19:55:41 +01:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_glyph_contour_point_for_origin:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @point_index: The contour-point index to query
|
|
|
|
* @direction: The direction of the text segment
|
|
|
|
* @x: (out): The X value retrieved for the contour point
|
|
|
|
* @y: (out): The Y value retrieved for the contour point
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the (X,Y) coordinates of a specified contour-point index
|
|
|
|
* in the specified glyph ID in the specified font, with respect
|
|
|
|
* to the origin in a text segment in the specified direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Calls the appropriate direction-specific variant (horizontal
|
|
|
|
* or vertical) depending on the value of @direction.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-17 00:15:37 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_glyph_contour_point_for_origin (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
unsigned int point_index,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x,
|
|
|
|
hb_position_t *y)
|
2009-11-05 19:55:41 +01:00
|
|
|
{
|
2012-08-02 01:03:46 +02:00
|
|
|
return font->get_glyph_contour_point_for_origin (glyph, point_index, direction, x, y);
|
2009-11-05 19:55:41 +01:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_glyph_to_string:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @glyph: The glyph ID to query
|
|
|
|
* @s: (out) (array length=size): The string containing the glyph name
|
|
|
|
* @size: Length of string @s
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the name of the specified glyph ID in @font and returns
|
|
|
|
* it in string @s.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2020-12-24 21:34:02 +01:00
|
|
|
* If the glyph ID has no name in @font, a string of the form `gidDDD` is
|
|
|
|
* generated, with `DDD` being the glyph ID.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2023-01-25 02:34:04 +01:00
|
|
|
* According to the OpenType specification, glyph names are limited to 63
|
|
|
|
* characters and can only contain (a subset of) ASCII.
|
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2012-08-08 04:13:25 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_glyph_to_string (hb_font_t *font,
|
|
|
|
hb_codepoint_t glyph,
|
|
|
|
char *s,
|
|
|
|
unsigned int size)
|
2012-08-08 04:13:25 +02:00
|
|
|
{
|
|
|
|
font->glyph_to_string (glyph, s, size);
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_glyph_from_string:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @s: (array length=len) (element-type uint8_t): string to query
|
|
|
|
* @len: The length of the string @s
|
|
|
|
* @glyph: (out): The glyph ID corresponding to the string requested
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the glyph ID from @font that matches the specified string.
|
2020-12-24 21:34:02 +01:00
|
|
|
* Strings of the format `gidDDD` or `uniUUUU` are parsed automatically.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* <note>Note: @len == -1 means the string is null-terminated.</note>
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if data found, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2012-08-08 04:13:25 +02:00
|
|
|
hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_glyph_from_string (hb_font_t *font,
|
|
|
|
const char *s,
|
2020-12-24 21:34:02 +01:00
|
|
|
int len,
|
2012-08-08 04:13:25 +02:00
|
|
|
hb_codepoint_t *glyph)
|
|
|
|
{
|
|
|
|
return font->glyph_from_string (s, len, glyph);
|
|
|
|
}
|
|
|
|
|
2010-04-24 02:49:18 +02:00
|
|
|
|
2009-08-02 01:54:49 +02:00
|
|
|
/*
|
|
|
|
* hb_font_t
|
|
|
|
*/
|
|
|
|
|
2018-08-06 15:17:48 +02:00
|
|
|
DEFINE_NULL_INSTANCE (hb_font_t) =
|
|
|
|
{
|
|
|
|
HB_OBJECT_HEADER_STATIC,
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
0, /* serial */
|
2022-05-20 20:15:00 +02:00
|
|
|
0, /* serial_coords */
|
2022-05-20 20:03:32 +02:00
|
|
|
|
2018-08-06 15:17:48 +02:00
|
|
|
nullptr, /* parent */
|
|
|
|
const_cast<hb_face_t *> (&_hb_Null_hb_face_t),
|
|
|
|
|
|
|
|
1000, /* x_scale */
|
|
|
|
1000, /* y_scale */
|
2023-02-02 00:56:56 +01:00
|
|
|
0.f, /* x_embolden */
|
|
|
|
0.f, /* y_embolden */
|
2023-02-07 19:29:49 +01:00
|
|
|
true, /* embolden_in_place */
|
|
|
|
0, /* x_strength */
|
|
|
|
0, /* y_strength */
|
2023-02-02 00:56:56 +01:00
|
|
|
0.f, /* slant */
|
|
|
|
0.f, /* slant_xy; */
|
2022-06-27 19:28:44 +02:00
|
|
|
1.f, /* x_multf */
|
|
|
|
1.f, /* y_multf */
|
2019-07-05 22:52:09 +02:00
|
|
|
1<<16, /* x_mult */
|
|
|
|
1<<16, /* y_mult */
|
2018-08-06 15:17:48 +02:00
|
|
|
|
|
|
|
0, /* x_ppem */
|
|
|
|
0, /* y_ppem */
|
|
|
|
0, /* ptem */
|
|
|
|
|
2023-01-15 18:54:01 +01:00
|
|
|
HB_FONT_NO_VAR_NAMED_INSTANCE, /* instance_index */
|
2018-08-06 15:17:48 +02:00
|
|
|
0, /* num_coords */
|
|
|
|
nullptr, /* coords */
|
2019-08-14 16:12:51 +02:00
|
|
|
nullptr, /* design_coords */
|
2018-08-06 15:17:48 +02:00
|
|
|
|
2018-11-11 06:17:30 +01:00
|
|
|
const_cast<hb_font_funcs_t *> (&_hb_Null_hb_font_funcs_t),
|
2018-08-06 15:17:48 +02:00
|
|
|
|
2018-11-16 08:29:13 +01:00
|
|
|
/* Zero for the rest is fine. */
|
2018-08-06 15:17:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-10-09 21:39:51 +02:00
|
|
|
static hb_font_t *
|
|
|
|
_hb_font_create (hb_face_t *face)
|
2009-08-02 01:54:49 +02:00
|
|
|
{
|
|
|
|
hb_font_t *font;
|
|
|
|
|
2011-05-03 02:46:32 +02:00
|
|
|
if (unlikely (!face))
|
2012-06-05 18:31:51 +02:00
|
|
|
face = hb_face_get_empty ();
|
2022-07-20 22:57:32 +02:00
|
|
|
|
2011-04-27 22:38:03 +02:00
|
|
|
if (!(font = hb_object_create<hb_font_t> ()))
|
2012-06-05 18:31:51 +02:00
|
|
|
return hb_font_get_empty ();
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2011-05-12 23:48:20 +02:00
|
|
|
hb_face_make_immutable (face);
|
2015-11-05 05:22:44 +01:00
|
|
|
font->parent = hb_font_get_empty ();
|
2011-05-03 02:46:32 +02:00
|
|
|
font->face = hb_face_reference (face);
|
2012-06-05 18:31:51 +02:00
|
|
|
font->klass = hb_font_funcs_get_empty ();
|
2018-11-16 08:29:13 +01:00
|
|
|
font->data.init0 (font);
|
2022-06-27 19:28:44 +02:00
|
|
|
font->x_scale = font->y_scale = face->get_upem ();
|
2023-02-07 19:29:49 +01:00
|
|
|
font->embolden_in_place = true;
|
2022-06-27 19:28:44 +02:00
|
|
|
font->x_multf = font->y_multf = 1.f;
|
2019-07-05 22:52:09 +02:00
|
|
|
font->x_mult = font->y_mult = 1 << 16;
|
2023-01-15 18:54:01 +01:00
|
|
|
font->instance_index = HB_FONT_NO_VAR_NAMED_INSTANCE;
|
2015-10-02 15:38:20 +02:00
|
|
|
|
2009-08-02 01:54:49 +02:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2018-10-09 21:39:51 +02:00
|
|
|
/**
|
2022-06-05 08:55:35 +02:00
|
|
|
* hb_font_create:
|
2018-10-09 21:39:51 +02:00
|
|
|
* @face: a face.
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Constructs a new font object from the specified face.
|
2018-10-09 21:39:51 +02:00
|
|
|
*
|
2022-01-02 15:45:10 +01:00
|
|
|
* <note>Note: If @face's index value (as passed to hb_face_create()
|
|
|
|
* has non-zero top 16-bits, those bits minus one are passed to
|
|
|
|
* hb_font_set_var_named_instance(), effectively loading a named-instance
|
|
|
|
* of a variable font, instead of the default-instance. This allows
|
|
|
|
* specifying which named-instance to load by default when creating the
|
|
|
|
* face.</note>
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer full): The new font object
|
2018-10-09 21:39:51 +02:00
|
|
|
*
|
|
|
|
* Since: 0.9.2
|
|
|
|
**/
|
|
|
|
hb_font_t *
|
|
|
|
hb_font_create (hb_face_t *face)
|
|
|
|
{
|
|
|
|
hb_font_t *font = _hb_font_create (face);
|
|
|
|
|
2019-05-11 08:15:58 +02:00
|
|
|
#ifndef HB_NO_OT_FONT
|
2018-10-09 21:39:51 +02:00
|
|
|
/* Install our in-house, very lightweight, funcs. */
|
|
|
|
hb_ot_font_set_funcs (font);
|
2019-04-10 21:40:03 +02:00
|
|
|
#endif
|
2018-10-09 21:39:51 +02:00
|
|
|
|
2022-01-28 21:53:21 +01:00
|
|
|
#ifndef HB_NO_VAR
|
2022-01-02 15:45:10 +01:00
|
|
|
if (face && face->index >> 16)
|
|
|
|
hb_font_set_var_named_instance (font, (face->index >> 16) - 1);
|
2022-01-28 21:53:21 +01:00
|
|
|
#endif
|
2022-01-02 15:45:10 +01:00
|
|
|
|
2018-10-09 21:39:51 +02:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2019-08-14 16:12:51 +02:00
|
|
|
static void
|
|
|
|
_hb_font_adopt_var_coords (hb_font_t *font,
|
|
|
|
int *coords, /* 2.14 normalized */
|
|
|
|
float *design_coords,
|
|
|
|
unsigned int coords_length)
|
|
|
|
{
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (font->coords);
|
|
|
|
hb_free (font->design_coords);
|
2019-08-14 16:12:51 +02:00
|
|
|
|
|
|
|
font->coords = coords;
|
|
|
|
font->design_coords = design_coords;
|
|
|
|
font->num_coords = coords_length;
|
2022-06-28 21:46:04 +02:00
|
|
|
|
|
|
|
font->mults_changed (); // Easiest to call this to drop cached data
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_create_sub_font:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @parent: The parent font object
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Constructs a sub-font font object from the specified @parent font,
|
|
|
|
* replicating the parent's properties.
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer full): The new sub-font font object
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-11 02:02:49 +02:00
|
|
|
hb_font_t *
|
|
|
|
hb_font_create_sub_font (hb_font_t *parent)
|
|
|
|
{
|
|
|
|
if (unlikely (!parent))
|
2014-08-06 21:36:41 +02:00
|
|
|
parent = hb_font_get_empty ();
|
2011-05-11 02:02:49 +02:00
|
|
|
|
2018-10-09 21:39:51 +02:00
|
|
|
hb_font_t *font = _hb_font_create (parent->face);
|
2011-05-11 02:02:49 +02:00
|
|
|
|
2018-11-03 20:03:06 +01:00
|
|
|
if (unlikely (hb_object_is_immutable (font)))
|
2011-05-11 02:02:49 +02:00
|
|
|
return font;
|
|
|
|
|
|
|
|
font->parent = hb_font_reference (parent);
|
|
|
|
|
|
|
|
font->x_scale = parent->x_scale;
|
|
|
|
font->y_scale = parent->y_scale;
|
2023-02-02 00:56:56 +01:00
|
|
|
font->x_embolden = parent->x_embolden;
|
|
|
|
font->y_embolden = parent->y_embolden;
|
2023-02-07 19:29:49 +01:00
|
|
|
font->embolden_in_place = parent->embolden_in_place;
|
2021-12-18 23:12:26 +01:00
|
|
|
font->slant = parent->slant;
|
2011-05-11 02:02:49 +02:00
|
|
|
font->x_ppem = parent->x_ppem;
|
|
|
|
font->y_ppem = parent->y_ppem;
|
2017-10-11 11:47:47 +02:00
|
|
|
font->ptem = parent->ptem;
|
2011-05-11 02:02:49 +02:00
|
|
|
|
2019-08-14 16:12:51 +02:00
|
|
|
unsigned int num_coords = parent->num_coords;
|
|
|
|
if (num_coords)
|
2017-10-11 11:34:53 +02:00
|
|
|
{
|
2021-07-08 18:58:50 +02:00
|
|
|
int *coords = (int *) hb_calloc (num_coords, sizeof (parent->coords[0]));
|
|
|
|
float *design_coords = (float *) hb_calloc (num_coords, sizeof (parent->design_coords[0]));
|
2019-08-14 16:12:51 +02:00
|
|
|
if (likely (coords && design_coords))
|
|
|
|
{
|
2022-11-22 20:54:50 +01:00
|
|
|
hb_memcpy (coords, parent->coords, num_coords * sizeof (parent->coords[0]));
|
|
|
|
hb_memcpy (design_coords, parent->design_coords, num_coords * sizeof (parent->design_coords[0]));
|
2019-08-14 16:12:51 +02:00
|
|
|
_hb_font_adopt_var_coords (font, coords, design_coords, num_coords);
|
|
|
|
}
|
2017-10-11 11:34:53 +02:00
|
|
|
else
|
2019-08-14 16:12:51 +02:00
|
|
|
{
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (coords);
|
|
|
|
hb_free (design_coords);
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
2017-10-11 11:34:53 +02:00
|
|
|
}
|
2016-03-01 11:29:36 +01:00
|
|
|
|
2022-06-28 21:46:04 +02:00
|
|
|
font->mults_changed ();
|
|
|
|
|
2011-05-11 02:02:49 +02:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_empty:
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the empty font object.
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer full): The empty font object
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-12 00:14:44 +02:00
|
|
|
hb_font_t *
|
2018-12-17 19:01:01 +01:00
|
|
|
hb_font_get_empty ()
|
2011-05-12 00:14:44 +02:00
|
|
|
{
|
2020-04-20 11:42:45 +02:00
|
|
|
return const_cast<hb_font_t *> (&Null (hb_font_t));
|
2011-05-12 00:14:44 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_reference: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Increases the reference count on the given font object.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer full): The @font object
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-02 01:54:49 +02:00
|
|
|
hb_font_t *
|
|
|
|
hb_font_reference (hb_font_t *font)
|
|
|
|
{
|
2011-04-27 22:38:03 +02:00
|
|
|
return hb_object_reference (font);
|
2009-08-02 01:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_destroy: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Decreases the reference count on the given font object. When the
|
|
|
|
* reference count reaches zero, the font is destroyed,
|
|
|
|
* freeing all memory.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-02 01:54:49 +02:00
|
|
|
void
|
|
|
|
hb_font_destroy (hb_font_t *font)
|
|
|
|
{
|
2011-04-27 22:38:03 +02:00
|
|
|
if (!hb_object_destroy (font)) return;
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2018-11-16 08:29:13 +01:00
|
|
|
font->data.fini ();
|
2012-07-26 23:34:25 +02:00
|
|
|
|
|
|
|
if (font->destroy)
|
|
|
|
font->destroy (font->user_data);
|
|
|
|
|
2011-05-11 02:02:49 +02:00
|
|
|
hb_font_destroy (font->parent);
|
2011-05-03 02:46:32 +02:00
|
|
|
hb_face_destroy (font->face);
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_font_funcs_destroy (font->klass);
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (font->coords);
|
|
|
|
hb_free (font->design_coords);
|
2016-03-01 11:29:36 +01:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (font);
|
2009-08-02 01:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_user_data: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2022-01-02 17:28:28 +01:00
|
|
|
* @key: The user-data key
|
2019-04-22 16:31:24 +02:00
|
|
|
* @data: A pointer to the user data
|
2020-12-30 23:19:29 +01:00
|
|
|
* @destroy: (nullable): A callback to call when @data is not needed anymore
|
2019-04-22 16:31:24 +02:00
|
|
|
* @replace: Whether to replace an existing data with the same key
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-01-02 17:28:28 +01:00
|
|
|
* Attaches a user-data key/data pair to the specified font object.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if success, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-28 03:46:01 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_font_set_user_data (hb_font_t *font,
|
|
|
|
hb_user_data_key_t *key,
|
|
|
|
void * data,
|
2019-04-22 16:31:24 +02:00
|
|
|
hb_destroy_func_t destroy /* May be NULL. */,
|
2011-08-09 00:43:24 +02:00
|
|
|
hb_bool_t replace)
|
2011-04-28 03:46:01 +02:00
|
|
|
{
|
2022-05-20 20:18:43 +02:00
|
|
|
if (!hb_object_is_immutable (font))
|
|
|
|
font->serial++;
|
2022-05-20 20:03:32 +02:00
|
|
|
|
2011-08-09 00:43:24 +02:00
|
|
|
return hb_object_set_user_data (font, key, data, destroy, replace);
|
2011-04-28 03:46:01 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_user_data: (skip)
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @key: The user-data key to query
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the user-data object associated with the specified key,
|
|
|
|
* attached to the specified font object.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer none): Pointer to the user data
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-04-28 03:46:01 +02:00
|
|
|
void *
|
2022-07-25 18:45:55 +02:00
|
|
|
hb_font_get_user_data (const hb_font_t *font,
|
2011-04-28 03:46:01 +02:00
|
|
|
hb_user_data_key_t *key)
|
|
|
|
{
|
|
|
|
return hb_object_get_user_data (font, key);
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_make_immutable:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Makes @font immutable.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-11 01:39:32 +02:00
|
|
|
void
|
|
|
|
hb_font_make_immutable (hb_font_t *font)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2018-09-26 21:03:07 +02:00
|
|
|
return;
|
2011-05-11 01:39:32 +02:00
|
|
|
|
2015-10-02 15:21:29 +02:00
|
|
|
if (font->parent)
|
|
|
|
hb_font_make_immutable (font->parent);
|
|
|
|
|
2018-11-03 19:51:38 +01:00
|
|
|
hb_object_make_immutable (font);
|
2011-05-11 01:39:32 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_is_immutable:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Tests whether a font object is immutable.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-06-30 08:43:57 +02:00
|
|
|
* Return value: `true` if @font is immutable, `false` otherwise
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-11 01:39:32 +02:00
|
|
|
hb_bool_t
|
|
|
|
hb_font_is_immutable (hb_font_t *font)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
return hb_object_is_immutable (font);
|
2011-05-11 01:39:32 +02:00
|
|
|
}
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_serial:
|
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
*
|
|
|
|
* Returns the internal serial number of the font. The serial
|
|
|
|
* number is increased every time a setting on the font is
|
|
|
|
* changed, using a setter function.
|
|
|
|
*
|
|
|
|
* Return value: serial number
|
|
|
|
*
|
2022-06-29 07:46:21 +02:00
|
|
|
* Since: 4.4.0
|
2022-05-20 20:03:32 +02:00
|
|
|
**/
|
2022-05-20 20:15:00 +02:00
|
|
|
unsigned int
|
2022-05-20 20:03:32 +02:00
|
|
|
hb_font_get_serial (hb_font_t *font)
|
|
|
|
{
|
|
|
|
return font->serial;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_changed:
|
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
*
|
|
|
|
* Notifies the @font that underlying font data has changed.
|
|
|
|
* This has the effect of increasing the serial as returned
|
|
|
|
* by hb_font_get_serial(), which invalidates internal caches.
|
|
|
|
*
|
2022-06-29 07:46:21 +02:00
|
|
|
* Since: 4.4.0
|
2022-05-20 20:03:32 +02:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
hb_font_changed (hb_font_t *font)
|
|
|
|
{
|
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
|
|
|
font->mults_changed ();
|
|
|
|
}
|
|
|
|
|
2015-10-08 18:51:02 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_parent:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @parent: The parent font object to assign
|
2015-10-08 18:51:02 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Sets the parent font of @font.
|
2015-10-08 18:51:02 +02:00
|
|
|
*
|
|
|
|
* Since: 1.0.5
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
hb_font_set_parent (hb_font_t *font,
|
|
|
|
hb_font_t *parent)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2015-10-08 18:51:02 +02:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
if (parent == font->parent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
2015-10-08 18:51:02 +02:00
|
|
|
if (!parent)
|
|
|
|
parent = hb_font_get_empty ();
|
|
|
|
|
|
|
|
hb_font_t *old = font->parent;
|
|
|
|
|
|
|
|
font->parent = hb_font_reference (parent);
|
|
|
|
|
|
|
|
hb_font_destroy (old);
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_parent:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the parent font of @font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer none): The parent font object
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-11 02:02:49 +02:00
|
|
|
hb_font_t *
|
|
|
|
hb_font_get_parent (hb_font_t *font)
|
|
|
|
{
|
|
|
|
return font->parent;
|
|
|
|
}
|
2011-04-28 03:46:01 +02:00
|
|
|
|
2017-02-03 19:39:40 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_face:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @face: The #hb_face_t to assign
|
2017-02-03 19:39:40 +01:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Sets @face as the font-face value of @font.
|
2017-02-03 19:39:40 +01:00
|
|
|
*
|
|
|
|
* Since: 1.4.3
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
hb_font_set_face (hb_font_t *font,
|
|
|
|
hb_face_t *face)
|
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2017-02-03 19:39:40 +01:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
if (face == font->face)
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
2017-02-03 19:39:40 +01:00
|
|
|
if (unlikely (!face))
|
|
|
|
face = hb_face_get_empty ();
|
|
|
|
|
|
|
|
hb_face_t *old = font->face;
|
|
|
|
|
2019-07-05 22:45:15 +02:00
|
|
|
hb_face_make_immutable (face);
|
2017-02-03 19:39:40 +01:00
|
|
|
font->face = hb_face_reference (face);
|
2019-07-05 22:52:09 +02:00
|
|
|
font->mults_changed ();
|
2017-02-03 19:39:40 +01:00
|
|
|
|
|
|
|
hb_face_destroy (old);
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_face:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the face associated with the specified font object.
|
2019-08-14 16:19:57 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: (transfer none): The #hb_face_t value
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-05-03 02:46:32 +02:00
|
|
|
hb_face_t *
|
|
|
|
hb_font_get_face (hb_font_t *font)
|
|
|
|
{
|
|
|
|
return font->face;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_funcs:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2021-01-01 00:36:57 +01:00
|
|
|
* @klass: (closure font_data) (destroy destroy) (scope notified): The font-functions structure.
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font_data: Data to attach to @font
|
2020-12-30 23:19:29 +01:00
|
|
|
* @destroy: (nullable): The function to call when @font_data is not needed anymore
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Replaces the font-functions structure attached to a font, updating
|
|
|
|
* the font's user-data with @font-data and the @destroy callback.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-11 02:05:16 +02:00
|
|
|
void
|
2009-11-04 00:34:20 +01:00
|
|
|
hb_font_set_funcs (hb_font_t *font,
|
|
|
|
hb_font_funcs_t *klass,
|
2013-09-06 23:35:57 +02:00
|
|
|
void *font_data,
|
2019-04-22 16:31:24 +02:00
|
|
|
hb_destroy_func_t destroy /* May be NULL. */)
|
2009-08-02 23:41:36 +02:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
{
|
2011-09-21 22:49:33 +02:00
|
|
|
if (destroy)
|
2013-09-06 23:35:57 +02:00
|
|
|
destroy (font_data);
|
2009-08-11 02:05:16 +02:00
|
|
|
return;
|
2011-09-21 22:49:33 +02:00
|
|
|
}
|
2009-08-02 23:41:36 +02:00
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
font->serial++;
|
|
|
|
|
2009-11-04 00:34:20 +01:00
|
|
|
if (font->destroy)
|
|
|
|
font->destroy (font->user_data);
|
|
|
|
|
2009-12-20 16:25:18 +01:00
|
|
|
if (!klass)
|
2012-06-05 18:31:51 +02:00
|
|
|
klass = hb_font_funcs_get_empty ();
|
2009-12-20 16:25:18 +01:00
|
|
|
|
2009-08-11 02:05:16 +02:00
|
|
|
hb_font_funcs_reference (klass);
|
|
|
|
hb_font_funcs_destroy (font->klass);
|
|
|
|
font->klass = klass;
|
2013-09-06 23:35:57 +02:00
|
|
|
font->user_data = font_data;
|
2011-04-20 09:03:32 +02:00
|
|
|
font->destroy = destroy;
|
2009-08-02 23:41:36 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_funcs_data:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @font_data: (destroy destroy) (scope notified): Data to attach to @font
|
2020-12-30 23:19:29 +01:00
|
|
|
* @destroy: (nullable): The function to call when @font_data is not needed anymore
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-01-02 17:28:28 +01:00
|
|
|
* Replaces the user data attached to a font, updating the font's
|
2019-04-22 16:31:24 +02:00
|
|
|
* @destroy callback.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-06-01 13:22:01 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2011-08-17 19:21:44 +02:00
|
|
|
void
|
|
|
|
hb_font_set_funcs_data (hb_font_t *font,
|
2019-04-22 16:31:24 +02:00
|
|
|
void *font_data,
|
|
|
|
hb_destroy_func_t destroy /* May be NULL. */)
|
2011-08-17 19:21:44 +02:00
|
|
|
{
|
2011-09-21 22:49:33 +02:00
|
|
|
/* Destroy user_data? */
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
{
|
2011-09-21 22:49:33 +02:00
|
|
|
if (destroy)
|
2013-09-06 23:35:57 +02:00
|
|
|
destroy (font_data);
|
2011-08-17 19:21:44 +02:00
|
|
|
return;
|
2011-09-21 22:49:33 +02:00
|
|
|
}
|
2011-08-17 19:21:44 +02:00
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
font->serial++;
|
|
|
|
|
2011-08-17 19:21:44 +02:00
|
|
|
if (font->destroy)
|
|
|
|
font->destroy (font->user_data);
|
|
|
|
|
2013-09-06 23:35:57 +02:00
|
|
|
font->user_data = font_data;
|
2011-08-17 19:21:44 +02:00
|
|
|
font->destroy = destroy;
|
|
|
|
}
|
|
|
|
|
2010-10-04 22:45:21 +02:00
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_scale:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @x_scale: Horizontal scale value to assign
|
|
|
|
* @y_scale: Vertical scale value to assign
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Sets the horizontal and vertical scale of a font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2023-01-10 20:53:54 +01:00
|
|
|
* The font scale is a number related to, but not the same as,
|
|
|
|
* font size. Typically the client establishes a scale factor
|
|
|
|
* to be used between the two. For example, 64, or 256, which
|
|
|
|
* would be the fractional-precision part of the font scale.
|
|
|
|
* This is necessary because #hb_position_t values are integer
|
|
|
|
* types and you need to leave room for fractional values
|
|
|
|
* in there.
|
|
|
|
*
|
2023-01-10 21:09:30 +01:00
|
|
|
* For example, to set the font size to 20, with 64
|
|
|
|
* levels of fractional precision you would call
|
|
|
|
* `hb_font_set_scale(font, 20 * 64, 20 * 64)`.
|
|
|
|
*
|
|
|
|
* In the example above, even what font size 20 means is up to
|
|
|
|
* you. It might be 20 pixels, or 20 points, or 20 millimeters.
|
|
|
|
* HarfBuzz does not care about that. You can set the point
|
|
|
|
* size of the font using hb_font_set_ptem(), and the pixel
|
|
|
|
* size using hb_font_set_ppem().
|
|
|
|
*
|
|
|
|
* The choice of scale is yours but needs to be consistent between
|
2023-01-10 20:53:54 +01:00
|
|
|
* what you set here, and what you expect out of #hb_position_t
|
|
|
|
* as well has draw / paint API output values.
|
|
|
|
*
|
2023-01-10 20:55:17 +01:00
|
|
|
* Fonts default to a scale equal to the UPEM value of their face.
|
2023-01-10 20:56:02 +01:00
|
|
|
* A font with this setting is sometimes called an "unscaled" font.
|
2023-01-10 20:55:17 +01:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-02 01:54:49 +02:00
|
|
|
void
|
|
|
|
hb_font_set_scale (hb_font_t *font,
|
2019-04-17 15:44:25 +02:00
|
|
|
int x_scale,
|
|
|
|
int y_scale)
|
2009-08-02 01:54:49 +02:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2009-08-02 01:54:49 +02:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
if (font->x_scale == x_scale && font->y_scale == y_scale)
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
2009-08-02 01:54:49 +02:00
|
|
|
font->x_scale = x_scale;
|
|
|
|
font->y_scale = y_scale;
|
2019-07-05 22:52:09 +02:00
|
|
|
font->mults_changed ();
|
2009-08-02 01:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_scale:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @x_scale: (out): Horizontal scale value
|
|
|
|
* @y_scale: (out): Vertical scale value
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the horizontal and vertical scale of a font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2010-10-04 22:45:21 +02:00
|
|
|
void
|
|
|
|
hb_font_get_scale (hb_font_t *font,
|
2019-04-17 15:44:25 +02:00
|
|
|
int *x_scale,
|
|
|
|
int *y_scale)
|
2010-10-04 22:45:21 +02:00
|
|
|
{
|
|
|
|
if (x_scale) *x_scale = font->x_scale;
|
|
|
|
if (y_scale) *y_scale = font->y_scale;
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_ppem:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @x_ppem: Horizontal ppem value to assign
|
|
|
|
* @y_ppem: Vertical ppem value to assign
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2023-01-10 22:32:08 +01:00
|
|
|
* Sets the horizontal and vertical pixels-per-em (PPEM) of a font.
|
|
|
|
*
|
|
|
|
* These values are used for pixel-size-specific adjustment to
|
|
|
|
* shaping and draw results, though for the most part they are
|
|
|
|
* unused and can be left unset.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2009-08-02 01:54:49 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_set_ppem (hb_font_t *font,
|
|
|
|
unsigned int x_ppem,
|
|
|
|
unsigned int y_ppem)
|
2009-08-02 01:54:49 +02:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2009-08-02 01:54:49 +02:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
if (font->x_ppem == x_ppem && font->y_ppem == y_ppem)
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
2009-08-02 01:54:49 +02:00
|
|
|
font->x_ppem = x_ppem;
|
|
|
|
font->y_ppem = y_ppem;
|
|
|
|
}
|
|
|
|
|
2013-09-06 21:40:22 +02:00
|
|
|
/**
|
|
|
|
* hb_font_get_ppem:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @x_ppem: (out): Horizontal ppem value
|
|
|
|
* @y_ppem: (out): Vertical ppem value
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2022-01-02 17:28:28 +01:00
|
|
|
* Fetches the horizontal and vertical points-per-em (ppem) of a font.
|
2013-09-06 21:40:22 +02:00
|
|
|
*
|
2015-09-03 12:25:59 +02:00
|
|
|
* Since: 0.9.2
|
2013-09-06 21:40:22 +02:00
|
|
|
**/
|
2010-10-04 22:45:21 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_ppem (hb_font_t *font,
|
2010-10-04 22:45:21 +02:00
|
|
|
unsigned int *x_ppem,
|
|
|
|
unsigned int *y_ppem)
|
|
|
|
{
|
|
|
|
if (x_ppem) *x_ppem = font->x_ppem;
|
|
|
|
if (y_ppem) *y_ppem = font->y_ppem;
|
|
|
|
}
|
2016-02-24 11:05:23 +01:00
|
|
|
|
2017-10-11 11:47:47 +02:00
|
|
|
/**
|
|
|
|
* hb_font_set_ptem:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2018-09-24 16:43:06 +02:00
|
|
|
* @ptem: font size in points.
|
2017-10-11 11:47:47 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Sets the "point size" of a font. Set to zero to unset.
|
|
|
|
* Used in CoreText to implement optical sizing.
|
2018-09-24 16:43:06 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* <note>Note: There are 72 points in an inch.</note>
|
2017-10-11 11:47:47 +02:00
|
|
|
*
|
|
|
|
* Since: 1.6.0
|
|
|
|
**/
|
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_set_ptem (hb_font_t *font,
|
|
|
|
float ptem)
|
2017-10-11 11:47:47 +02:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2017-10-11 11:47:47 +02:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
if (font->ptem == ptem)
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
2017-10-11 11:47:47 +02:00
|
|
|
font->ptem = ptem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_get_ptem:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2017-10-11 11:47:47 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Fetches the "point size" of a font. Used in CoreText to
|
|
|
|
* implement optical sizing.
|
2017-10-11 11:47:47 +02:00
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* Return value: Point size. A value of zero means "not set."
|
2017-10-11 11:47:47 +02:00
|
|
|
*
|
2021-12-18 23:12:26 +01:00
|
|
|
* Since: 1.6.0
|
2017-10-11 11:47:47 +02:00
|
|
|
**/
|
|
|
|
float
|
|
|
|
hb_font_get_ptem (hb_font_t *font)
|
|
|
|
{
|
|
|
|
return font->ptem;
|
|
|
|
}
|
|
|
|
|
2023-02-02 08:15:02 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_synthetic_bold:
|
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @x_embolden: the amount to embolden horizontally
|
|
|
|
* @y_embolden: the amount to embolden vertically
|
2023-02-07 19:29:49 +01:00
|
|
|
* @in_place: whether to embolden glyphs in-place
|
2023-02-02 08:15:02 +01:00
|
|
|
*
|
|
|
|
* Sets the "synthetic boldness" of a font.
|
|
|
|
*
|
2023-02-07 19:29:49 +01:00
|
|
|
* Positive values for @x_embolden / @y_embolden make a font
|
|
|
|
* bolder, negative values thinner. Typical values are in the
|
|
|
|
* 0.01 to 0.05 range. The default value is zero.
|
2023-02-02 08:15:02 +01:00
|
|
|
*
|
|
|
|
* Synthetic boldness is applied by offsetting the contour
|
|
|
|
* points of the glyph shape.
|
|
|
|
*
|
2023-02-07 19:29:49 +01:00
|
|
|
* Synthetic boldness is applied when rendering a glyph via
|
|
|
|
* hb_font_draw_glyph().
|
|
|
|
*
|
2023-02-11 22:44:58 +01:00
|
|
|
* If @in_place is `false`, then glyph advance-widths are also
|
2023-02-09 01:45:59 +01:00
|
|
|
* adjusted, otherwise they are not. The in-place mode is
|
|
|
|
* useful for simulating [font grading](https://fonts.google.com/knowledge/glossary/grade).
|
|
|
|
*
|
2023-02-02 08:15:02 +01:00
|
|
|
*
|
2023-02-11 22:44:58 +01:00
|
|
|
* Since: 7.0.0
|
2023-02-02 08:15:02 +01:00
|
|
|
**/
|
2023-02-02 00:56:56 +01:00
|
|
|
void
|
2023-02-07 19:29:49 +01:00
|
|
|
hb_font_set_synthetic_bold (hb_font_t *font,
|
|
|
|
float x_embolden,
|
|
|
|
float y_embolden,
|
|
|
|
hb_bool_t in_place)
|
2023-02-02 00:56:56 +01:00
|
|
|
{
|
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (font->x_embolden == x_embolden &&
|
2023-02-07 19:29:49 +01:00
|
|
|
font->y_embolden == y_embolden &&
|
2023-02-16 23:03:50 +01:00
|
|
|
font->embolden_in_place == (bool) in_place)
|
2023-02-02 00:56:56 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
|
|
|
font->x_embolden = x_embolden;
|
|
|
|
font->y_embolden = y_embolden;
|
2023-02-07 19:29:49 +01:00
|
|
|
font->embolden_in_place = in_place;
|
2023-02-02 00:56:56 +01:00
|
|
|
font->mults_changed ();
|
|
|
|
}
|
|
|
|
|
2023-02-02 08:15:02 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_synthetic_bold:
|
|
|
|
* @font: #hb_font_t to work upon
|
2023-02-07 19:29:49 +01:00
|
|
|
* @x_embolden: (out): return location for horizontal value
|
|
|
|
* @y_embolden: (out): return location for vertical value
|
|
|
|
* @in_place: (out): return location for in-place value
|
2023-02-02 08:15:02 +01:00
|
|
|
*
|
2023-02-07 19:29:49 +01:00
|
|
|
* Fetches the "synthetic boldness" parameters of a font.
|
2023-02-02 08:15:02 +01:00
|
|
|
*
|
2023-02-11 22:44:58 +01:00
|
|
|
* Since: 7.0.0
|
2023-02-02 08:15:02 +01:00
|
|
|
**/
|
2023-02-02 00:56:56 +01:00
|
|
|
void
|
2023-02-07 19:29:49 +01:00
|
|
|
hb_font_get_synthetic_bold (hb_font_t *font,
|
|
|
|
float *x_embolden,
|
|
|
|
float *y_embolden,
|
|
|
|
hb_bool_t *in_place)
|
2023-02-02 00:56:56 +01:00
|
|
|
{
|
|
|
|
if (x_embolden) *x_embolden = font->x_embolden;
|
|
|
|
if (y_embolden) *y_embolden = font->y_embolden;
|
2023-02-07 19:29:49 +01:00
|
|
|
if (in_place) *in_place = font->embolden_in_place;
|
2023-02-02 00:56:56 +01:00
|
|
|
}
|
|
|
|
|
2021-12-18 23:12:26 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_synthetic_slant:
|
|
|
|
* @font: #hb_font_t to work upon
|
2022-01-13 00:29:22 +01:00
|
|
|
* @slant: synthetic slant value.
|
2021-12-18 23:12:26 +01:00
|
|
|
*
|
2022-01-02 19:50:02 +01:00
|
|
|
* Sets the "synthetic slant" of a font. By default is zero.
|
2022-02-08 01:02:37 +01:00
|
|
|
* Synthetic slant is the graphical skew applied to the font
|
|
|
|
* at rendering time.
|
2021-12-18 23:12:26 +01:00
|
|
|
*
|
2022-01-02 19:50:02 +01:00
|
|
|
* HarfBuzz needs to know this value to adjust shaping results,
|
|
|
|
* metrics, and style values to match the slanted rendering.
|
|
|
|
*
|
2022-12-19 19:53:49 +01:00
|
|
|
* <note>Note: The glyph shape fetched via the hb_font_draw_glyph()
|
|
|
|
* function is slanted to reflect this value as well.</note>
|
2022-02-08 01:02:37 +01:00
|
|
|
*
|
2022-01-02 19:50:02 +01:00
|
|
|
* <note>Note: The slant value is a ratio. For example, a
|
|
|
|
* 20% slant would be represented as a 0.2 value.</note>
|
2021-12-18 23:12:26 +01:00
|
|
|
*
|
2022-01-31 17:12:01 +01:00
|
|
|
* Since: 3.3.0
|
2021-12-18 23:12:26 +01:00
|
|
|
**/
|
|
|
|
HB_EXTERN void
|
|
|
|
hb_font_set_synthetic_slant (hb_font_t *font, float slant)
|
|
|
|
{
|
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
return;
|
|
|
|
|
2022-05-20 20:03:32 +02:00
|
|
|
if (font->slant == slant)
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial++;
|
|
|
|
|
2021-12-18 23:12:26 +01:00
|
|
|
font->slant = slant;
|
|
|
|
font->mults_changed ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_get_synthetic_slant:
|
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
*
|
2022-01-02 19:50:02 +01:00
|
|
|
* Fetches the "synthetic slant" of a font.
|
2021-12-18 23:12:26 +01:00
|
|
|
*
|
2022-01-02 19:50:02 +01:00
|
|
|
* Return value: Synthetic slant. By default is zero.
|
2021-12-18 23:12:26 +01:00
|
|
|
*
|
2022-01-31 17:12:01 +01:00
|
|
|
* Since: 3.3.0
|
2021-12-18 23:12:26 +01:00
|
|
|
**/
|
|
|
|
HB_EXTERN float
|
|
|
|
hb_font_get_synthetic_slant (hb_font_t *font)
|
|
|
|
{
|
|
|
|
return font->slant;
|
|
|
|
}
|
|
|
|
|
2019-08-14 20:07:00 +02:00
|
|
|
#ifndef HB_NO_VAR
|
2017-01-22 00:05:00 +01:00
|
|
|
/*
|
|
|
|
* Variations
|
|
|
|
*/
|
|
|
|
|
2017-01-23 02:42:33 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_variations:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @variations: (array length=variations_length): Array of variation settings to apply
|
|
|
|
* @variations_length: Number of variations to apply
|
|
|
|
*
|
|
|
|
* Applies a list of font-variation settings to a font.
|
2017-01-23 02:42:33 +01:00
|
|
|
*
|
2022-01-12 19:08:02 +01:00
|
|
|
* Note that this overrides all existing variations set on @font.
|
|
|
|
* Axes not included in @variations will be effectively set to their
|
|
|
|
* default values.
|
|
|
|
*
|
2017-01-23 02:42:33 +01:00
|
|
|
* Since: 1.4.2
|
|
|
|
*/
|
2017-01-22 00:21:50 +01:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_set_variations (hb_font_t *font,
|
2017-01-22 02:41:37 +01:00
|
|
|
const hb_variation_t *variations,
|
2019-04-17 15:44:25 +02:00
|
|
|
unsigned int variations_length)
|
2017-01-22 00:21:50 +01:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2017-01-22 00:21:50 +01:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:15:00 +02:00
|
|
|
font->serial_coords = ++font->serial;
|
2022-05-20 20:03:32 +02:00
|
|
|
|
2023-01-15 18:54:01 +01:00
|
|
|
if (!variations_length && font->instance_index == HB_FONT_NO_VAR_NAMED_INSTANCE)
|
2017-01-22 00:21:50 +01:00
|
|
|
{
|
2017-10-15 12:11:08 +02:00
|
|
|
hb_font_set_var_coords_normalized (font, nullptr, 0);
|
2017-01-22 00:21:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-23 01:49:56 +02:00
|
|
|
const OT::fvar &fvar = *font->face->table.fvar;
|
|
|
|
auto axes = fvar.get_axes ();
|
|
|
|
const unsigned coords_length = axes.length;
|
2017-01-22 00:21:50 +01:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr;
|
|
|
|
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
2019-08-14 16:12:51 +02:00
|
|
|
|
|
|
|
if (unlikely (coords_length && !(normalized && design_coords)))
|
|
|
|
{
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (normalized);
|
|
|
|
hb_free (design_coords);
|
2017-01-22 00:36:35 +01:00
|
|
|
return;
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
|
|
|
|
2023-01-15 18:44:04 +01:00
|
|
|
/* Initialize design coords. */
|
2023-01-15 18:58:15 +01:00
|
|
|
for (unsigned int i = 0; i < coords_length; i++)
|
|
|
|
design_coords[i] = axes[i].get_default ();
|
|
|
|
if (font->instance_index != HB_FONT_NO_VAR_NAMED_INSTANCE)
|
2023-01-15 18:44:04 +01:00
|
|
|
{
|
|
|
|
unsigned count = coords_length;
|
2023-01-15 18:58:15 +01:00
|
|
|
/* This may fail if index is out-of-range;
|
|
|
|
* That's why we initialize design_coords from fvar above
|
|
|
|
* unconditionally. */
|
2023-01-15 18:44:04 +01:00
|
|
|
hb_ot_var_named_instance_get_design_coords (font->face, font->instance_index,
|
|
|
|
&count, design_coords);
|
|
|
|
}
|
2022-07-23 21:25:40 +02:00
|
|
|
|
2019-08-14 16:12:51 +02:00
|
|
|
for (unsigned int i = 0; i < variations_length; i++)
|
|
|
|
{
|
2021-07-23 01:49:56 +02:00
|
|
|
const auto tag = variations[i].tag;
|
|
|
|
const auto v = variations[i].value;
|
|
|
|
for (unsigned axis_index = 0; axis_index < coords_length; axis_index++)
|
|
|
|
if (axes[axis_index].axisTag == tag)
|
|
|
|
design_coords[axis_index] = v;
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
2019-08-20 12:45:22 +02:00
|
|
|
font->face->table.avar->map_coords (normalized, coords_length);
|
2017-01-22 00:21:50 +01:00
|
|
|
|
2023-01-15 18:44:04 +01:00
|
|
|
hb_ot_var_normalize_coords (font->face, coords_length, design_coords, normalized);
|
2019-08-14 16:12:51 +02:00
|
|
|
_hb_font_adopt_var_coords (font, normalized, design_coords, coords_length);
|
2017-01-22 00:21:50 +01:00
|
|
|
}
|
2019-07-27 11:03:46 +02:00
|
|
|
|
2023-02-28 20:07:48 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_variation:
|
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @tag: The #hb_tag_t tag of the variation-axis name
|
|
|
|
* @value: The value of the variation axis
|
|
|
|
*
|
|
|
|
* Change the value of one variation axis on the font.
|
|
|
|
*
|
|
|
|
* Note: This function is expensive to be called repeatedly.
|
2023-03-01 02:16:39 +01:00
|
|
|
* If you want to set multiple variation axes at the same time,
|
2023-02-28 20:07:48 +01:00
|
|
|
* use hb_font_set_variations() instead.
|
|
|
|
*
|
2023-03-03 00:01:49 +01:00
|
|
|
* Since: 7.1.0
|
2023-02-28 20:07:48 +01:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
hb_font_set_variation (hb_font_t *font,
|
|
|
|
hb_tag_t tag,
|
|
|
|
float value)
|
|
|
|
{
|
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
return;
|
|
|
|
|
|
|
|
font->serial_coords = ++font->serial;
|
|
|
|
|
|
|
|
// TODO Share some of this code with set_variations()
|
|
|
|
|
|
|
|
const OT::fvar &fvar = *font->face->table.fvar;
|
|
|
|
auto axes = fvar.get_axes ();
|
|
|
|
const unsigned coords_length = axes.length;
|
|
|
|
|
|
|
|
int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr;
|
|
|
|
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
|
|
|
|
|
|
|
if (unlikely (coords_length && !(normalized && design_coords)))
|
|
|
|
{
|
|
|
|
hb_free (normalized);
|
|
|
|
hb_free (design_coords);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize design coords. */
|
2023-02-28 22:49:44 +01:00
|
|
|
if (font->design_coords)
|
2023-02-28 20:07:48 +01:00
|
|
|
{
|
2023-02-28 22:49:44 +01:00
|
|
|
assert (coords_length == font->num_coords);
|
|
|
|
for (unsigned int i = 0; i < coords_length; i++)
|
|
|
|
design_coords[i] = font->design_coords[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < coords_length; i++)
|
|
|
|
design_coords[i] = axes[i].get_default ();
|
|
|
|
if (font->instance_index != HB_FONT_NO_VAR_NAMED_INSTANCE)
|
|
|
|
{
|
|
|
|
unsigned count = coords_length;
|
|
|
|
/* This may fail if index is out-of-range;
|
|
|
|
* That's why we initialize design_coords from fvar above
|
|
|
|
* unconditionally. */
|
|
|
|
hb_ot_var_named_instance_get_design_coords (font->face, font->instance_index,
|
|
|
|
&count, design_coords);
|
|
|
|
}
|
2023-02-28 20:07:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned axis_index = 0; axis_index < coords_length; axis_index++)
|
|
|
|
if (axes[axis_index].axisTag == tag)
|
|
|
|
design_coords[axis_index] = value;
|
|
|
|
|
|
|
|
font->face->table.avar->map_coords (normalized, coords_length);
|
|
|
|
|
|
|
|
hb_ot_var_normalize_coords (font->face, coords_length, design_coords, normalized);
|
|
|
|
_hb_font_adopt_var_coords (font, normalized, design_coords, coords_length);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-23 02:42:33 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_var_coords_design:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @coords: (array length=coords_length): Array of variation coordinates to apply
|
|
|
|
* @coords_length: Number of coordinates to apply
|
|
|
|
*
|
|
|
|
* Applies a list of variation coordinates (in design-space units)
|
|
|
|
* to a font.
|
2017-01-23 02:42:33 +01:00
|
|
|
*
|
2022-01-12 19:08:02 +01:00
|
|
|
* Note that this overrides all existing variations set on @font.
|
|
|
|
* Axes not included in @coords will be effectively set to their
|
|
|
|
* default values.
|
|
|
|
*
|
2017-01-23 02:42:33 +01:00
|
|
|
* Since: 1.4.2
|
|
|
|
*/
|
2017-01-22 00:05:00 +01:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_set_var_coords_design (hb_font_t *font,
|
|
|
|
const float *coords,
|
|
|
|
unsigned int coords_length)
|
2017-01-22 00:05:00 +01:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2017-01-22 00:21:50 +01:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:15:00 +02:00
|
|
|
font->serial_coords = ++font->serial;
|
2022-05-20 20:03:32 +02:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
int *normalized = coords_length ? (int *) hb_calloc (coords_length, sizeof (int)) : nullptr;
|
|
|
|
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (float)) : nullptr;
|
2019-08-14 16:12:51 +02:00
|
|
|
|
|
|
|
if (unlikely (coords_length && !(normalized && design_coords)))
|
|
|
|
{
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (normalized);
|
|
|
|
hb_free (design_coords);
|
2017-01-22 00:36:35 +01:00
|
|
|
return;
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (coords_length)
|
2022-11-22 20:54:50 +01:00
|
|
|
hb_memcpy (design_coords, coords, coords_length * sizeof (font->design_coords[0]));
|
2017-01-22 00:05:00 +01:00
|
|
|
|
2017-01-23 03:52:00 +01:00
|
|
|
hb_ot_var_normalize_coords (font->face, coords_length, coords, normalized);
|
2019-08-14 16:12:51 +02:00
|
|
|
_hb_font_adopt_var_coords (font, normalized, design_coords, coords_length);
|
2017-01-22 00:05:00 +01:00
|
|
|
}
|
2019-07-27 11:03:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_set_var_named_instance:
|
|
|
|
* @font: a font.
|
|
|
|
* @instance_index: named instance index.
|
|
|
|
*
|
2023-01-15 18:54:01 +01:00
|
|
|
* Sets design coords of a font from a named-instance index.
|
2019-07-27 11:03:46 +02:00
|
|
|
*
|
2019-08-14 07:20:54 +02:00
|
|
|
* Since: 2.6.0
|
2019-07-27 11:03:46 +02:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
hb_font_set_var_named_instance (hb_font_t *font,
|
2023-01-15 18:54:01 +01:00
|
|
|
unsigned int instance_index)
|
2019-07-27 11:03:46 +02:00
|
|
|
{
|
|
|
|
if (hb_object_is_immutable (font))
|
|
|
|
return;
|
|
|
|
|
2023-01-15 18:44:04 +01:00
|
|
|
if (font->instance_index == instance_index)
|
2019-07-27 11:03:46 +02:00
|
|
|
return;
|
|
|
|
|
2023-01-15 18:44:04 +01:00
|
|
|
font->serial_coords = ++font->serial;
|
|
|
|
|
|
|
|
font->instance_index = instance_index;
|
|
|
|
hb_font_set_variations (font, nullptr, 0);
|
2019-07-27 11:03:46 +02:00
|
|
|
}
|
2016-02-24 11:05:23 +01:00
|
|
|
|
2023-01-15 18:54:01 +01:00
|
|
|
/**
|
|
|
|
* hb_font_get_var_named_instance:
|
|
|
|
* @font: a font.
|
|
|
|
*
|
|
|
|
* Returns the currently-set named-instance index of the font.
|
|
|
|
*
|
|
|
|
* Return value: Named-instance index or %HB_FONT_NO_VAR_NAMED_INSTANCE.
|
|
|
|
*
|
2023-02-11 22:44:58 +01:00
|
|
|
* Since: 7.0.0
|
2023-01-15 18:54:01 +01:00
|
|
|
**/
|
|
|
|
unsigned int
|
|
|
|
hb_font_get_var_named_instance (hb_font_t *font)
|
|
|
|
{
|
|
|
|
return font->instance_index;
|
|
|
|
}
|
|
|
|
|
2017-01-23 02:42:33 +01:00
|
|
|
/**
|
|
|
|
* hb_font_set_var_coords_normalized:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
|
|
|
* @coords: (array length=coords_length): Array of variation coordinates to apply
|
|
|
|
* @coords_length: Number of coordinates to apply
|
|
|
|
*
|
|
|
|
* Applies a list of variation coordinates (in normalized units)
|
|
|
|
* to a font.
|
|
|
|
*
|
2022-01-12 19:08:02 +01:00
|
|
|
* Note that this overrides all existing variations set on @font.
|
|
|
|
* Axes not included in @coords will be effectively set to their
|
|
|
|
* default values.
|
|
|
|
*
|
2019-04-22 16:31:24 +02:00
|
|
|
* <note>Note: Coordinates should be normalized to 2.14.</note>
|
2017-01-23 02:42:33 +01:00
|
|
|
*
|
|
|
|
* Since: 1.4.2
|
|
|
|
*/
|
2016-09-10 07:23:34 +02:00
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_set_var_coords_normalized (hb_font_t *font,
|
|
|
|
const int *coords, /* 2.14 normalized */
|
|
|
|
unsigned int coords_length)
|
2016-09-10 07:23:34 +02:00
|
|
|
{
|
2018-11-03 19:51:38 +01:00
|
|
|
if (hb_object_is_immutable (font))
|
2016-09-10 07:23:34 +02:00
|
|
|
return;
|
|
|
|
|
2022-05-20 20:15:00 +02:00
|
|
|
font->serial_coords = ++font->serial;
|
2022-05-20 20:03:32 +02:00
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
int *copy = coords_length ? (int *) hb_calloc (coords_length, sizeof (coords[0])) : nullptr;
|
|
|
|
int *unmapped = coords_length ? (int *) hb_calloc (coords_length, sizeof (coords[0])) : nullptr;
|
|
|
|
float *design_coords = coords_length ? (float *) hb_calloc (coords_length, sizeof (design_coords[0])) : nullptr;
|
2019-08-14 16:12:51 +02:00
|
|
|
|
|
|
|
if (unlikely (coords_length && !(copy && unmapped && design_coords)))
|
|
|
|
{
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (copy);
|
|
|
|
hb_free (unmapped);
|
|
|
|
hb_free (design_coords);
|
2016-09-10 07:23:34 +02:00
|
|
|
return;
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
2016-09-10 07:23:34 +02:00
|
|
|
|
2016-09-10 10:58:27 +02:00
|
|
|
if (coords_length)
|
2019-08-14 16:12:51 +02:00
|
|
|
{
|
2022-11-22 20:54:50 +01:00
|
|
|
hb_memcpy (copy, coords, coords_length * sizeof (coords[0]));
|
|
|
|
hb_memcpy (unmapped, coords, coords_length * sizeof (coords[0]));
|
2019-08-14 16:12:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Best effort design coords simulation */
|
|
|
|
font->face->table.avar->unmap_coords (unmapped, coords_length);
|
|
|
|
for (unsigned int i = 0; i < coords_length; ++i)
|
|
|
|
design_coords[i] = font->face->table.fvar->unnormalize_axis_value (i, unmapped[i]);
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (unmapped);
|
2016-09-10 10:58:27 +02:00
|
|
|
|
2019-08-14 16:12:51 +02:00
|
|
|
_hb_font_adopt_var_coords (font, copy, design_coords, coords_length);
|
2016-09-10 07:23:34 +02:00
|
|
|
}
|
|
|
|
|
2017-01-23 02:42:33 +01:00
|
|
|
/**
|
2017-01-24 08:42:53 +01:00
|
|
|
* hb_font_get_var_coords_normalized:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @font: #hb_font_t to work upon
|
2022-01-31 17:12:01 +01:00
|
|
|
* @length: (out): Number of coordinates retrieved
|
2019-04-22 16:31:24 +02:00
|
|
|
*
|
|
|
|
* Fetches the list of normalized variation coordinates currently
|
|
|
|
* set on a font.
|
2017-01-23 02:42:33 +01:00
|
|
|
*
|
2022-01-02 17:28:28 +01:00
|
|
|
* Note that this returned array may only contain values for some
|
|
|
|
* (or none) of the axes; omitted axes effectively have zero values.
|
|
|
|
*
|
2017-01-23 02:47:49 +01:00
|
|
|
* Return value is valid as long as variation coordinates of the font
|
|
|
|
* are not modified.
|
|
|
|
*
|
2022-01-31 17:12:01 +01:00
|
|
|
* Return value: coordinates array
|
|
|
|
*
|
2017-01-23 02:42:33 +01:00
|
|
|
* Since: 1.4.2
|
|
|
|
*/
|
2017-01-23 02:47:49 +01:00
|
|
|
const int *
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_var_coords_normalized (hb_font_t *font,
|
2017-01-21 23:48:46 +01:00
|
|
|
unsigned int *length)
|
|
|
|
{
|
|
|
|
if (length)
|
2017-01-22 00:05:00 +01:00
|
|
|
*length = font->num_coords;
|
2017-01-21 23:48:46 +01:00
|
|
|
|
|
|
|
return font->coords;
|
|
|
|
}
|
2019-08-14 16:12:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_get_var_coords_design:
|
2020-12-30 22:34:17 +01:00
|
|
|
* @font: #hb_font_t to work upon
|
2022-01-31 17:12:01 +01:00
|
|
|
* @length: (out): Number of coordinates retrieved
|
2019-08-14 16:12:51 +02:00
|
|
|
*
|
2022-01-31 17:12:01 +01:00
|
|
|
* Fetches the list of variation coordinates (in design-space units) currently
|
|
|
|
* set on a font.
|
2019-08-14 16:12:51 +02:00
|
|
|
*
|
2022-01-02 17:28:28 +01:00
|
|
|
* Note that this returned array may only contain values for some
|
|
|
|
* (or none) of the axes; omitted axes effectively have their default
|
|
|
|
* values.
|
|
|
|
*
|
2022-01-31 17:12:01 +01:00
|
|
|
* Return value is valid as long as variation coordinates of the font
|
|
|
|
* are not modified.
|
|
|
|
*
|
2020-12-30 22:34:17 +01:00
|
|
|
* Return value: coordinates array
|
|
|
|
*
|
2022-01-31 17:12:01 +01:00
|
|
|
* Since: 3.3.0
|
2019-08-14 16:12:51 +02:00
|
|
|
*/
|
|
|
|
const float *
|
|
|
|
hb_font_get_var_coords_design (hb_font_t *font,
|
|
|
|
unsigned int *length)
|
|
|
|
{
|
|
|
|
if (length)
|
|
|
|
*length = font->num_coords;
|
|
|
|
|
|
|
|
return font->design_coords;
|
|
|
|
}
|
2019-08-14 20:07:00 +02:00
|
|
|
#endif
|
2016-09-10 07:23:34 +02:00
|
|
|
|
2019-05-11 09:37:01 +02:00
|
|
|
#ifndef HB_DISABLE_DEPRECATED
|
2016-02-24 11:05:23 +01:00
|
|
|
/*
|
|
|
|
* Deprecated get_glyph_func():
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct hb_trampoline_closure_t
|
|
|
|
{
|
|
|
|
void *user_data;
|
|
|
|
hb_destroy_func_t destroy;
|
2016-02-25 01:16:05 +01:00
|
|
|
unsigned int ref_count;
|
2016-02-24 11:05:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FuncType>
|
|
|
|
struct hb_trampoline_t
|
|
|
|
{
|
|
|
|
hb_trampoline_closure_t closure; /* Must be first. */
|
|
|
|
FuncType func;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FuncType>
|
|
|
|
static hb_trampoline_t<FuncType> *
|
|
|
|
trampoline_create (FuncType func,
|
|
|
|
void *user_data,
|
|
|
|
hb_destroy_func_t destroy)
|
|
|
|
{
|
|
|
|
typedef hb_trampoline_t<FuncType> trampoline_t;
|
|
|
|
|
2021-07-08 18:58:50 +02:00
|
|
|
trampoline_t *trampoline = (trampoline_t *) hb_calloc (1, sizeof (trampoline_t));
|
2016-02-24 11:05:23 +01:00
|
|
|
|
|
|
|
if (unlikely (!trampoline))
|
2017-10-15 12:11:08 +02:00
|
|
|
return nullptr;
|
2016-02-24 11:05:23 +01:00
|
|
|
|
|
|
|
trampoline->closure.user_data = user_data;
|
|
|
|
trampoline->closure.destroy = destroy;
|
2016-02-25 01:16:05 +01:00
|
|
|
trampoline->closure.ref_count = 1;
|
2016-02-24 11:05:23 +01:00
|
|
|
trampoline->func = func;
|
|
|
|
|
|
|
|
return trampoline;
|
|
|
|
}
|
|
|
|
|
2016-02-25 01:16:05 +01:00
|
|
|
static void
|
|
|
|
trampoline_reference (hb_trampoline_closure_t *closure)
|
|
|
|
{
|
|
|
|
closure->ref_count++;
|
|
|
|
}
|
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
static void
|
|
|
|
trampoline_destroy (void *user_data)
|
|
|
|
{
|
|
|
|
hb_trampoline_closure_t *closure = (hb_trampoline_closure_t *) user_data;
|
2016-02-25 01:16:05 +01:00
|
|
|
|
|
|
|
if (--closure->ref_count)
|
|
|
|
return;
|
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
if (closure->destroy)
|
|
|
|
closure->destroy (closure->user_data);
|
2021-07-08 18:58:50 +02:00
|
|
|
hb_free (closure);
|
2016-02-24 11:05:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef hb_trampoline_t<hb_font_get_glyph_func_t> hb_font_get_glyph_trampoline_t;
|
|
|
|
|
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_nominal_glyph_trampoline (hb_font_t *font,
|
|
|
|
void *font_data,
|
|
|
|
hb_codepoint_t unicode,
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data)
|
2016-02-24 11:05:23 +01:00
|
|
|
{
|
|
|
|
hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data;
|
|
|
|
return trampoline->func (font, font_data, unicode, 0, glyph, trampoline->closure.user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static hb_bool_t
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_get_variation_glyph_trampoline (hb_font_t *font,
|
|
|
|
void *font_data,
|
|
|
|
hb_codepoint_t unicode,
|
|
|
|
hb_codepoint_t variation_selector,
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_codepoint_t *glyph,
|
2019-04-17 15:44:25 +02:00
|
|
|
void *user_data)
|
2016-02-24 11:05:23 +01:00
|
|
|
{
|
|
|
|
hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data;
|
|
|
|
return trampoline->func (font, font_data, unicode, variation_selector, glyph, trampoline->closure.user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hb_font_funcs_set_glyph_func:
|
2019-04-22 16:31:24 +02:00
|
|
|
* @ffuncs: The font-functions structure
|
|
|
|
* @func: (closure user_data) (destroy destroy) (scope notified): callback function
|
|
|
|
* @user_data: data to pass to @func
|
2020-12-30 23:19:29 +01:00
|
|
|
* @destroy: (nullable): function to call when @user_data is not needed anymore
|
2016-02-24 11:05:23 +01:00
|
|
|
*
|
|
|
|
* Deprecated. Use hb_font_funcs_set_nominal_glyph_func() and
|
|
|
|
* hb_font_funcs_set_variation_glyph_func() instead.
|
|
|
|
*
|
|
|
|
* Since: 0.9.2
|
|
|
|
* Deprecated: 1.2.3
|
|
|
|
**/
|
|
|
|
void
|
2019-04-17 15:44:25 +02:00
|
|
|
hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
|
|
|
|
hb_font_get_glyph_func_t func,
|
|
|
|
void *user_data,
|
2019-04-22 16:31:24 +02:00
|
|
|
hb_destroy_func_t destroy /* May be NULL. */)
|
2016-02-24 11:05:23 +01:00
|
|
|
{
|
2020-02-11 00:33:03 +01:00
|
|
|
if (hb_object_is_immutable (ffuncs))
|
|
|
|
{
|
|
|
|
if (destroy)
|
|
|
|
destroy (user_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-24 11:05:23 +01:00
|
|
|
hb_font_get_glyph_trampoline_t *trampoline;
|
|
|
|
|
|
|
|
trampoline = trampoline_create (func, user_data, destroy);
|
2016-02-25 01:16:05 +01:00
|
|
|
if (unlikely (!trampoline))
|
|
|
|
{
|
|
|
|
if (destroy)
|
|
|
|
destroy (user_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-16 19:21:45 +02:00
|
|
|
/* Since we pass it to two destroying functions. */
|
|
|
|
trampoline_reference (&trampoline->closure);
|
|
|
|
|
2016-02-25 01:16:05 +01:00
|
|
|
hb_font_funcs_set_nominal_glyph_func (ffuncs,
|
|
|
|
hb_font_get_nominal_glyph_trampoline,
|
|
|
|
trampoline,
|
|
|
|
trampoline_destroy);
|
|
|
|
|
|
|
|
hb_font_funcs_set_variation_glyph_func (ffuncs,
|
|
|
|
hb_font_get_variation_glyph_trampoline,
|
2016-02-24 11:05:23 +01:00
|
|
|
trampoline,
|
|
|
|
trampoline_destroy);
|
|
|
|
}
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2022-12-19 19:53:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
|
|
|
|
hb_font_get_glyph_shape_func_t func,
|
|
|
|
void *user_data,
|
|
|
|
hb_destroy_func_t destroy /* May be NULL. */)
|
|
|
|
{
|
|
|
|
hb_font_funcs_set_draw_glyph_func (ffuncs, func, user_data, destroy);
|
|
|
|
}
|