2017-01-23 20:41:43 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2017 Google, Inc.
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HB_OT_VAR_HVAR_TABLE_HH
|
|
|
|
#define HB_OT_VAR_HVAR_TABLE_HH
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-ot-layout-common.hh"
|
2021-10-14 22:39:45 +02:00
|
|
|
#include "hb-ot-var-common.hh"
|
2017-01-23 20:41:43 +01:00
|
|
|
|
|
|
|
namespace OT {
|
|
|
|
|
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
struct index_map_subset_plan_t
|
|
|
|
{
|
2019-03-20 23:10:59 +01:00
|
|
|
enum index_map_index_t {
|
|
|
|
ADV_INDEX,
|
2019-03-22 02:09:37 +01:00
|
|
|
LSB_INDEX, /* dual as TSB */
|
|
|
|
RSB_INDEX, /* dual as BSB */
|
2019-03-20 23:10:59 +01:00
|
|
|
VORG_INDEX
|
|
|
|
};
|
|
|
|
|
2019-12-31 13:23:02 +01:00
|
|
|
void init (const DeltaSetIndexMap &index_map,
|
|
|
|
hb_inc_bimap_t &outer_map,
|
|
|
|
hb_vector_t<hb_set_t *> &inner_sets,
|
|
|
|
const hb_subset_plan_t *plan)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-02-22 00:47:27 +01:00
|
|
|
map_count = 0;
|
|
|
|
outer_bit_count = 0;
|
2019-04-16 19:33:51 +02:00
|
|
|
inner_bit_count = 1;
|
2019-02-22 00:47:27 +01:00
|
|
|
max_inners.init ();
|
|
|
|
output_map.init ();
|
|
|
|
|
2020-04-20 11:42:45 +02:00
|
|
|
if (&index_map == &Null (DeltaSetIndexMap)) return;
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-02-22 00:47:27 +01:00
|
|
|
unsigned int last_val = (unsigned int)-1;
|
2019-02-21 00:48:29 +01:00
|
|
|
hb_codepoint_t last_gid = (hb_codepoint_t)-1;
|
2019-06-05 21:59:09 +02:00
|
|
|
hb_codepoint_t gid = (hb_codepoint_t) hb_min (index_map.get_map_count (), plan->num_output_glyphs ());
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-02-22 00:47:27 +01:00
|
|
|
outer_bit_count = (index_map.get_width () * 8) - index_map.get_inner_bit_count ();
|
2019-07-09 20:43:59 +02:00
|
|
|
max_inners.resize (inner_sets.length);
|
|
|
|
for (unsigned i = 0; i < inner_sets.length; i++) max_inners[i] = 0;
|
2019-02-21 00:48:29 +01:00
|
|
|
|
|
|
|
/* Search backwards for a map value different from the last map value */
|
2019-02-22 00:47:27 +01:00
|
|
|
for (; gid > 0; gid--)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-07-09 20:43:59 +02:00
|
|
|
hb_codepoint_t old_gid;
|
|
|
|
if (!plan->old_gid_for_new_gid (gid - 1, &old_gid))
|
|
|
|
{
|
2019-10-06 15:36:40 +02:00
|
|
|
if (last_gid == (hb_codepoint_t) -1)
|
2019-07-09 20:43:59 +02:00
|
|
|
continue;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-10-06 15:36:40 +02:00
|
|
|
unsigned int v = index_map.map (old_gid);
|
|
|
|
if (last_gid == (hb_codepoint_t) -1)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-02-22 00:47:27 +01:00
|
|
|
last_val = v;
|
|
|
|
last_gid = gid;
|
2019-02-21 00:48:29 +01:00
|
|
|
continue;
|
|
|
|
}
|
2019-02-22 00:47:27 +01:00
|
|
|
if (v != last_val) break;
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-02-22 00:47:27 +01:00
|
|
|
last_gid = gid;
|
2019-02-21 00:48:29 +01:00
|
|
|
}
|
|
|
|
|
2019-03-29 00:17:36 +01:00
|
|
|
if (unlikely (last_gid == (hb_codepoint_t)-1)) return;
|
2019-03-20 00:00:01 +01:00
|
|
|
map_count = last_gid;
|
2019-02-22 00:47:27 +01:00
|
|
|
for (gid = 0; gid < map_count; gid++)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-07-09 20:43:59 +02:00
|
|
|
hb_codepoint_t old_gid;
|
|
|
|
if (plan->old_gid_for_new_gid (gid, &old_gid))
|
|
|
|
{
|
|
|
|
unsigned int v = index_map.map (old_gid);
|
|
|
|
unsigned int outer = v >> 16;
|
|
|
|
unsigned int inner = v & 0xFFFF;
|
|
|
|
outer_map.add (outer);
|
|
|
|
if (inner > max_inners[outer]) max_inners[outer] = inner;
|
2020-01-10 05:24:16 +01:00
|
|
|
if (outer >= inner_sets.length) return;
|
2019-12-31 13:27:39 +01:00
|
|
|
inner_sets[outer]->add (inner);
|
2019-07-09 20:43:59 +02:00
|
|
|
}
|
2019-02-21 00:48:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 20:11:50 +01:00
|
|
|
void fini ()
|
2019-02-22 00:47:27 +01:00
|
|
|
{
|
|
|
|
max_inners.fini ();
|
|
|
|
output_map.fini ();
|
|
|
|
}
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-04-30 19:40:45 +02:00
|
|
|
void remap (const DeltaSetIndexMap *input_map,
|
2019-07-09 02:13:29 +02:00
|
|
|
const hb_inc_bimap_t &outer_map,
|
|
|
|
const hb_vector_t<hb_inc_bimap_t> &inner_maps,
|
2019-04-30 19:40:45 +02:00
|
|
|
const hb_subset_plan_t *plan)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2020-04-20 11:42:45 +02:00
|
|
|
if (input_map == &Null (DeltaSetIndexMap)) return;
|
2019-03-19 08:41:41 +01:00
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
for (unsigned int i = 0; i < max_inners.length; i++)
|
|
|
|
{
|
2019-07-09 02:13:29 +02:00
|
|
|
if (inner_maps[i].get_population () == 0) continue;
|
2019-04-30 19:40:45 +02:00
|
|
|
unsigned int bit_count = (max_inners[i]==0)? 1: hb_bit_storage (inner_maps[i][max_inners[i]]);
|
2019-02-21 00:48:29 +01:00
|
|
|
if (bit_count > inner_bit_count) inner_bit_count = bit_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
output_map.resize (map_count);
|
2019-02-22 00:47:27 +01:00
|
|
|
for (hb_codepoint_t gid = 0; gid < output_map.length; gid++)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-07-09 20:43:59 +02:00
|
|
|
hb_codepoint_t old_gid;
|
|
|
|
if (plan->old_gid_for_new_gid (gid, &old_gid))
|
|
|
|
{
|
2021-03-31 19:31:49 +02:00
|
|
|
uint32_t v = input_map->map (old_gid);
|
2019-07-09 20:43:59 +02:00
|
|
|
unsigned int outer = v >> 16;
|
|
|
|
output_map[gid] = (outer_map[outer] << 16) | (inner_maps[outer][v & 0xFFFF]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
output_map[gid] = 0; /* Map unused glyph to outer/inner=0/0 */
|
2019-02-21 00:48:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 20:11:50 +01:00
|
|
|
unsigned int get_inner_bit_count () const { return inner_bit_count; }
|
2019-10-06 15:36:40 +02:00
|
|
|
unsigned int get_width () const { return ((outer_bit_count + inner_bit_count + 7) / 8); }
|
|
|
|
unsigned int get_map_count () const { return map_count; }
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-02-26 20:11:50 +01:00
|
|
|
unsigned int get_size () const
|
2019-02-21 00:48:29 +01:00
|
|
|
{ return (map_count? (DeltaSetIndexMap::min_size + get_width () * map_count): 0); }
|
|
|
|
|
2019-03-19 08:41:41 +01:00
|
|
|
bool is_identity () const { return get_output_map ().length == 0; }
|
2021-03-31 19:31:49 +02:00
|
|
|
hb_array_t<const uint32_t> get_output_map () const { return output_map.as_array (); }
|
2019-02-22 00:47:27 +01:00
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
protected:
|
2019-10-06 15:36:40 +02:00
|
|
|
unsigned int map_count;
|
|
|
|
hb_vector_t<unsigned int> max_inners;
|
|
|
|
unsigned int outer_bit_count;
|
|
|
|
unsigned int inner_bit_count;
|
2021-03-31 19:31:49 +02:00
|
|
|
hb_vector_t<uint32_t> output_map;
|
2019-02-21 00:48:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hvarvvar_subset_plan_t
|
|
|
|
{
|
2019-04-30 19:40:45 +02:00
|
|
|
hvarvvar_subset_plan_t() : inner_maps (), index_map_plans () {}
|
2019-02-21 00:48:29 +01:00
|
|
|
~hvarvvar_subset_plan_t() { fini (); }
|
|
|
|
|
|
|
|
void init (const hb_array_t<const DeltaSetIndexMap *> &index_maps,
|
|
|
|
const VariationStore &_var_store,
|
|
|
|
const hb_subset_plan_t *plan)
|
|
|
|
{
|
|
|
|
index_map_plans.resize (index_maps.length);
|
2019-02-22 00:47:27 +01:00
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
var_store = &_var_store;
|
2019-07-09 20:43:59 +02:00
|
|
|
inner_sets.resize (var_store->get_sub_table_count ());
|
|
|
|
for (unsigned int i = 0; i < inner_sets.length; i++)
|
|
|
|
inner_sets[i] = hb_set_create ();
|
|
|
|
adv_set = hb_set_create ();
|
|
|
|
|
2019-04-30 19:40:45 +02:00
|
|
|
inner_maps.resize (var_store->get_sub_table_count ());
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2020-01-09 21:10:40 +01:00
|
|
|
if (unlikely (!index_map_plans.length || !inner_sets.length || !inner_maps.length)) return;
|
2020-01-06 18:55:00 +01:00
|
|
|
|
2019-07-09 20:43:59 +02:00
|
|
|
bool retain_adv_map = false;
|
|
|
|
index_map_plans[0].init (*index_maps[0], outer_map, inner_sets, plan);
|
2020-01-09 21:10:40 +01:00
|
|
|
if (index_maps[0] == &Null (DeltaSetIndexMap))
|
2019-07-09 20:43:59 +02:00
|
|
|
{
|
2021-07-30 00:07:13 +02:00
|
|
|
retain_adv_map = plan->flags & HB_SUBSET_FLAGS_RETAIN_GIDS;
|
2019-07-09 20:43:59 +02:00
|
|
|
outer_map.add (0);
|
|
|
|
for (hb_codepoint_t gid = 0; gid < plan->num_output_glyphs (); gid++)
|
|
|
|
{
|
|
|
|
hb_codepoint_t old_gid;
|
|
|
|
if (plan->old_gid_for_new_gid (gid, &old_gid))
|
2019-12-31 13:27:39 +01:00
|
|
|
inner_sets[0]->add (old_gid);
|
2019-07-09 20:43:59 +02:00
|
|
|
}
|
|
|
|
hb_set_union (adv_set, inner_sets[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 1; i < index_maps.length; i++)
|
|
|
|
index_map_plans[i].init (*index_maps[i], outer_map, inner_sets, plan);
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2019-07-09 02:13:29 +02:00
|
|
|
outer_map.sort ();
|
2019-07-09 20:43:59 +02:00
|
|
|
|
|
|
|
if (retain_adv_map)
|
|
|
|
{
|
|
|
|
for (hb_codepoint_t gid = 0; gid < plan->num_output_glyphs (); gid++)
|
2019-12-31 13:27:39 +01:00
|
|
|
if (inner_sets[0]->has (gid))
|
2019-07-13 01:14:23 +02:00
|
|
|
inner_maps[0].add (gid);
|
|
|
|
else
|
|
|
|
inner_maps[0].skip ();
|
2019-07-09 20:43:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inner_maps[0].add_set (adv_set);
|
|
|
|
hb_set_subtract (inner_sets[0], adv_set);
|
|
|
|
inner_maps[0].add_set (inner_sets[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 1; i < inner_maps.length; i++)
|
|
|
|
inner_maps[i].add_set (inner_sets[i]);
|
2019-02-21 00:48:29 +01:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < index_maps.length; i++)
|
2019-04-30 19:40:45 +02:00
|
|
|
index_map_plans[i].remap (index_maps[i], outer_map, inner_maps, plan);
|
2019-02-21 00:48:29 +01:00
|
|
|
}
|
|
|
|
|
2019-02-26 20:11:50 +01:00
|
|
|
void fini ()
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-07-09 20:43:59 +02:00
|
|
|
for (unsigned int i = 0; i < inner_sets.length; i++)
|
|
|
|
hb_set_destroy (inner_sets[i]);
|
|
|
|
hb_set_destroy (adv_set);
|
2022-01-18 17:21:31 +01:00
|
|
|
inner_maps.fini ();
|
|
|
|
index_map_plans.fini ();
|
2019-02-21 00:48:29 +01:00
|
|
|
}
|
|
|
|
|
2019-10-06 15:36:40 +02:00
|
|
|
hb_inc_bimap_t outer_map;
|
|
|
|
hb_vector_t<hb_inc_bimap_t> inner_maps;
|
|
|
|
hb_vector_t<index_map_subset_plan_t> index_map_plans;
|
|
|
|
const VariationStore *var_store;
|
2019-07-09 20:43:59 +02:00
|
|
|
|
|
|
|
protected:
|
2019-10-06 15:36:40 +02:00
|
|
|
hb_vector_t<hb_set_t *> inner_sets;
|
|
|
|
hb_set_t *adv_set;
|
2019-02-21 00:48:29 +01:00
|
|
|
};
|
2017-01-23 20:41:43 +01:00
|
|
|
|
|
|
|
/*
|
2018-04-12 11:08:19 +02:00
|
|
|
* HVAR -- Horizontal Metrics Variations
|
|
|
|
* https://docs.microsoft.com/en-us/typography/opentype/spec/hvar
|
|
|
|
* VVAR -- Vertical Metrics Variations
|
|
|
|
* https://docs.microsoft.com/en-us/typography/opentype/spec/vvar
|
2017-01-23 20:41:43 +01:00
|
|
|
*/
|
|
|
|
#define HB_OT_TAG_HVAR HB_TAG('H','V','A','R')
|
|
|
|
#define HB_OT_TAG_VVAR HB_TAG('V','V','A','R')
|
|
|
|
|
|
|
|
struct HVARVVAR
|
|
|
|
{
|
2019-01-22 12:08:57 +01:00
|
|
|
static constexpr hb_tag_t HVARTag = HB_OT_TAG_HVAR;
|
|
|
|
static constexpr hb_tag_t VVARTag = HB_OT_TAG_VVAR;
|
2017-01-23 20:41:43 +01:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2017-01-23 20:41:43 +01:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (version.sanitize (c) &&
|
|
|
|
likely (version.major == 1) &&
|
|
|
|
varStore.sanitize (c, this) &&
|
|
|
|
advMap.sanitize (c, this) &&
|
|
|
|
lsbMap.sanitize (c, this) &&
|
|
|
|
rsbMap.sanitize (c, this));
|
|
|
|
}
|
|
|
|
|
2023-04-04 19:33:58 +02:00
|
|
|
const VariationStore& get_var_store () const
|
|
|
|
{ return this+varStore; }
|
|
|
|
|
2019-02-22 23:53:06 +01:00
|
|
|
void listup_index_maps (hb_vector_t<const DeltaSetIndexMap *> &index_maps) const
|
|
|
|
{
|
|
|
|
index_maps.push (&(this+advMap));
|
|
|
|
index_maps.push (&(this+lsbMap));
|
|
|
|
index_maps.push (&(this+rsbMap));
|
|
|
|
}
|
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
bool serialize_index_maps (hb_serialize_context_t *c,
|
2019-02-22 00:47:27 +01:00
|
|
|
const hb_array_t<index_map_subset_plan_t> &im_plans)
|
2019-02-21 00:48:29 +01:00
|
|
|
{
|
2019-05-02 20:25:10 +02:00
|
|
|
TRACE_SERIALIZE (this);
|
2019-03-20 23:10:59 +01:00
|
|
|
if (im_plans[index_map_subset_plan_t::ADV_INDEX].is_identity ())
|
2019-03-30 07:53:06 +01:00
|
|
|
advMap = 0;
|
2021-06-29 23:23:37 +02:00
|
|
|
else if (unlikely (!advMap.serialize_serialize (c, im_plans[index_map_subset_plan_t::ADV_INDEX])))
|
2019-02-21 00:48:29 +01:00
|
|
|
return_trace (false);
|
2019-03-20 23:10:59 +01:00
|
|
|
if (im_plans[index_map_subset_plan_t::LSB_INDEX].is_identity ())
|
2019-03-30 07:53:06 +01:00
|
|
|
lsbMap = 0;
|
2021-06-29 23:23:37 +02:00
|
|
|
else if (unlikely (!lsbMap.serialize_serialize (c, im_plans[index_map_subset_plan_t::LSB_INDEX])))
|
2019-02-21 00:48:29 +01:00
|
|
|
return_trace (false);
|
2019-03-20 23:10:59 +01:00
|
|
|
if (im_plans[index_map_subset_plan_t::RSB_INDEX].is_identity ())
|
2019-03-30 07:53:06 +01:00
|
|
|
rsbMap = 0;
|
2021-06-29 23:23:37 +02:00
|
|
|
else if (unlikely (!rsbMap.serialize_serialize (c, im_plans[index_map_subset_plan_t::RSB_INDEX])))
|
2019-02-21 00:48:29 +01:00
|
|
|
return_trace (false);
|
2019-02-22 00:47:27 +01:00
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
bool _subset (hb_subset_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
|
|
|
hvarvvar_subset_plan_t hvar_plan;
|
|
|
|
hb_vector_t<const DeltaSetIndexMap *>
|
|
|
|
index_maps;
|
|
|
|
|
2019-02-22 23:53:06 +01:00
|
|
|
((T*)this)->listup_index_maps (index_maps);
|
2019-02-21 00:48:29 +01:00
|
|
|
hvar_plan.init (index_maps.as_array (), this+varStore, c->plan);
|
|
|
|
|
2019-02-22 00:47:27 +01:00
|
|
|
T *out = c->serializer->allocate_min<T> ();
|
2019-02-21 00:48:29 +01:00
|
|
|
if (unlikely (!out)) return_trace (false);
|
|
|
|
|
2019-03-30 07:53:06 +01:00
|
|
|
out->version.major = 1;
|
|
|
|
out->version.minor = 0;
|
2019-02-21 00:48:29 +01:00
|
|
|
|
2021-06-29 23:23:37 +02:00
|
|
|
if (unlikely (!out->varStore
|
|
|
|
.serialize_serialize (c->serializer,
|
|
|
|
hvar_plan.var_store,
|
|
|
|
hvar_plan.inner_maps.as_array ())))
|
2019-02-21 00:48:29 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
|
|
|
return_trace (out->T::serialize_index_maps (c->serializer,
|
2019-02-22 00:47:27 +01:00
|
|
|
hvar_plan.index_map_plans.as_array ()));
|
2019-02-21 00:48:29 +01:00
|
|
|
}
|
|
|
|
|
2022-07-03 21:04:27 +02:00
|
|
|
float get_advance_delta_unscaled (hb_codepoint_t glyph,
|
|
|
|
const int *coords, unsigned int coord_count,
|
|
|
|
VariationStore::cache_t *store_cache = nullptr) const
|
2017-01-23 20:56:08 +01:00
|
|
|
{
|
2021-03-31 19:31:49 +02:00
|
|
|
uint32_t varidx = (this+advMap).map (glyph);
|
2022-05-21 01:03:18 +02:00
|
|
|
return (this+varStore).get_delta (varidx,
|
2022-06-30 22:25:09 +02:00
|
|
|
coords, coord_count,
|
2022-05-21 01:03:18 +02:00
|
|
|
store_cache);
|
2017-01-23 20:56:08 +01:00
|
|
|
}
|
|
|
|
|
2022-07-03 21:03:12 +02:00
|
|
|
bool get_lsb_delta_unscaled (hb_codepoint_t glyph,
|
|
|
|
const int *coords, unsigned int coord_count,
|
|
|
|
float *lsb) const
|
2019-03-17 23:36:26 +01:00
|
|
|
{
|
2022-07-02 19:21:36 +02:00
|
|
|
if (!lsbMap) return false;
|
2021-03-31 19:31:49 +02:00
|
|
|
uint32_t varidx = (this+lsbMap).map (glyph);
|
2022-07-02 19:21:36 +02:00
|
|
|
*lsb = (this+varStore).get_delta (varidx, coords, coord_count);
|
|
|
|
return true;
|
2019-03-17 23:36:26 +01:00
|
|
|
}
|
|
|
|
|
2022-05-21 01:03:18 +02:00
|
|
|
public:
|
2017-01-23 20:41:43 +01:00
|
|
|
FixedVersion<>version; /* Version of the metrics variation table
|
|
|
|
* initially set to 0x00010000u */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset32To<VariationStore>
|
2017-01-23 20:41:43 +01:00
|
|
|
varStore; /* Offset to item variation store table. */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset32To<DeltaSetIndexMap>
|
2017-01-23 20:41:43 +01:00
|
|
|
advMap; /* Offset to advance var-idx mapping. */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset32To<DeltaSetIndexMap>
|
2017-01-23 20:41:43 +01:00
|
|
|
lsbMap; /* Offset to lsb/tsb var-idx mapping. */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset32To<DeltaSetIndexMap>
|
2017-01-23 20:41:43 +01:00
|
|
|
rsbMap; /* Offset to rsb/bsb var-idx mapping. */
|
|
|
|
|
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (20);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HVAR : HVARVVAR {
|
2019-01-22 12:08:57 +01:00
|
|
|
static constexpr hb_tag_t tableTag = HB_OT_TAG_HVAR;
|
2019-02-21 00:48:29 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const { return HVARVVAR::_subset<HVAR> (c); }
|
2017-01-23 20:41:43 +01:00
|
|
|
};
|
|
|
|
struct VVAR : HVARVVAR {
|
2019-01-22 12:08:57 +01:00
|
|
|
static constexpr hb_tag_t tableTag = HB_OT_TAG_VVAR;
|
2017-01-23 20:41:43 +01:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2017-01-23 20:41:43 +01:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (static_cast<const HVARVVAR *> (this)->sanitize (c) &&
|
|
|
|
vorgMap.sanitize (c, this));
|
|
|
|
}
|
|
|
|
|
2019-02-22 23:53:06 +01:00
|
|
|
void listup_index_maps (hb_vector_t<const DeltaSetIndexMap *> &index_maps) const
|
|
|
|
{
|
|
|
|
HVARVVAR::listup_index_maps (index_maps);
|
|
|
|
index_maps.push (&(this+vorgMap));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool serialize_index_maps (hb_serialize_context_t *c,
|
|
|
|
const hb_array_t<index_map_subset_plan_t> &im_plans)
|
|
|
|
{
|
2019-05-02 20:25:10 +02:00
|
|
|
TRACE_SERIALIZE (this);
|
2019-02-22 23:53:06 +01:00
|
|
|
if (unlikely (!HVARVVAR::serialize_index_maps (c, im_plans)))
|
|
|
|
return_trace (false);
|
2019-03-20 23:10:59 +01:00
|
|
|
if (!im_plans[index_map_subset_plan_t::VORG_INDEX].get_map_count ())
|
2019-03-30 07:53:06 +01:00
|
|
|
vorgMap = 0;
|
2021-06-29 23:23:37 +02:00
|
|
|
else if (unlikely (!vorgMap.serialize_serialize (c, im_plans[index_map_subset_plan_t::VORG_INDEX])))
|
2019-02-22 23:53:06 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
2019-02-21 00:48:29 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const { return HVARVVAR::_subset<VVAR> (c); }
|
|
|
|
|
2022-07-03 21:00:22 +02:00
|
|
|
bool get_vorg_delta_unscaled (hb_codepoint_t glyph,
|
|
|
|
const int *coords, unsigned int coord_count,
|
|
|
|
float *delta) const
|
2022-06-30 22:08:29 +02:00
|
|
|
{
|
|
|
|
if (!vorgMap) return false;
|
|
|
|
uint32_t varidx = (this+vorgMap).map (glyph);
|
|
|
|
*delta = (this+varStore).get_delta (varidx, coords, coord_count);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-23 20:41:43 +01:00
|
|
|
protected:
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset32To<DeltaSetIndexMap>
|
2017-01-23 20:41:43 +01:00
|
|
|
vorgMap; /* Offset to vertical-origin var-idx mapping. */
|
|
|
|
|
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (24);
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace OT */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* HB_OT_VAR_HVAR_TABLE_HH */
|