2009-08-02 01:54:49 +02:00
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
* Copyright © 2009 Red Hat, Inc.
|
|
|
|
* Copyright © 2011 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
|
2011-04-21 23:14:28 +02:00
|
|
|
* Google Author(s): Behdad Esfahbod
|
2009-08-02 01:54:49 +02:00
|
|
|
*/
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#ifndef HB_FONT_HH
|
|
|
|
#define HB_FONT_HH
|
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-face.hh"
|
|
|
|
#include "hb-shaper.hh"
|
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
|
|
|
*/
|
|
|
|
|
2011-05-17 00:15:37 +02:00
|
|
|
#define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \
|
2022-12-19 19:45:45 +01:00
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,font_h_extents) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,font_v_extents) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,nominal_glyph) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,nominal_glyphs) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,variation_glyph) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_h_advance) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_v_advance) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_h_advances) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_v_advances) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_h_origin) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_v_origin) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_h_kerning) \
|
|
|
|
HB_IF_NOT_DEPRECATED (HB_FONT_FUNC_IMPLEMENT (get_,glyph_v_kerning)) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_extents) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_contour_point) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_name) \
|
|
|
|
HB_FONT_FUNC_IMPLEMENT (get_,glyph_from_name) \
|
2022-12-19 19:53:49 +01:00
|
|
|
HB_FONT_FUNC_IMPLEMENT (,draw_glyph) \
|
2022-12-19 19:45:45 +01:00
|
|
|
HB_FONT_FUNC_IMPLEMENT (,paint_glyph) \
|
2011-07-08 05:14:42 +02:00
|
|
|
/* ^--- Add new callbacks here */
|
2011-05-17 00:15:37 +02:00
|
|
|
|
2018-08-06 15:17:48 +02:00
|
|
|
struct hb_font_funcs_t
|
|
|
|
{
|
2011-07-08 05:14:42 +02:00
|
|
|
hb_object_header_t header;
|
|
|
|
|
2011-05-11 02:41:13 +02:00
|
|
|
struct {
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) void *name;
|
2011-05-17 00:15:37 +02:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
2022-06-01 16:44:07 +02:00
|
|
|
} *user_data;
|
2011-05-11 02:41:13 +02:00
|
|
|
|
2010-05-24 18:46:21 +02:00
|
|
|
struct {
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) hb_destroy_func_t name;
|
2011-05-17 00:15:37 +02:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
2022-06-01 16:44:07 +02:00
|
|
|
} *destroy;
|
2015-11-05 07:00:25 +01:00
|
|
|
|
|
|
|
/* Don't access these directly. Call font->get_*() instead. */
|
|
|
|
union get_t {
|
|
|
|
struct get_funcs_t {
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) hb_font_##get_##name##_func_t name;
|
2015-11-05 07:00:25 +01:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
|
|
|
} f;
|
2018-03-28 23:06:58 +02:00
|
|
|
void (*array[0
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) +1
|
2018-03-28 23:06:58 +02:00
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
2018-12-17 19:01:01 +01:00
|
|
|
]) ();
|
2015-11-05 07:00:25 +01:00
|
|
|
} get;
|
2009-08-02 01:54:49 +02:00
|
|
|
};
|
2018-08-06 15:17:48 +02:00
|
|
|
DECLARE_NULL_INSTANCE (hb_font_funcs_t);
|
2009-08-02 01:54:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hb_font_t
|
|
|
|
*/
|
|
|
|
|
2018-11-16 08:29:13 +01:00
|
|
|
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INSTANTIATE_SHAPERS(shaper, font);
|
|
|
|
#include "hb-shaper-list.hh"
|
|
|
|
#undef HB_SHAPER_IMPLEMENT
|
|
|
|
|
2018-08-06 15:17:48 +02:00
|
|
|
struct hb_font_t
|
|
|
|
{
|
2011-04-22 00:24:02 +02:00
|
|
|
hb_object_header_t header;
|
2022-05-20 20:15:00 +02:00
|
|
|
unsigned int serial;
|
|
|
|
unsigned int serial_coords;
|
2009-08-02 01:54:49 +02:00
|
|
|
|
2011-05-11 02:02:49 +02:00
|
|
|
hb_font_t *parent;
|
2011-05-03 02:46:32 +02:00
|
|
|
hb_face_t *face;
|
|
|
|
|
2019-07-05 22:52:09 +02:00
|
|
|
int32_t x_scale;
|
|
|
|
int32_t y_scale;
|
2023-02-02 00:56:56 +01:00
|
|
|
|
|
|
|
float x_embolden;
|
|
|
|
float y_embolden;
|
2023-02-07 19:29:49 +01:00
|
|
|
bool embolden_in_place;
|
|
|
|
int32_t x_strength; /* x_embolden, in scaled units. */
|
|
|
|
int32_t y_strength; /* y_embolden, in scaled units. */
|
2023-02-02 00:56:56 +01:00
|
|
|
|
2021-12-18 23:12:26 +01:00
|
|
|
float slant;
|
2021-12-19 15:25:37 +01:00
|
|
|
float slant_xy;
|
2023-02-02 00:56:56 +01:00
|
|
|
|
2022-06-27 19:28:44 +02:00
|
|
|
float x_multf;
|
|
|
|
float y_multf;
|
2019-07-05 22:52:09 +02:00
|
|
|
int64_t x_mult;
|
|
|
|
int64_t y_mult;
|
2009-08-02 01:54:49 +02:00
|
|
|
|
|
|
|
unsigned int x_ppem;
|
|
|
|
unsigned int y_ppem;
|
2009-08-11 02:05:16 +02:00
|
|
|
|
2017-10-11 11:47:47 +02:00
|
|
|
float ptem;
|
|
|
|
|
2016-03-01 11:12:08 +01:00
|
|
|
/* Font variation coordinates. */
|
2023-01-15 18:44:04 +01:00
|
|
|
unsigned int instance_index;
|
2016-03-01 11:29:36 +01:00
|
|
|
unsigned int num_coords;
|
2016-09-10 11:11:05 +02:00
|
|
|
int *coords;
|
2019-08-14 16:12:51 +02:00
|
|
|
float *design_coords;
|
2016-03-01 11:12:08 +01:00
|
|
|
|
2009-11-04 00:34:20 +01:00
|
|
|
hb_font_funcs_t *klass;
|
|
|
|
void *user_data;
|
2011-04-20 09:03:32 +02:00
|
|
|
hb_destroy_func_t destroy;
|
2011-05-11 06:02:02 +02:00
|
|
|
|
2018-11-16 08:29:13 +01:00
|
|
|
hb_shaper_object_dataset_t<hb_font_t> data; /* Various shaper data. */
|
2012-07-26 23:34:25 +02:00
|
|
|
|
2011-05-11 06:02:02 +02:00
|
|
|
|
|
|
|
/* Convert from font-space to user-space */
|
2019-07-05 22:56:45 +02:00
|
|
|
int64_t dir_mult (hb_direction_t direction)
|
|
|
|
{ return HB_DIRECTION_IS_VERTICAL(direction) ? y_mult : x_mult; }
|
|
|
|
hb_position_t em_scale_x (int16_t v) { return em_mult (v, x_mult); }
|
|
|
|
hb_position_t em_scale_y (int16_t v) { return em_mult (v, y_mult); }
|
2022-06-27 19:28:44 +02:00
|
|
|
hb_position_t em_scalef_x (float v) { return em_multf (v, x_multf); }
|
|
|
|
hb_position_t em_scalef_y (float v) { return em_multf (v, y_multf); }
|
|
|
|
float em_fscale_x (int16_t v) { return em_fmult (v, x_multf); }
|
|
|
|
float em_fscale_y (int16_t v) { return em_fmult (v, y_multf); }
|
|
|
|
float em_fscalef_x (float v) { return em_fmultf (v, x_multf); }
|
|
|
|
float em_fscalef_y (float v) { return em_fmultf (v, y_multf); }
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t em_scale_dir (int16_t v, hb_direction_t direction)
|
2019-07-05 22:56:45 +02:00
|
|
|
{ return em_mult (v, dir_mult (direction)); }
|
2011-05-11 06:02:02 +02:00
|
|
|
|
2011-05-11 06:15:37 +02:00
|
|
|
/* Convert from parent-font user-space to our user-space */
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t parent_scale_x_distance (hb_position_t v)
|
|
|
|
{
|
2011-05-11 06:15:37 +02:00
|
|
|
if (unlikely (parent && parent->x_scale != x_scale))
|
2013-11-06 20:46:04 +01:00
|
|
|
return (hb_position_t) (v * (int64_t) this->x_scale / this->parent->x_scale);
|
2011-05-11 06:15:37 +02:00
|
|
|
return v;
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t parent_scale_y_distance (hb_position_t v)
|
|
|
|
{
|
2011-05-11 06:15:37 +02:00
|
|
|
if (unlikely (parent && parent->y_scale != y_scale))
|
2013-11-06 20:46:04 +01:00
|
|
|
return (hb_position_t) (v * (int64_t) this->y_scale / this->parent->y_scale);
|
2011-05-11 06:15:37 +02:00
|
|
|
return v;
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t parent_scale_x_position (hb_position_t v)
|
|
|
|
{ return parent_scale_x_distance (v); }
|
|
|
|
hb_position_t parent_scale_y_position (hb_position_t v)
|
|
|
|
{ return parent_scale_y_distance (v); }
|
2011-05-11 06:15:37 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void parent_scale_distance (hb_position_t *x, hb_position_t *y)
|
|
|
|
{
|
2011-05-11 06:15:37 +02:00
|
|
|
*x = parent_scale_x_distance (*x);
|
|
|
|
*y = parent_scale_y_distance (*y);
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void parent_scale_position (hb_position_t *x, hb_position_t *y)
|
|
|
|
{
|
2011-05-11 06:15:37 +02:00
|
|
|
*x = parent_scale_x_position (*x);
|
|
|
|
*y = parent_scale_y_position (*y);
|
|
|
|
}
|
|
|
|
|
2022-12-22 15:26:14 +01:00
|
|
|
void scale_glyph_extents (hb_glyph_extents_t *extents)
|
|
|
|
{
|
2023-01-09 19:54:44 +01:00
|
|
|
float x1 = em_fscale_x (extents->x_bearing);
|
|
|
|
float y1 = em_fscale_y (extents->y_bearing);
|
|
|
|
float x2 = em_fscale_x (extents->x_bearing + extents->width);
|
|
|
|
float y2 = em_fscale_y (extents->y_bearing + extents->height);
|
2022-12-22 15:31:16 +01:00
|
|
|
|
|
|
|
/* Apply slant. */
|
2023-01-09 21:43:56 +01:00
|
|
|
if (slant_xy)
|
|
|
|
{
|
|
|
|
x1 += hb_min (y1 * slant_xy, y2 * slant_xy);
|
|
|
|
x2 += hb_max (y1 * slant_xy, y2 * slant_xy);
|
|
|
|
}
|
2023-01-09 19:54:44 +01:00
|
|
|
|
|
|
|
extents->x_bearing = floorf (x1);
|
|
|
|
extents->y_bearing = floorf (y1);
|
|
|
|
extents->width = ceilf (x2) - extents->x_bearing;
|
|
|
|
extents->height = ceilf (y2) - extents->y_bearing;
|
|
|
|
|
2023-02-07 21:46:13 +01:00
|
|
|
if (x_strength || y_strength)
|
|
|
|
{
|
|
|
|
/* Y */
|
|
|
|
int y_shift = y_strength;
|
|
|
|
if (y_scale < 0) y_shift = -y_shift;
|
|
|
|
extents->y_bearing += y_shift;
|
|
|
|
extents->height -= y_shift;
|
|
|
|
|
|
|
|
/* X */
|
|
|
|
int x_shift = x_strength;
|
|
|
|
if (x_scale < 0) x_shift = -x_shift;
|
|
|
|
if (embolden_in_place)
|
|
|
|
extents->x_bearing -= x_shift / 2;
|
|
|
|
extents->width += x_shift;
|
|
|
|
}
|
2022-12-22 15:26:14 +01:00
|
|
|
}
|
|
|
|
|
2011-05-11 06:15:37 +02:00
|
|
|
|
2012-08-02 01:03:46 +02:00
|
|
|
/* Public getters */
|
|
|
|
|
2015-11-05 06:42:55 +01:00
|
|
|
HB_INTERNAL bool has_func (unsigned int i);
|
2018-10-20 04:12:33 +02:00
|
|
|
HB_INTERNAL bool has_func_set (unsigned int i);
|
2015-11-05 06:42:55 +01:00
|
|
|
|
|
|
|
/* has_* ... */
|
2022-12-19 19:45:45 +01:00
|
|
|
#define HB_FONT_FUNC_IMPLEMENT(get_,name) \
|
2015-11-05 06:42:55 +01:00
|
|
|
bool \
|
2018-12-17 19:01:01 +01:00
|
|
|
has_##name##_func () \
|
2015-11-05 06:42:55 +01:00
|
|
|
{ \
|
|
|
|
hb_font_funcs_t *funcs = this->klass; \
|
|
|
|
unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \
|
|
|
|
return has_func (i); \
|
2018-10-20 04:12:33 +02:00
|
|
|
} \
|
|
|
|
bool \
|
2018-12-17 19:01:01 +01:00
|
|
|
has_##name##_func_set () \
|
2018-10-20 04:12:33 +02:00
|
|
|
{ \
|
|
|
|
hb_font_funcs_t *funcs = this->klass; \
|
|
|
|
unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \
|
|
|
|
return has_func_set (i); \
|
2015-11-05 06:42:55 +01:00
|
|
|
}
|
|
|
|
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
|
|
|
#undef HB_FONT_FUNC_IMPLEMENT
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_font_h_extents (hb_font_extents_t *extents)
|
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 klass->get.f.font_h_extents (this, user_data,
|
|
|
|
extents,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->font_h_extents);
|
2015-10-26 08:23:22 +01:00
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_font_v_extents (hb_font_extents_t *extents)
|
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 klass->get.f.font_v_extents (this, user_data,
|
|
|
|
extents,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->font_v_extents);
|
2015-10-26 08:23:22 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool has_glyph (hb_codepoint_t unicode)
|
2014-01-02 07:30:45 +01:00
|
|
|
{
|
|
|
|
hb_codepoint_t glyph;
|
2016-02-24 11:05:23 +01:00
|
|
|
return get_nominal_glyph (unicode, &glyph);
|
2014-01-02 07:30:45 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_nominal_glyph (hb_codepoint_t unicode,
|
2021-10-26 16:02:29 +02:00
|
|
|
hb_codepoint_t *glyph,
|
|
|
|
hb_codepoint_t not_found = 0)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2021-10-26 16:02:29 +02:00
|
|
|
*glyph = not_found;
|
2016-02-24 11:05:23 +01:00
|
|
|
return klass->get.f.nominal_glyph (this, user_data,
|
|
|
|
unicode, glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->nominal_glyph);
|
2016-02-24 11:05:23 +01:00
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
unsigned int get_nominal_glyphs (unsigned int count,
|
|
|
|
const hb_codepoint_t *first_unicode,
|
|
|
|
unsigned int unicode_stride,
|
|
|
|
hb_codepoint_t *first_glyph,
|
|
|
|
unsigned int glyph_stride)
|
2018-10-09 15:23:51 +02:00
|
|
|
{
|
|
|
|
return klass->get.f.nominal_glyphs (this, user_data,
|
|
|
|
count,
|
|
|
|
first_unicode, unicode_stride,
|
|
|
|
first_glyph, glyph_stride,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->nominal_glyphs);
|
2018-10-09 15:23:51 +02:00
|
|
|
}
|
2016-02-24 11:05:23 +01:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector,
|
2021-10-26 16:02:29 +02:00
|
|
|
hb_codepoint_t *glyph,
|
|
|
|
hb_codepoint_t not_found = 0)
|
2016-02-24 11:05:23 +01:00
|
|
|
{
|
2021-10-26 16:02:29 +02:00
|
|
|
*glyph = not_found;
|
2016-02-24 11:05:23 +01:00
|
|
|
return klass->get.f.variation_glyph (this, user_data,
|
|
|
|
unicode, variation_selector, glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->variation_glyph);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_glyph_h_advance (hb_codepoint_t glyph)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_h_advance (this, user_data,
|
|
|
|
glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_h_advance);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_glyph_v_advance (hb_codepoint_t glyph)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_v_advance (this, user_data,
|
|
|
|
glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_v_advance);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_h_advances (unsigned int count,
|
|
|
|
const hb_codepoint_t *first_glyph,
|
|
|
|
unsigned int glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned int advance_stride)
|
2018-08-06 18:45:17 +02:00
|
|
|
{
|
|
|
|
return klass->get.f.glyph_h_advances (this, user_data,
|
|
|
|
count,
|
|
|
|
first_glyph, glyph_stride,
|
|
|
|
first_advance, advance_stride,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_h_advances);
|
2018-08-06 18:45:17 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_v_advances (unsigned int count,
|
|
|
|
const hb_codepoint_t *first_glyph,
|
|
|
|
unsigned int glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned int advance_stride)
|
2018-08-06 18:45:17 +02:00
|
|
|
{
|
|
|
|
return klass->get.f.glyph_v_advances (this, user_data,
|
|
|
|
count,
|
|
|
|
first_glyph, glyph_stride,
|
|
|
|
first_advance, advance_stride,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_v_advances);
|
2018-08-06 18:45:17 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph,
|
2020-04-20 11:42:45 +02:00
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
*x = *y = 0;
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_h_origin (this, user_data,
|
|
|
|
glyph, x, y,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_h_origin);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_v_origin (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
*x = *y = 0;
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_v_origin (this, user_data,
|
|
|
|
glyph, x, y,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_v_origin);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_glyph_h_kerning (hb_codepoint_t left_glyph,
|
|
|
|
hb_codepoint_t right_glyph)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2019-05-11 09:37:01 +02:00
|
|
|
#ifdef HB_DISABLE_DEPRECATED
|
|
|
|
return 0;
|
|
|
|
#else
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_h_kerning (this, user_data,
|
|
|
|
left_glyph, right_glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_h_kerning);
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_position_t get_glyph_v_kerning (hb_codepoint_t top_glyph,
|
|
|
|
hb_codepoint_t bottom_glyph)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2019-05-11 09:37:01 +02:00
|
|
|
#ifdef HB_DISABLE_DEPRECATED
|
|
|
|
return 0;
|
|
|
|
#else
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_v_kerning (this, user_data,
|
|
|
|
top_glyph, bottom_glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_v_kerning);
|
2019-05-11 09:37:01 +02:00
|
|
|
#endif
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_extents (hb_codepoint_t glyph,
|
2019-10-01 12:19:55 +02:00
|
|
|
hb_glyph_extents_t *extents)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2022-11-22 20:50:36 +01:00
|
|
|
hb_memset (extents, 0, sizeof (*extents));
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_extents (this, user_data,
|
|
|
|
glyph,
|
|
|
|
extents,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_extents);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_contour_point (hb_codepoint_t glyph, unsigned int point_index,
|
2020-07-18 19:44:52 +02:00
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
*x = *y = 0;
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_contour_point (this, user_data,
|
|
|
|
glyph, point_index,
|
|
|
|
x, y,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_contour_point);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_name (hb_codepoint_t glyph,
|
|
|
|
char *name, unsigned int size)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2012-08-08 04:13:25 +02:00
|
|
|
if (size) *name = '\0';
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_name (this, user_data,
|
|
|
|
glyph,
|
|
|
|
name, size,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_name);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_from_name (const char *name, int len, /* -1 means nul-terminated */
|
|
|
|
hb_codepoint_t *glyph)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2012-08-08 04:13:25 +02:00
|
|
|
*glyph = 0;
|
|
|
|
if (len == -1) len = strlen (name);
|
2015-11-05 06:16:26 +01:00
|
|
|
return klass->get.f.glyph_from_name (this, user_data,
|
|
|
|
name, len,
|
|
|
|
glyph,
|
2022-06-01 16:44:07 +02:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->glyph_from_name);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2022-12-19 19:53:49 +01:00
|
|
|
void draw_glyph (hb_codepoint_t glyph,
|
|
|
|
hb_draw_funcs_t *draw_funcs, void *draw_data)
|
2022-02-03 08:14:47 +01:00
|
|
|
{
|
2022-12-19 19:53:49 +01:00
|
|
|
klass->get.f.draw_glyph (this, user_data,
|
|
|
|
glyph,
|
|
|
|
draw_funcs, draw_data,
|
|
|
|
!klass->user_data ? nullptr : klass->user_data->draw_glyph);
|
2022-02-03 08:14:47 +01:00
|
|
|
}
|
|
|
|
|
2022-12-19 19:45:45 +01:00
|
|
|
void paint_glyph (hb_codepoint_t glyph,
|
2022-12-21 20:04:32 +01:00
|
|
|
hb_paint_funcs_t *paint_funcs, void *paint_data,
|
|
|
|
unsigned int palette,
|
|
|
|
hb_color_t foreground)
|
2022-12-14 12:22:00 +01:00
|
|
|
{
|
2022-12-19 19:45:45 +01:00
|
|
|
klass->get.f.paint_glyph (this, user_data,
|
2022-12-14 12:22:00 +01:00
|
|
|
glyph,
|
|
|
|
paint_funcs, paint_data,
|
2022-12-21 20:04:32 +01:00
|
|
|
palette, foreground,
|
2022-12-19 19:45:45 +01:00
|
|
|
!klass->user_data ? nullptr : klass->user_data->paint_glyph);
|
2022-12-14 12:22:00 +01:00
|
|
|
}
|
2012-08-02 01:03:46 +02:00
|
|
|
|
|
|
|
/* A bit higher-level, and with fallback */
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_h_extents_with_fallback (hb_font_extents_t *extents)
|
2016-10-26 18:08:41 +02:00
|
|
|
{
|
|
|
|
if (!get_font_h_extents (extents))
|
|
|
|
{
|
|
|
|
extents->ascender = y_scale * .8;
|
|
|
|
extents->descender = extents->ascender - y_scale;
|
|
|
|
extents->line_gap = 0;
|
|
|
|
}
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_v_extents_with_fallback (hb_font_extents_t *extents)
|
2016-10-26 18:08:41 +02:00
|
|
|
{
|
|
|
|
if (!get_font_v_extents (extents))
|
|
|
|
{
|
|
|
|
extents->ascender = x_scale / 2;
|
|
|
|
extents->descender = extents->ascender - x_scale;
|
|
|
|
extents->line_gap = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_extents_for_direction (hb_direction_t direction,
|
|
|
|
hb_font_extents_t *extents)
|
2015-10-26 08:23:22 +01:00
|
|
|
{
|
2016-10-26 18:08:41 +02:00
|
|
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
|
|
|
get_h_extents_with_fallback (extents);
|
|
|
|
else
|
|
|
|
get_v_extents_with_fallback (extents);
|
2015-10-26 08:23:22 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_advance_for_direction (hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2018-08-07 18:44:01 +02:00
|
|
|
*x = *y = 0;
|
|
|
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
2012-08-02 01:03:46 +02:00
|
|
|
*x = get_glyph_h_advance (glyph);
|
2018-08-07 18:44:01 +02:00
|
|
|
else
|
2012-08-02 01:03:46 +02:00
|
|
|
*y = get_glyph_v_advance (glyph);
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_advances_for_direction (hb_direction_t direction,
|
|
|
|
unsigned int count,
|
|
|
|
const hb_codepoint_t *first_glyph,
|
|
|
|
unsigned glyph_stride,
|
|
|
|
hb_position_t *first_advance,
|
|
|
|
unsigned advance_stride)
|
2018-08-07 18:52:06 +02:00
|
|
|
{
|
|
|
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
|
|
|
get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
|
|
|
|
else
|
|
|
|
get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride);
|
|
|
|
}
|
2012-08-02 01:03:46 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void guess_v_origin_minus_h_origin (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
*x = get_glyph_h_advance (glyph) / 2;
|
|
|
|
|
2016-10-26 18:12:50 +02:00
|
|
|
hb_font_extents_t extents;
|
|
|
|
get_h_extents_with_fallback (&extents);
|
|
|
|
*y = extents.ascender;
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_h_origin_with_fallback (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2016-10-26 17:44:16 +02:00
|
|
|
{
|
|
|
|
if (!get_glyph_h_origin (glyph, x, y) &&
|
|
|
|
get_glyph_v_origin (glyph, x, y))
|
|
|
|
{
|
|
|
|
hb_position_t dx, dy;
|
|
|
|
guess_v_origin_minus_h_origin (glyph, &dx, &dy);
|
|
|
|
*x -= dx; *y -= dy;
|
|
|
|
}
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_v_origin_with_fallback (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2016-10-26 17:44:16 +02:00
|
|
|
{
|
|
|
|
if (!get_glyph_v_origin (glyph, x, y) &&
|
|
|
|
get_glyph_h_origin (glyph, x, y))
|
|
|
|
{
|
|
|
|
hb_position_t dx, dy;
|
|
|
|
guess_v_origin_minus_h_origin (glyph, &dx, &dy);
|
|
|
|
*x += dx; *y += dy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_origin_for_direction (hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
2013-06-10 20:39:51 +02:00
|
|
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
|
2016-10-26 17:44:16 +02:00
|
|
|
get_glyph_h_origin_with_fallback (glyph, x, y);
|
2013-06-10 20:39:51 +02:00
|
|
|
else
|
2016-10-26 17:44:16 +02:00
|
|
|
get_glyph_v_origin_with_fallback (glyph, x, y);
|
2012-08-02 01:03:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void add_glyph_h_origin (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2015-11-05 04:28:17 +01:00
|
|
|
{
|
|
|
|
hb_position_t origin_x, origin_y;
|
|
|
|
|
2016-10-26 17:44:16 +02:00
|
|
|
get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y);
|
2015-11-05 04:28:17 +01:00
|
|
|
|
|
|
|
*x += origin_x;
|
|
|
|
*y += origin_y;
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void add_glyph_v_origin (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2015-11-05 04:28:17 +01:00
|
|
|
{
|
|
|
|
hb_position_t origin_x, origin_y;
|
|
|
|
|
2016-10-26 17:44:16 +02:00
|
|
|
get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y);
|
2015-11-05 04:28:17 +01:00
|
|
|
|
|
|
|
*x += origin_x;
|
|
|
|
*y += origin_y;
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void add_glyph_origin_for_direction (hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
hb_position_t origin_x, origin_y;
|
|
|
|
|
|
|
|
get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y);
|
|
|
|
|
|
|
|
*x += origin_x;
|
|
|
|
*y += origin_y;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void subtract_glyph_h_origin (hb_codepoint_t glyph,
|
2019-10-01 12:19:55 +02:00
|
|
|
hb_position_t *x, hb_position_t *y)
|
2015-11-05 04:28:17 +01:00
|
|
|
{
|
|
|
|
hb_position_t origin_x, origin_y;
|
|
|
|
|
2016-10-26 17:44:16 +02:00
|
|
|
get_glyph_h_origin_with_fallback (glyph, &origin_x, &origin_y);
|
2015-11-05 04:28:17 +01:00
|
|
|
|
|
|
|
*x -= origin_x;
|
|
|
|
*y -= origin_y;
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void subtract_glyph_v_origin (hb_codepoint_t glyph,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2015-11-05 04:28:17 +01:00
|
|
|
{
|
|
|
|
hb_position_t origin_x, origin_y;
|
|
|
|
|
2016-10-26 17:44:16 +02:00
|
|
|
get_glyph_v_origin_with_fallback (glyph, &origin_x, &origin_y);
|
2015-11-05 04:28:17 +01:00
|
|
|
|
|
|
|
*x -= origin_x;
|
|
|
|
*y -= origin_y;
|
|
|
|
}
|
2018-12-16 20:08:10 +01:00
|
|
|
void subtract_glyph_origin_for_direction (hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
hb_position_t origin_x, origin_y;
|
|
|
|
|
|
|
|
get_glyph_origin_for_direction (glyph, direction, &origin_x, &origin_y);
|
|
|
|
|
|
|
|
*x -= origin_x;
|
|
|
|
*y -= origin_y;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_glyph_kerning_for_direction (hb_codepoint_t first_glyph, hb_codepoint_t second_glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
|
|
|
|
*y = 0;
|
2018-10-09 05:09:48 +02:00
|
|
|
*x = get_glyph_h_kerning (first_glyph, second_glyph);
|
2012-08-02 01:03:46 +02:00
|
|
|
} else {
|
|
|
|
*x = 0;
|
|
|
|
*y = get_glyph_v_kerning (first_glyph, second_glyph);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_extents_for_origin (hb_codepoint_t glyph,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_glyph_extents_t *extents)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
hb_bool_t ret = get_glyph_extents (glyph, extents);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
subtract_glyph_origin_for_direction (glyph, direction, &extents->x_bearing, &extents->y_bearing);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t get_glyph_contour_point_for_origin (hb_codepoint_t glyph, unsigned int point_index,
|
|
|
|
hb_direction_t direction,
|
|
|
|
hb_position_t *x, hb_position_t *y)
|
2012-08-02 01:03:46 +02:00
|
|
|
{
|
|
|
|
hb_bool_t ret = get_glyph_contour_point (glyph, point_index, x, y);
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
subtract_glyph_origin_for_direction (glyph, direction, x, y);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-08-08 04:13:25 +02:00
|
|
|
/* Generates gidDDD if glyph has no name. */
|
2018-12-16 20:08:10 +01:00
|
|
|
void
|
2012-08-08 04:13:25 +02:00
|
|
|
glyph_to_string (hb_codepoint_t glyph,
|
|
|
|
char *s, unsigned int size)
|
|
|
|
{
|
|
|
|
if (get_glyph_name (glyph, s, size)) return;
|
|
|
|
|
2013-08-27 17:44:09 +02:00
|
|
|
if (size && snprintf (s, size, "gid%u", glyph) < 0)
|
|
|
|
*s = '\0';
|
2012-08-08 04:13:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Parses gidDDD and uniUUUU strings automatically. */
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_bool_t
|
2012-08-08 04:13:25 +02:00
|
|
|
glyph_from_string (const char *s, int len, /* -1 means nul-terminated */
|
|
|
|
hb_codepoint_t *glyph)
|
|
|
|
{
|
|
|
|
if (get_glyph_from_name (s, len, glyph)) return true;
|
|
|
|
|
|
|
|
if (len == -1) len = strlen (s);
|
|
|
|
|
|
|
|
/* Straight glyph index. */
|
|
|
|
if (hb_codepoint_parse (s, len, 10, glyph))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (len > 3)
|
|
|
|
{
|
|
|
|
/* gidDDD syntax for glyph indices. */
|
|
|
|
if (0 == strncmp (s, "gid", 3) &&
|
|
|
|
hb_codepoint_parse (s + 3, len - 3, 10, glyph))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
/* uniUUUU and other Unicode character indices. */
|
|
|
|
hb_codepoint_t unichar;
|
|
|
|
if (0 == strncmp (s, "uni", 3) &&
|
|
|
|
hb_codepoint_parse (s + 3, len - 3, 16, &unichar) &&
|
2016-02-24 11:05:23 +01:00
|
|
|
get_nominal_glyph (unichar, glyph))
|
2012-08-08 04:13:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-02 01:03:46 +02:00
|
|
|
|
2019-07-05 22:52:09 +02:00
|
|
|
void mults_changed ()
|
|
|
|
{
|
2022-06-27 19:28:44 +02:00
|
|
|
float upem = face->get_upem ();
|
2023-02-02 00:56:56 +01:00
|
|
|
|
2022-06-27 19:28:44 +02:00
|
|
|
x_multf = x_scale / upem;
|
|
|
|
y_multf = y_scale / upem;
|
2022-06-01 15:27:30 +02:00
|
|
|
bool x_neg = x_scale < 0;
|
2022-06-27 19:28:44 +02:00
|
|
|
x_mult = (x_neg ? -((int64_t) -x_scale << 16) : ((int64_t) x_scale << 16)) / upem;
|
2022-06-01 15:27:30 +02:00
|
|
|
bool y_neg = y_scale < 0;
|
2022-06-27 19:28:44 +02:00
|
|
|
y_mult = (y_neg ? -((int64_t) -y_scale << 16) : ((int64_t) y_scale << 16)) / upem;
|
2023-02-02 00:56:56 +01:00
|
|
|
|
2023-02-20 04:38:43 +01:00
|
|
|
x_strength = fabsf (roundf (x_scale * x_embolden));
|
|
|
|
y_strength = fabsf (roundf (y_scale * y_embolden));
|
2023-02-02 00:56:56 +01:00
|
|
|
|
2021-12-19 15:25:37 +01:00
|
|
|
slant_xy = y_scale ? slant * x_scale / y_scale : 0.f;
|
2022-06-28 21:19:12 +02:00
|
|
|
|
|
|
|
data.fini ();
|
2019-07-05 22:52:09 +02:00
|
|
|
}
|
|
|
|
|
2019-07-05 22:56:45 +02:00
|
|
|
hb_position_t em_mult (int16_t v, int64_t mult)
|
2021-11-01 23:45:36 +01:00
|
|
|
{ return (hb_position_t) ((v * mult + 32768) >> 16); }
|
2022-06-27 19:28:44 +02:00
|
|
|
hb_position_t em_multf (float v, float mult)
|
|
|
|
{ return (hb_position_t) roundf (em_fmultf (v, mult)); }
|
|
|
|
float em_fmultf (float v, float mult)
|
|
|
|
{ return v * mult; }
|
|
|
|
float em_fmult (int16_t v, float mult)
|
|
|
|
{ return (float) v * mult; }
|
2009-08-02 01:54:49 +02:00
|
|
|
};
|
2018-08-06 15:17:48 +02:00
|
|
|
DECLARE_NULL_INSTANCE (hb_font_t);
|
2009-08-02 01:54:49 +02:00
|
|
|
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#endif /* HB_FONT_HH */
|