2009-05-18 23:09:33 +02:00
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
* Copyright © 2007,2008,2009,2010 Red Hat, Inc.
|
2013-04-24 22:42:05 +02:00
|
|
|
* Copyright © 2010,2012,2013 Google, Inc.
|
2009-05-18 23:09:33 +02:00
|
|
|
*
|
2010-04-22 06:11:43 +02:00
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
2009-05-18 23:09:33 +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
|
2010-10-27 23:39:01 +02:00
|
|
|
* Google Author(s): Behdad Esfahbod
|
2009-05-18 23:09:33 +02:00
|
|
|
*/
|
|
|
|
|
2011-08-17 14:19:59 +02:00
|
|
|
#ifndef HB_OT_LAYOUT_GPOS_TABLE_HH
|
|
|
|
#define HB_OT_LAYOUT_GPOS_TABLE_HH
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-ot-layout-gsubgpos.hh"
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
2012-08-28 23:57:49 +02:00
|
|
|
namespace OT {
|
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
struct MarkArray;
|
|
|
|
static void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage,
|
|
|
|
const MarkArray &mark_array,
|
|
|
|
const hb_set_t &glyphset,
|
|
|
|
hb_map_t* klass_mapping /* INOUT */);
|
2010-05-05 07:13:09 +02:00
|
|
|
|
2011-07-28 22:48:43 +02:00
|
|
|
/* buffer **position** var allocations */
|
2016-02-11 09:25:28 +01:00
|
|
|
#define attach_chain() var.i16[0] /* glyph to which this attaches to, relative to current glyphs; negative for going back, positive for forward. */
|
|
|
|
#define attach_type() var.u8[2] /* attachment type */
|
|
|
|
/* Note! if attach_chain() is zero, the value of attach_type() is irrelevant. */
|
|
|
|
|
|
|
|
enum attach_type_t {
|
|
|
|
ATTACH_TYPE_NONE = 0X00,
|
|
|
|
|
|
|
|
/* Each attachment should be either a mark or a cursive; can't be both. */
|
|
|
|
ATTACH_TYPE_MARK = 0X01,
|
|
|
|
ATTACH_TYPE_CURSIVE = 0X02,
|
|
|
|
};
|
2010-10-28 05:09:10 +02:00
|
|
|
|
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
/* Shared Tables: ValueRecord, Anchor Table, and MarkArray */
|
|
|
|
|
2018-01-10 03:07:30 +01:00
|
|
|
typedef HBUINT16 Value;
|
2009-08-27 00:53:43 +02:00
|
|
|
|
2018-11-11 01:54:08 +01:00
|
|
|
typedef UnsizedArrayOf<Value> ValueRecord;
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2018-01-10 03:07:30 +01:00
|
|
|
struct ValueFormat : HBUINT16
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2012-04-12 19:23:59 +02:00
|
|
|
enum Flags {
|
2014-07-11 20:54:42 +02:00
|
|
|
xPlacement = 0x0001u, /* Includes horizontal adjustment for placement */
|
|
|
|
yPlacement = 0x0002u, /* Includes vertical adjustment for placement */
|
|
|
|
xAdvance = 0x0004u, /* Includes horizontal adjustment for advance */
|
|
|
|
yAdvance = 0x0008u, /* Includes vertical adjustment for advance */
|
|
|
|
xPlaDevice = 0x0010u, /* Includes horizontal Device table for placement */
|
|
|
|
yPlaDevice = 0x0020u, /* Includes vertical Device table for placement */
|
|
|
|
xAdvDevice = 0x0040u, /* Includes horizontal Device table for advance */
|
|
|
|
yAdvDevice = 0x0080u, /* Includes vertical Device table for advance */
|
|
|
|
ignored = 0x0F00u, /* Was used in TrueType Open for MM fonts */
|
|
|
|
reserved = 0xF000u, /* For future use */
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2014-07-11 20:54:42 +02:00
|
|
|
devices = 0x00F0u /* Mask for having any Device table */
|
2010-04-21 08:02:57 +02:00
|
|
|
};
|
2009-05-21 10:49:04 +02:00
|
|
|
|
2010-04-21 08:02:57 +02:00
|
|
|
/* All fields are options. Only those available advance the value pointer. */
|
2009-05-21 10:49:04 +02:00
|
|
|
#if 0
|
2020-07-18 19:44:52 +02:00
|
|
|
HBINT16 xPlacement; /* Horizontal adjustment for
|
2009-05-21 10:49:04 +02:00
|
|
|
* placement--in design units */
|
2020-07-18 19:44:52 +02:00
|
|
|
HBINT16 yPlacement; /* Vertical adjustment for
|
2009-05-21 10:49:04 +02:00
|
|
|
* placement--in design units */
|
2020-07-18 19:44:52 +02:00
|
|
|
HBINT16 xAdvance; /* Horizontal adjustment for
|
2009-05-21 10:49:04 +02:00
|
|
|
* advance--in design units (only used
|
|
|
|
* for horizontal writing) */
|
2020-07-18 19:44:52 +02:00
|
|
|
HBINT16 yAdvance; /* Vertical adjustment for advance--in
|
2009-05-21 10:49:04 +02:00
|
|
|
* design units (only used for vertical
|
|
|
|
* writing) */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Device> xPlaDevice; /* Offset to Device table for
|
2009-05-21 10:49:04 +02:00
|
|
|
* horizontal placement--measured from
|
|
|
|
* beginning of PosTable (may be NULL) */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Device> yPlaDevice; /* Offset to Device table for vertical
|
2009-05-21 10:49:04 +02:00
|
|
|
* placement--measured from beginning
|
|
|
|
* of PosTable (may be NULL) */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Device> xAdvDevice; /* Offset to Device table for
|
2009-05-21 10:49:04 +02:00
|
|
|
* horizontal advance--measured from
|
|
|
|
* beginning of PosTable (may be NULL) */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Device> yAdvDevice; /* Offset to Device table for vertical
|
2009-05-21 10:49:04 +02:00
|
|
|
* advance--measured from beginning of
|
|
|
|
* PosTable (may be NULL) */
|
|
|
|
#endif
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2021-04-23 01:45:14 +02:00
|
|
|
IntType& operator = (uint16_t i) { v = i; return *this; }
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
unsigned int get_len () const { return hb_popcount ((unsigned int) *this); }
|
|
|
|
unsigned int get_size () const { return get_len () * Value::static_size; }
|
2010-04-21 08:02:57 +02:00
|
|
|
|
2019-10-01 12:19:55 +02:00
|
|
|
bool apply_value (hb_ot_apply_context_t *c,
|
|
|
|
const void *base,
|
|
|
|
const Value *values,
|
|
|
|
hb_glyph_position_t &glyph_pos) const
|
2010-04-21 08:02:57 +02:00
|
|
|
{
|
2018-11-07 21:40:55 +01:00
|
|
|
bool ret = false;
|
2010-04-21 08:02:57 +02:00
|
|
|
unsigned int format = *this;
|
2018-11-07 21:40:55 +01:00
|
|
|
if (!format) return ret;
|
2010-04-21 08:02:57 +02:00
|
|
|
|
2016-09-10 02:03:11 +02:00
|
|
|
hb_font_t *font = c->font;
|
2018-11-07 23:19:21 +01:00
|
|
|
bool horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction);
|
2016-09-10 02:03:11 +02:00
|
|
|
|
2018-11-07 21:40:55 +01:00
|
|
|
if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++, &ret));
|
|
|
|
if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++, &ret));
|
2011-05-20 21:59:59 +02:00
|
|
|
if (format & xAdvance) {
|
2018-11-07 21:40:55 +01:00
|
|
|
if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_short (values, &ret));
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2011-05-20 21:59:59 +02:00
|
|
|
}
|
2011-05-20 01:19:50 +02:00
|
|
|
/* y_advance values grow downward but font-space grows upward, hence negation */
|
2011-05-20 21:59:59 +02:00
|
|
|
if (format & yAdvance) {
|
2018-11-07 21:40:55 +01:00
|
|
|
if (unlikely (!horizontal)) glyph_pos.y_advance -= font->em_scale_y (get_short (values, &ret));
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2011-05-20 21:59:59 +02:00
|
|
|
}
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2018-11-07 21:40:55 +01:00
|
|
|
if (!has_device ()) return ret;
|
2010-04-29 20:31:56 +02:00
|
|
|
|
2016-03-01 11:29:36 +01:00
|
|
|
bool use_x_device = font->x_ppem || font->num_coords;
|
|
|
|
bool use_y_device = font->y_ppem || font->num_coords;
|
2010-04-29 20:31:56 +02:00
|
|
|
|
2018-11-07 21:40:55 +01:00
|
|
|
if (!use_x_device && !use_y_device) return ret;
|
2010-04-29 20:31:56 +02:00
|
|
|
|
2016-09-10 09:22:24 +02:00
|
|
|
const VariationStore &store = c->var_store;
|
2016-09-10 02:03:11 +02:00
|
|
|
|
2009-07-30 22:28:45 +02:00
|
|
|
/* pixel -> fractional pixel */
|
|
|
|
if (format & xPlaDevice) {
|
2018-11-07 21:40:55 +01:00
|
|
|
if (use_x_device) glyph_pos.x_offset += (base + get_device (values, &ret)).get_x_delta (font, store);
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2009-07-30 22:28:45 +02:00
|
|
|
}
|
|
|
|
if (format & yPlaDevice) {
|
2018-11-07 21:40:55 +01:00
|
|
|
if (use_y_device) glyph_pos.y_offset += (base + get_device (values, &ret)).get_y_delta (font, store);
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2009-07-30 22:28:45 +02:00
|
|
|
}
|
|
|
|
if (format & xAdvDevice) {
|
2018-11-07 21:40:55 +01:00
|
|
|
if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values, &ret)).get_x_delta (font, store);
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2009-07-30 22:28:45 +02:00
|
|
|
}
|
|
|
|
if (format & yAdvDevice) {
|
2011-05-20 01:19:50 +02:00
|
|
|
/* y_advance values grow downward but font-space grows upward, hence negation */
|
2018-11-07 21:40:55 +01:00
|
|
|
if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values, &ret)).get_y_delta (font, store);
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2009-05-19 01:47:52 +02:00
|
|
|
}
|
2018-11-07 21:40:55 +01:00
|
|
|
return ret;
|
2009-05-19 01:47:52 +02:00
|
|
|
}
|
2010-04-21 08:02:57 +02:00
|
|
|
|
2021-04-24 00:21:30 +02:00
|
|
|
unsigned int get_effective_format (const Value *values) const
|
|
|
|
{
|
|
|
|
unsigned int format = *this;
|
2021-04-24 04:09:37 +02:00
|
|
|
for (unsigned flag = xPlacement; flag <= yAdvDevice; flag = flag << 1) {
|
|
|
|
if (format & flag) should_drop (*values++, (Flags) flag, &format);
|
|
|
|
}
|
|
|
|
|
2021-04-24 00:21:30 +02:00
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Iterator,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
2021-04-24 01:32:56 +02:00
|
|
|
unsigned int get_effective_format (Iterator it) const {
|
2021-04-24 00:21:30 +02:00
|
|
|
unsigned int new_format = 0;
|
|
|
|
|
|
|
|
for (const hb_array_t<const Value>& values : it)
|
|
|
|
new_format = new_format | get_effective_format (&values);
|
|
|
|
|
|
|
|
return new_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
void copy_values (hb_serialize_context_t *c,
|
|
|
|
unsigned int new_format,
|
|
|
|
const void *base,
|
|
|
|
const Value *values,
|
|
|
|
const hb_map_t *layout_variation_idx_map) const
|
2020-01-16 00:32:44 +01:00
|
|
|
{
|
|
|
|
unsigned int format = *this;
|
|
|
|
if (!format) return;
|
|
|
|
|
2021-04-24 00:21:30 +02:00
|
|
|
if (format & xPlacement) copy_value (c, new_format, xPlacement, *values++);
|
2021-04-24 01:32:56 +02:00
|
|
|
if (format & yPlacement) copy_value (c, new_format, yPlacement, *values++);
|
|
|
|
if (format & xAdvance) copy_value (c, new_format, xAdvance, *values++);
|
|
|
|
if (format & yAdvance) copy_value (c, new_format, yAdvance, *values++);
|
2020-01-16 00:32:44 +01:00
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
if (format & xPlaDevice) copy_device (c, base, values++, layout_variation_idx_map);
|
|
|
|
if (format & yPlaDevice) copy_device (c, base, values++, layout_variation_idx_map);
|
|
|
|
if (format & xAdvDevice) copy_device (c, base, values++, layout_variation_idx_map);
|
|
|
|
if (format & yAdvDevice) copy_device (c, base, values++, layout_variation_idx_map);
|
2020-01-16 00:32:44 +01:00
|
|
|
}
|
|
|
|
|
2021-04-24 00:21:30 +02:00
|
|
|
void copy_value (hb_serialize_context_t *c,
|
|
|
|
unsigned int new_format,
|
|
|
|
Flags flag,
|
|
|
|
Value value) const
|
|
|
|
{
|
|
|
|
// Filter by new format.
|
|
|
|
if (!(new_format & flag)) return;
|
|
|
|
c->copy (value);
|
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
2020-07-29 06:03:32 +02:00
|
|
|
const void *base,
|
|
|
|
const hb_array_t<const Value>& values) const
|
2020-02-26 22:11:42 +01:00
|
|
|
{
|
|
|
|
unsigned format = *this;
|
|
|
|
unsigned i = 0;
|
|
|
|
if (format & xPlacement) i++;
|
|
|
|
if (format & yPlacement) i++;
|
|
|
|
if (format & xAdvance) i++;
|
|
|
|
if (format & yAdvance) i++;
|
|
|
|
if (format & xPlaDevice)
|
|
|
|
{
|
|
|
|
(base + get_device (&(values[i]))).collect_variation_indices (c->layout_variation_indices);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format & ValueFormat::yPlaDevice)
|
|
|
|
{
|
|
|
|
(base + get_device (&(values[i]))).collect_variation_indices (c->layout_variation_indices);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format & ValueFormat::xAdvDevice)
|
|
|
|
{
|
|
|
|
|
|
|
|
(base + get_device (&(values[i]))).collect_variation_indices (c->layout_variation_indices);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format & ValueFormat::yAdvDevice)
|
|
|
|
{
|
|
|
|
|
|
|
|
(base + get_device (&(values[i]))).collect_variation_indices (c->layout_variation_indices);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-21 08:02:57 +02:00
|
|
|
private:
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_value_devices (hb_sanitize_context_t *c, const void *base, const Value *values) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2010-04-21 08:02:57 +02:00
|
|
|
unsigned int format = *this;
|
|
|
|
|
|
|
|
if (format & xPlacement) values++;
|
|
|
|
if (format & yPlacement) values++;
|
|
|
|
if (format & xAdvance) values++;
|
|
|
|
if (format & yAdvance) values++;
|
|
|
|
|
2010-05-13 20:18:49 +02:00
|
|
|
if ((format & xPlaDevice) && !get_device (values++).sanitize (c, base)) return false;
|
|
|
|
if ((format & yPlaDevice) && !get_device (values++).sanitize (c, base)) return false;
|
|
|
|
if ((format & xAdvDevice) && !get_device (values++).sanitize (c, base)) return false;
|
|
|
|
if ((format & yAdvDevice) && !get_device (values++).sanitize (c, base)) return false;
|
2010-04-21 08:02:57 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-31 20:49:14 +02:00
|
|
|
static inline Offset16To<Device>& get_device (Value* value)
|
2020-02-26 22:11:42 +01:00
|
|
|
{
|
2021-03-31 20:49:14 +02:00
|
|
|
return *static_cast<Offset16To<Device> *> (value);
|
2020-02-26 22:11:42 +01:00
|
|
|
}
|
2021-03-31 20:49:14 +02:00
|
|
|
static inline const Offset16To<Device>& get_device (const Value* value, bool *worked=nullptr)
|
2020-02-26 22:11:42 +01:00
|
|
|
{
|
|
|
|
if (worked) *worked |= bool (*value);
|
2021-03-31 20:49:14 +02:00
|
|
|
return *static_cast<const Offset16To<Device> *> (value);
|
2020-02-26 22:11:42 +01:00
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
bool copy_device (hb_serialize_context_t *c, const void *base,
|
2020-07-29 06:03:32 +02:00
|
|
|
const Value *src_value, const hb_map_t *layout_variation_idx_map) const
|
2020-01-16 00:32:44 +01:00
|
|
|
{
|
|
|
|
Value *dst_value = c->copy (*src_value);
|
|
|
|
|
|
|
|
if (!dst_value) return false;
|
|
|
|
if (*dst_value == 0) return true;
|
|
|
|
|
|
|
|
*dst_value = 0;
|
|
|
|
c->push ();
|
2020-02-26 22:11:42 +01:00
|
|
|
if ((base + get_device (src_value)).copy (c, layout_variation_idx_map))
|
2020-01-16 00:32:44 +01:00
|
|
|
{
|
2020-03-07 20:02:36 +01:00
|
|
|
c->add_link (*dst_value, c->pop_pack ());
|
2020-01-16 00:32:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
c->pop_discard ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-10 20:31:50 +01:00
|
|
|
static inline const HBINT16& get_short (const Value* value, bool *worked=nullptr)
|
2018-11-07 21:40:55 +01:00
|
|
|
{
|
2018-12-21 21:05:00 +01:00
|
|
|
if (worked) *worked |= bool (*value);
|
2019-12-10 20:02:48 +01:00
|
|
|
return *reinterpret_cast<const HBINT16 *> (value);
|
2018-11-07 21:40:55 +01:00
|
|
|
}
|
2010-05-06 19:06:15 +02:00
|
|
|
|
2010-04-21 08:02:57 +02:00
|
|
|
public:
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
bool has_device () const
|
2018-12-16 20:08:10 +01:00
|
|
|
{
|
2010-04-21 08:02:57 +02:00
|
|
|
unsigned int format = *this;
|
|
|
|
return (format & devices) != 0;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_value (hb_sanitize_context_t *c, const void *base, const Value *values) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_range (values, get_size ()) && (!has_device () || sanitize_value_devices (c, base, values)));
|
2010-04-21 08:02:57 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_values (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2010-04-21 08:02:57 +02:00
|
|
|
unsigned int len = get_len ();
|
|
|
|
|
2018-11-12 20:23:31 +01:00
|
|
|
if (!c->check_range (values, count, get_size ())) return_trace (false);
|
2010-04-21 08:02:57 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!has_device ()) return_trace (true);
|
2010-04-21 08:02:57 +02:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < count; i++) {
|
2010-05-13 20:18:49 +02:00
|
|
|
if (!sanitize_value_devices (c, base, values))
|
2018-11-15 20:40:56 +01:00
|
|
|
return_trace (false);
|
2010-04-21 08:02:57 +02:00
|
|
|
values += len;
|
|
|
|
}
|
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2010-04-21 08:02:57 +02:00
|
|
|
}
|
|
|
|
|
2010-04-22 19:59:39 +02:00
|
|
|
/* Just sanitize referenced Device tables. Doesn't check the values themselves. */
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count, unsigned int stride) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2010-04-21 08:02:57 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!has_device ()) return_trace (true);
|
2010-04-21 08:02:57 +02:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < count; i++) {
|
2010-05-13 20:18:49 +02:00
|
|
|
if (!sanitize_value_devices (c, base, values))
|
2018-11-15 20:40:56 +01:00
|
|
|
return_trace (false);
|
2010-04-21 08:02:57 +02:00
|
|
|
values += stride;
|
|
|
|
}
|
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2010-04-21 08:02:57 +02:00
|
|
|
}
|
2021-04-24 00:21:30 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void should_drop (Value value, Flags flag, unsigned int* format) const
|
|
|
|
{
|
|
|
|
if (value) return;
|
|
|
|
*format = *format & ~flag;
|
|
|
|
}
|
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
template<typename Iterator, typename SrcLookup>
|
2019-12-10 20:21:26 +01:00
|
|
|
static void SinglePos_serialize (hb_serialize_context_t *c,
|
2021-04-24 01:32:56 +02:00
|
|
|
const SrcLookup *src,
|
2019-12-10 20:21:26 +01:00
|
|
|
Iterator it,
|
2020-07-29 06:03:32 +02:00
|
|
|
const hb_map_t *layout_variation_idx_map);
|
2019-07-03 01:30:57 +02:00
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct AnchorFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
|
|
|
|
float *x, float *y) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2016-09-10 01:27:03 +02:00
|
|
|
hb_font_t *font = c->font;
|
2018-01-10 05:13:47 +01:00
|
|
|
*x = font->em_fscale_x (xCoordinate);
|
|
|
|
*y = font->em_fscale_y (yCoordinate);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
2019-10-01 12:19:55 +02:00
|
|
|
|
2019-09-19 01:11:44 +02:00
|
|
|
AnchorFormat1* copy (hb_serialize_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_SERIALIZE (this);
|
2021-04-02 23:37:10 +02:00
|
|
|
AnchorFormat1* out = c->embed<AnchorFormat1> (this);
|
2021-04-08 02:15:32 +02:00
|
|
|
if (!out) return_trace (out);
|
2021-04-02 23:37:10 +02:00
|
|
|
out->format = 1;
|
|
|
|
return_trace (out);
|
2019-09-19 01:11:44 +02:00
|
|
|
}
|
2009-08-04 19:30:49 +02:00
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2018-02-26 10:08:00 +01:00
|
|
|
FWORD xCoordinate; /* Horizontal value--in design units */
|
|
|
|
FWORD yCoordinate; /* Vertical value--in design units */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (6);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct AnchorFormat2
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id,
|
|
|
|
float *x, float *y) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2016-09-10 01:27:03 +02:00
|
|
|
hb_font_t *font = c->font;
|
2019-06-20 04:33:15 +02:00
|
|
|
|
|
|
|
#ifdef HB_NO_HINTING
|
|
|
|
*x = font->em_fscale_x (xCoordinate);
|
|
|
|
*y = font->em_fscale_y (yCoordinate);
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2016-09-10 01:27:03 +02:00
|
|
|
unsigned int x_ppem = font->x_ppem;
|
|
|
|
unsigned int y_ppem = font->y_ppem;
|
2018-04-23 16:09:40 +02:00
|
|
|
hb_position_t cx = 0, cy = 0;
|
2018-11-07 23:19:21 +01:00
|
|
|
bool ret;
|
2010-04-29 09:59:06 +02:00
|
|
|
|
2016-09-10 01:27:03 +02:00
|
|
|
ret = (x_ppem || y_ppem) &&
|
2018-11-07 23:19:21 +01:00
|
|
|
font->get_glyph_contour_point_for_origin (glyph_id, anchorPoint, HB_DIRECTION_LTR, &cx, &cy);
|
2018-01-10 05:13:47 +01:00
|
|
|
*x = ret && x_ppem ? cx : font->em_fscale_x (xCoordinate);
|
|
|
|
*y = ret && y_ppem ? cy : font->em_fscale_y (yCoordinate);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2019-09-19 01:11:44 +02:00
|
|
|
AnchorFormat2* copy (hb_serialize_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_SERIALIZE (this);
|
|
|
|
return_trace (c->embed<AnchorFormat2> (this));
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 2 */
|
2018-02-26 10:08:00 +01:00
|
|
|
FWORD xCoordinate; /* Horizontal value--in design units */
|
|
|
|
FWORD yCoordinate; /* Vertical value--in design units */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 anchorPoint; /* Index to glyph contour point */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (8);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct AnchorFormat3
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
|
|
|
|
float *x, float *y) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2016-09-10 01:27:03 +02:00
|
|
|
hb_font_t *font = c->font;
|
2018-01-10 05:13:47 +01:00
|
|
|
*x = font->em_fscale_x (xCoordinate);
|
|
|
|
*y = font->em_fscale_y (yCoordinate);
|
2009-05-21 10:54:01 +02:00
|
|
|
|
2016-09-10 01:27:03 +02:00
|
|
|
if (font->x_ppem || font->num_coords)
|
2016-09-10 02:03:11 +02:00
|
|
|
*x += (this+xDeviceTable).get_x_delta (font, c->var_store);
|
2016-09-10 01:27:03 +02:00
|
|
|
if (font->y_ppem || font->num_coords)
|
2016-09-10 07:48:27 +02:00
|
|
|
*y += (this+yDeviceTable).get_y_delta (font, c->var_store);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) && xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
AnchorFormat3* copy (hb_serialize_context_t *c,
|
|
|
|
const hb_map_t *layout_variation_idx_map) const
|
2019-09-19 01:11:44 +02:00
|
|
|
{
|
|
|
|
TRACE_SERIALIZE (this);
|
2020-02-26 22:11:42 +01:00
|
|
|
if (!layout_variation_idx_map) return_trace (nullptr);
|
|
|
|
|
2019-09-19 01:11:44 +02:00
|
|
|
auto *out = c->embed<AnchorFormat3> (this);
|
|
|
|
if (unlikely (!out)) return_trace (nullptr);
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
out->xDeviceTable.serialize_copy (c, xDeviceTable, this, 0, hb_serialize_context_t::Head, layout_variation_idx_map);
|
|
|
|
out->yDeviceTable.serialize_copy (c, yDeviceTable, this, 0, hb_serialize_context_t::Head, layout_variation_idx_map);
|
2019-09-19 01:11:44 +02:00
|
|
|
return_trace (out);
|
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
(this+xDeviceTable).collect_variation_indices (c->layout_variation_indices);
|
|
|
|
(this+yDeviceTable).collect_variation_indices (c->layout_variation_indices);
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 3 */
|
2018-02-26 10:08:00 +01:00
|
|
|
FWORD xCoordinate; /* Horizontal value--in design units */
|
|
|
|
FWORD yCoordinate; /* Vertical value--in design units */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Device>
|
2009-05-18 23:09:33 +02:00
|
|
|
xDeviceTable; /* Offset to Device table for X
|
|
|
|
* coordinate-- from beginning of
|
|
|
|
* Anchor table (may be NULL) */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Device>
|
2009-05-18 23:09:33 +02:00
|
|
|
yDeviceTable; /* Offset to Device table for Y
|
|
|
|
* coordinate-- from beginning of
|
|
|
|
* Anchor table (may be NULL) */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (10);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct Anchor
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id,
|
|
|
|
float *x, float *y) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2009-05-18 23:09:33 +02:00
|
|
|
*x = *y = 0;
|
|
|
|
switch (u.format) {
|
2016-09-10 01:27:03 +02:00
|
|
|
case 1: u.format1.get_anchor (c, glyph_id, x, y); return;
|
|
|
|
case 2: u.format2.get_anchor (c, glyph_id, x, y); return;
|
|
|
|
case 3: u.format3.get_anchor (c, glyph_id, x, y); return;
|
2018-01-10 04:33:08 +01:00
|
|
|
default: return;
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!u.format.sanitize (c)) return_trace (false);
|
2009-08-04 19:30:49 +02:00
|
|
|
switch (u.format) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (u.format1.sanitize (c));
|
|
|
|
case 2: return_trace (u.format2.sanitize (c));
|
|
|
|
case 3: return_trace (u.format3.sanitize (c));
|
|
|
|
default:return_trace (true);
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2019-09-19 01:11:44 +02:00
|
|
|
{
|
2021-04-02 23:37:10 +02:00
|
|
|
TRACE_SUBSET (this);
|
2019-09-19 01:11:44 +02:00
|
|
|
switch (u.format) {
|
2021-04-02 23:37:10 +02:00
|
|
|
case 1: return_trace (bool (reinterpret_cast<Anchor *> (u.format1.copy (c->serializer))));
|
2021-04-23 00:18:35 +02:00
|
|
|
case 2:
|
2021-07-30 00:07:13 +02:00
|
|
|
if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
|
2021-04-23 00:18:35 +02:00
|
|
|
{
|
|
|
|
// AnchorFormat 2 just containins extra hinting information, so
|
|
|
|
// if hints are being dropped convert to format 1.
|
|
|
|
return_trace (bool (reinterpret_cast<Anchor *> (u.format1.copy (c->serializer))));
|
|
|
|
}
|
|
|
|
return_trace (bool (reinterpret_cast<Anchor *> (u.format2.copy (c->serializer))));
|
2021-04-02 23:37:10 +02:00
|
|
|
case 3: return_trace (bool (reinterpret_cast<Anchor *> (u.format3.copy (c->serializer,
|
2021-04-23 00:18:35 +02:00
|
|
|
c->plan->layout_variation_idx_map))));
|
2021-04-02 23:37:10 +02:00
|
|
|
default:return_trace (false);
|
2019-09-19 01:11:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
switch (u.format) {
|
|
|
|
case 1: case 2:
|
|
|
|
return;
|
|
|
|
case 3:
|
|
|
|
u.format3.collect_variation_indices (c);
|
|
|
|
return;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
AnchorFormat1 format1;
|
|
|
|
AnchorFormat2 format2;
|
|
|
|
AnchorFormat3 format3;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
2010-05-11 00:08:46 +02:00
|
|
|
public:
|
2010-05-11 00:47:48 +02:00
|
|
|
DEFINE_SIZE_UNION (2, format);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-15 00:14:03 +02:00
|
|
|
struct AnchorMatrix
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
const Anchor& get_anchor (unsigned int row, unsigned int col,
|
|
|
|
unsigned int cols, bool *found) const
|
|
|
|
{
|
2013-01-08 23:15:46 +01:00
|
|
|
*found = false;
|
2020-04-20 11:42:45 +02:00
|
|
|
if (unlikely (row >= rows || col >= cols)) return Null (Anchor);
|
2014-12-13 06:07:53 +01:00
|
|
|
*found = !matrixZ[row * cols + col].is_null ();
|
|
|
|
return this+matrixZ[row * cols + col];
|
2009-08-15 00:14:03 +02:00
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
template <typename Iterator,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
|
|
|
Iterator index_iter) const
|
|
|
|
{
|
|
|
|
for (unsigned i : index_iter)
|
|
|
|
(this+matrixZ[i]).collect_variation_indices (c);
|
|
|
|
}
|
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
template <typename Iterator,
|
2021-04-02 23:37:10 +02:00
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
|
|
|
bool subset (hb_subset_context_t *c,
|
|
|
|
unsigned num_rows,
|
|
|
|
Iterator index_iter) const
|
2020-02-04 22:24:37 +01:00
|
|
|
{
|
2021-04-02 23:37:10 +02:00
|
|
|
TRACE_SUBSET (this);
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (this);
|
|
|
|
|
2020-08-08 22:04:54 +02:00
|
|
|
if (!index_iter) return_trace (false);
|
2021-04-02 23:37:10 +02:00
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
2020-02-04 22:24:37 +01:00
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
out->rows = num_rows;
|
2020-02-04 22:24:37 +01:00
|
|
|
for (const unsigned i : index_iter)
|
|
|
|
{
|
2021-04-02 23:37:10 +02:00
|
|
|
auto *offset = c->serializer->embed (matrixZ[i]);
|
2020-03-13 20:21:10 +01:00
|
|
|
if (!offset) return_trace (false);
|
2021-04-02 23:37:10 +02:00
|
|
|
offset->serialize_subset (c, matrixZ[i], this);
|
2020-02-04 22:24:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!c->check_struct (this)) return_trace (false);
|
2018-07-10 14:12:37 +02:00
|
|
|
if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false);
|
2009-08-15 00:14:03 +02:00
|
|
|
unsigned int count = rows * cols;
|
2018-09-10 23:29:26 +02:00
|
|
|
if (!c->check_array (matrixZ.arrayZ, count)) return_trace (false);
|
2009-08-15 00:14:03 +02:00
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
|
|
|
|
return_trace (true);
|
2009-08-15 00:14:03 +02:00
|
|
|
}
|
|
|
|
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 rows; /* Number of rows */
|
2021-03-31 20:49:14 +02:00
|
|
|
UnsizedArrayOf<Offset16To<Anchor>>
|
2018-09-10 23:29:26 +02:00
|
|
|
matrixZ; /* Matrix of offsets to Anchor tables--
|
2009-08-15 00:14:03 +02:00
|
|
|
* from beginning of AnchorMatrix table */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2014-12-13 06:07:53 +01:00
|
|
|
DEFINE_SIZE_ARRAY (2, matrixZ);
|
2009-08-15 00:14:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkRecord
|
|
|
|
{
|
2009-05-21 10:58:24 +02:00
|
|
|
friend struct MarkArray;
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
unsigned get_class () const { return (unsigned) klass; }
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) && markAnchor.sanitize (c, base));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
MarkRecord *subset (hb_subset_context_t *c,
|
|
|
|
const void *src_base,
|
|
|
|
const hb_map_t *klass_mapping) const
|
2020-02-04 22:24:37 +01:00
|
|
|
{
|
2021-04-02 23:37:10 +02:00
|
|
|
TRACE_SUBSET (this);
|
|
|
|
auto *out = c->serializer->embed (this);
|
2020-02-04 22:24:37 +01:00
|
|
|
if (unlikely (!out)) return_trace (nullptr);
|
2020-03-08 21:09:24 +01:00
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
out->klass = klass_mapping->get (klass);
|
2021-04-02 23:37:10 +02:00
|
|
|
out->markAnchor.serialize_subset (c, markAnchor, src_base);
|
2020-02-04 22:24:37 +01:00
|
|
|
return_trace (out);
|
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
|
|
|
const void *src_base) const
|
|
|
|
{
|
|
|
|
(src_base+markAnchor).collect_variation_indices (c);
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 klass; /* Class defined for this mark */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Anchor>
|
2009-05-18 23:09:33 +02:00
|
|
|
markAnchor; /* Offset to Anchor table--from
|
|
|
|
* beginning of MarkArray table */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (4);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2021-04-01 00:04:43 +02:00
|
|
|
struct MarkArray : Array16Of<MarkRecord> /* Array of MarkRecords--in Coverage order */
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c,
|
|
|
|
unsigned int mark_index, unsigned int glyph_index,
|
|
|
|
const AnchorMatrix &anchors, unsigned int class_count,
|
|
|
|
unsigned int glyph_pos) const
|
2009-08-15 01:33:24 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
2021-04-01 00:04:43 +02:00
|
|
|
const MarkRecord &record = Array16Of<MarkRecord>::operator[](mark_index);
|
2009-08-15 01:33:24 +02:00
|
|
|
unsigned int mark_class = record.klass;
|
|
|
|
|
|
|
|
const Anchor& mark_anchor = this + record.markAnchor;
|
2013-01-08 23:15:46 +01:00
|
|
|
bool found;
|
|
|
|
const Anchor& glyph_anchor = anchors.get_anchor (glyph_index, mark_class, class_count, &found);
|
|
|
|
/* If this subtable doesn't have an anchor for this base and this class,
|
|
|
|
* return false such that the subsequent subtables have a chance at it. */
|
2015-09-29 15:57:02 +02:00
|
|
|
if (unlikely (!found)) return_trace (false);
|
2009-08-15 01:33:24 +02:00
|
|
|
|
2018-01-10 05:13:47 +01:00
|
|
|
float mark_x, mark_y, base_x, base_y;
|
2009-08-15 01:33:24 +02:00
|
|
|
|
2017-08-11 05:32:02 +02:00
|
|
|
buffer->unsafe_to_break (glyph_pos, buffer->idx);
|
2016-09-10 01:27:03 +02:00
|
|
|
mark_anchor.get_anchor (c, buffer->cur().codepoint, &mark_x, &mark_y);
|
|
|
|
glyph_anchor.get_anchor (c, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
|
2009-08-15 01:33:24 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_glyph_position_t &o = buffer->cur_pos();
|
2019-05-08 08:26:09 +02:00
|
|
|
o.x_offset = roundf (base_x - mark_x);
|
|
|
|
o.y_offset = roundf (base_y - mark_y);
|
2016-02-11 09:25:28 +01:00
|
|
|
o.attach_type() = ATTACH_TYPE_MARK;
|
2016-02-11 08:49:10 +01:00
|
|
|
o.attach_chain() = (int) glyph_pos - (int) buffer->idx;
|
2015-11-05 07:58:58 +01:00
|
|
|
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
|
2009-08-15 01:33:24 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx++;
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2009-08-15 01:33:24 +02:00
|
|
|
}
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
template <typename Iterator,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
|
|
|
bool subset (hb_subset_context_t *c,
|
|
|
|
Iterator coverage,
|
|
|
|
const hb_map_t *klass_mapping) const
|
2020-02-04 22:24:37 +01:00
|
|
|
{
|
2021-04-02 23:37:10 +02:00
|
|
|
TRACE_SUBSET (this);
|
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
|
|
|
|
|
|
|
auto* out = c->serializer->start_embed (this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
|
|
|
|
auto mark_iter =
|
|
|
|
+ hb_zip (coverage, this->iter ())
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
;
|
|
|
|
|
|
|
|
unsigned new_length = 0;
|
|
|
|
for (const auto& mark_record : mark_iter) {
|
|
|
|
if (unlikely (!mark_record.subset (c, this, klass_mapping)))
|
|
|
|
return_trace (false);
|
|
|
|
new_length++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely (!c->serializer->check_assign (out->len, new_length,
|
|
|
|
HB_SERIALIZE_ERROR_ARRAY_OVERFLOW)))
|
|
|
|
return_trace (false);
|
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
return_trace (true);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2021-04-01 00:04:43 +02:00
|
|
|
return_trace (Array16Of<MarkRecord>::sanitize (c, this));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Lookups */
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct SinglePosFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{ return (this+coverage).intersects (glyphs); }
|
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
if (!valueFormat.has_device ()) return;
|
2020-07-18 19:44:52 +02:00
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
auto it =
|
|
|
|
+ hb_iter (this+coverage)
|
|
|
|
| hb_filter (c->glyph_set)
|
|
|
|
;
|
|
|
|
|
|
|
|
if (!it) return;
|
|
|
|
valueFormat.collect_variation_indices (c, this, values.as_array (valueFormat.get_len ()));
|
|
|
|
}
|
2019-10-23 01:00:43 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2020-04-23 19:55:41 +02:00
|
|
|
{ if (unlikely (!(this+coverage).collect_coverage (c->input))) return; }
|
2012-11-24 07:38:41 +01:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+coverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
ValueFormat get_value_format () const { return valueFormat; }
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (index == NOT_COVERED)) return_trace (false);
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2016-09-10 02:03:11 +02:00
|
|
|
valueFormat.apply_value (c, this, values, buffer->cur_pos());
|
2009-05-31 04:17:32 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx++;
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2019-07-03 01:30:57 +02:00
|
|
|
template<typename Iterator,
|
2021-04-24 01:32:56 +02:00
|
|
|
typename SrcLookup,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
2019-07-03 01:30:57 +02:00
|
|
|
void serialize (hb_serialize_context_t *c,
|
2021-04-24 01:32:56 +02:00
|
|
|
const SrcLookup *src,
|
2019-07-03 01:30:57 +02:00
|
|
|
Iterator it,
|
2021-04-24 00:21:30 +02:00
|
|
|
ValueFormat newFormat,
|
2020-07-29 06:03:32 +02:00
|
|
|
const hb_map_t *layout_variation_idx_map)
|
2019-07-03 01:30:57 +02:00
|
|
|
{
|
2021-07-29 01:36:22 +02:00
|
|
|
if (unlikely (!c->extend_min (this))) return;
|
2021-04-23 01:45:14 +02:00
|
|
|
if (unlikely (!c->check_assign (valueFormat,
|
2021-04-24 00:21:30 +02:00
|
|
|
newFormat,
|
2021-04-23 01:45:14 +02:00
|
|
|
HB_SERIALIZE_ERROR_INT_OVERFLOW))) return;
|
2019-07-03 01:30:57 +02:00
|
|
|
|
2021-04-23 01:45:14 +02:00
|
|
|
for (const hb_array_t<const Value>& _ : + it | hb_map (hb_second))
|
|
|
|
{
|
2021-04-24 01:32:56 +02:00
|
|
|
src->get_value_format ().copy_values (c, newFormat, src, &_, layout_variation_idx_map);
|
2021-04-23 01:45:14 +02:00
|
|
|
// Only serialize the first entry in the iterator, the rest are assumed to
|
|
|
|
// be the same.
|
|
|
|
break;
|
|
|
|
}
|
2019-07-03 01:30:57 +02:00
|
|
|
|
|
|
|
auto glyphs =
|
|
|
|
+ it
|
|
|
|
| hb_map_retains_sorting (hb_first)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
coverage.serialize_serialize (c, glyphs);
|
2019-07-03 01:30:57 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2019-07-03 01:30:57 +02:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto it =
|
|
|
|
+ hb_iter (this+coverage)
|
|
|
|
| hb_filter (glyphset)
|
2019-09-02 02:25:50 +02:00
|
|
|
| hb_map_retains_sorting (glyph_map)
|
|
|
|
| hb_zip (hb_repeat (values.as_array (valueFormat.get_len ())))
|
2019-07-03 01:30:57 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
bool ret = bool (it);
|
2021-04-24 01:32:56 +02:00
|
|
|
SinglePos_serialize (c->serializer, this, it, c->plan->layout_variation_idx_map);
|
2019-07-03 01:30:57 +02:00
|
|
|
return_trace (ret);
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
coverage.sanitize (c, this) &&
|
|
|
|
valueFormat.sanitize_value (c, this, values));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-18 23:09:33 +02:00
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
2009-05-19 01:47:52 +02:00
|
|
|
ValueFormat valueFormat; /* Defines the types of data in the
|
2009-05-18 23:09:33 +02:00
|
|
|
* ValueRecord */
|
|
|
|
ValueRecord values; /* Defines positioning
|
|
|
|
* value(s)--applied to all glyphs in
|
|
|
|
* the Coverage table */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2010-05-11 01:01:17 +02:00
|
|
|
DEFINE_SIZE_ARRAY (6, values);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct SinglePosFormat2
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{ return (this+coverage).intersects (glyphs); }
|
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
if (!valueFormat.has_device ()) return;
|
2020-07-18 19:44:52 +02:00
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
auto it =
|
|
|
|
+ hb_zip (this+coverage, hb_range ((unsigned) valueCount))
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
;
|
|
|
|
|
|
|
|
if (!it) return;
|
|
|
|
|
|
|
|
unsigned sub_length = valueFormat.get_len ();
|
|
|
|
const hb_array_t<const Value> values_array = values.as_array (valueCount * sub_length);
|
|
|
|
|
|
|
|
for (unsigned i : + it
|
2020-07-29 06:03:32 +02:00
|
|
|
| hb_map (hb_second))
|
2020-02-26 22:11:42 +01:00
|
|
|
valueFormat.collect_variation_indices (c, this, values_array.sub_array (i * sub_length, sub_length));
|
|
|
|
|
|
|
|
}
|
2019-10-23 01:00:43 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2020-04-23 19:55:41 +02:00
|
|
|
{ if (unlikely (!(this+coverage).collect_coverage (c->input))) return; }
|
2012-11-24 07:38:41 +01:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+coverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
ValueFormat get_value_format () const { return valueFormat; }
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (index == NOT_COVERED)) return_trace (false);
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (index >= valueCount)) return_trace (false);
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2016-09-10 02:03:11 +02:00
|
|
|
valueFormat.apply_value (c, this,
|
2010-03-16 08:46:17 +01:00
|
|
|
&values[index * valueFormat.get_len ()],
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->cur_pos());
|
2009-05-31 04:17:32 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx++;
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2019-07-03 01:30:57 +02:00
|
|
|
template<typename Iterator,
|
2021-04-24 01:32:56 +02:00
|
|
|
typename SrcLookup,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
2019-07-03 01:30:57 +02:00
|
|
|
void serialize (hb_serialize_context_t *c,
|
2021-04-24 01:32:56 +02:00
|
|
|
const SrcLookup *src,
|
2019-07-03 01:30:57 +02:00
|
|
|
Iterator it,
|
2021-04-24 00:21:30 +02:00
|
|
|
ValueFormat newFormat,
|
2020-07-29 06:03:32 +02:00
|
|
|
const hb_map_t *layout_variation_idx_map)
|
2019-07-03 01:30:57 +02:00
|
|
|
{
|
2021-07-29 01:36:22 +02:00
|
|
|
auto out = c->extend_min (this);
|
2020-01-16 00:32:44 +01:00
|
|
|
if (unlikely (!out)) return;
|
2021-04-24 00:21:30 +02:00
|
|
|
if (unlikely (!c->check_assign (valueFormat, newFormat, HB_SERIALIZE_ERROR_INT_OVERFLOW))) return;
|
2021-03-18 18:51:26 +01:00
|
|
|
if (unlikely (!c->check_assign (valueCount, it.len (), HB_SERIALIZE_ERROR_ARRAY_OVERFLOW))) return;
|
2019-08-24 15:27:14 +02:00
|
|
|
|
2020-01-16 00:32:44 +01:00
|
|
|
+ it
|
|
|
|
| hb_map (hb_second)
|
|
|
|
| hb_apply ([&] (hb_array_t<const Value> _)
|
2021-04-24 01:32:56 +02:00
|
|
|
{ src->get_value_format ().copy_values (c, newFormat, src, &_, layout_variation_idx_map); })
|
2020-01-16 00:32:44 +01:00
|
|
|
;
|
2019-07-03 01:30:57 +02:00
|
|
|
|
|
|
|
auto glyphs =
|
|
|
|
+ it
|
|
|
|
| hb_map_retains_sorting (hb_first)
|
|
|
|
;
|
2019-08-24 15:27:14 +02:00
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
coverage.serialize_serialize (c, glyphs);
|
2019-07-03 01:30:57 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2019-07-03 01:30:57 +02:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
unsigned sub_length = valueFormat.get_len ();
|
2019-08-29 23:58:16 +02:00
|
|
|
auto values_array = values.as_array (valueCount * sub_length);
|
2019-07-03 01:30:57 +02:00
|
|
|
|
|
|
|
auto it =
|
|
|
|
+ hb_zip (this+coverage, hb_range ((unsigned) valueCount))
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
| hb_map_retains_sorting ([&] (const hb_pair_t<hb_codepoint_t, unsigned>& _)
|
2019-08-24 15:27:14 +02:00
|
|
|
{
|
2019-08-29 23:58:16 +02:00
|
|
|
return hb_pair (glyph_map[_.first],
|
|
|
|
values_array.sub_array (_.second * sub_length,
|
|
|
|
sub_length));
|
2019-08-24 15:27:14 +02:00
|
|
|
})
|
2019-07-03 01:30:57 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
bool ret = bool (it);
|
2021-04-24 01:32:56 +02:00
|
|
|
SinglePos_serialize (c->serializer, this, it, c->plan->layout_variation_idx_map);
|
2019-07-03 01:30:57 +02:00
|
|
|
return_trace (ret);
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
coverage.sanitize (c, this) &&
|
|
|
|
valueFormat.sanitize_values (c, this, values, valueCount));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 2 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-18 23:09:33 +02:00
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
2009-05-19 01:47:52 +02:00
|
|
|
ValueFormat valueFormat; /* Defines the types of data in the
|
2009-05-18 23:09:33 +02:00
|
|
|
* ValueRecord */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 valueCount; /* Number of ValueRecords */
|
2009-05-18 23:09:33 +02:00
|
|
|
ValueRecord values; /* Array of ValueRecords--positioning
|
|
|
|
* values applied to glyphs */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2010-05-11 01:01:17 +02:00
|
|
|
DEFINE_SIZE_ARRAY (8, values);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct SinglePos
|
|
|
|
{
|
2019-07-03 01:30:57 +02:00
|
|
|
template<typename Iterator,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
|
|
|
unsigned get_format (Iterator glyph_val_iter_pairs)
|
|
|
|
{
|
|
|
|
hb_array_t<const Value> first_val_iter = hb_second (*glyph_val_iter_pairs);
|
|
|
|
|
2019-09-24 12:22:46 +02:00
|
|
|
for (const auto iter : glyph_val_iter_pairs)
|
|
|
|
for (const auto _ : hb_zip (iter.second, first_val_iter))
|
2019-09-21 13:55:54 +02:00
|
|
|
if (_.first != _.second)
|
2019-09-21 21:00:52 +02:00
|
|
|
return 2;
|
2019-07-03 01:30:57 +02:00
|
|
|
|
2019-09-21 21:00:52 +02:00
|
|
|
return 1;
|
2019-07-03 01:30:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Iterator,
|
2021-04-24 01:32:56 +02:00
|
|
|
typename SrcLookup,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
2019-07-03 01:30:57 +02:00
|
|
|
void serialize (hb_serialize_context_t *c,
|
2021-04-24 01:32:56 +02:00
|
|
|
const SrcLookup* src,
|
2019-07-03 01:30:57 +02:00
|
|
|
Iterator glyph_val_iter_pairs,
|
2020-07-29 06:03:32 +02:00
|
|
|
const hb_map_t *layout_variation_idx_map)
|
2019-07-03 01:30:57 +02:00
|
|
|
{
|
|
|
|
if (unlikely (!c->extend_min (u.format))) return;
|
|
|
|
unsigned format = 2;
|
2021-04-24 01:32:56 +02:00
|
|
|
ValueFormat new_format = src->get_value_format ();
|
2019-07-03 01:30:57 +02:00
|
|
|
|
2021-04-24 00:21:30 +02:00
|
|
|
if (glyph_val_iter_pairs)
|
|
|
|
{
|
|
|
|
format = get_format (glyph_val_iter_pairs);
|
2021-04-24 01:32:56 +02:00
|
|
|
new_format = src->get_value_format ().get_effective_format (+ glyph_val_iter_pairs | hb_map (hb_second));
|
2021-04-24 00:21:30 +02:00
|
|
|
}
|
2019-07-03 01:30:57 +02:00
|
|
|
|
|
|
|
u.format = format;
|
|
|
|
switch (u.format) {
|
2021-04-24 01:32:56 +02:00
|
|
|
case 1: u.format1.serialize (c,
|
|
|
|
src,
|
|
|
|
glyph_val_iter_pairs,
|
|
|
|
new_format,
|
|
|
|
layout_variation_idx_map);
|
|
|
|
return;
|
2021-04-24 00:21:30 +02:00
|
|
|
case 2: u.format2.serialize (c,
|
|
|
|
src,
|
|
|
|
glyph_val_iter_pairs,
|
|
|
|
new_format,
|
|
|
|
layout_variation_idx_map);
|
2021-04-24 01:32:56 +02:00
|
|
|
return;
|
2019-07-03 01:30:57 +02:00
|
|
|
default:return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2012-07-28 23:31:01 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, u.format);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (u.format) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
|
|
|
case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default:return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
SinglePosFormat1 format1;
|
|
|
|
SinglePosFormat2 format2;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
template<typename Iterator, typename SrcLookup>
|
2019-12-10 20:21:26 +01:00
|
|
|
static void
|
2019-07-03 01:30:57 +02:00
|
|
|
SinglePos_serialize (hb_serialize_context_t *c,
|
2021-04-24 01:32:56 +02:00
|
|
|
const SrcLookup *src,
|
2019-08-24 15:27:14 +02:00
|
|
|
Iterator it,
|
2020-07-29 06:03:32 +02:00
|
|
|
const hb_map_t *layout_variation_idx_map)
|
2021-04-24 01:32:56 +02:00
|
|
|
{ c->start_embed<SinglePos> ()->serialize (c, src, it, layout_variation_idx_map); }
|
2019-07-03 01:30:57 +02:00
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PairValueRecord
|
|
|
|
{
|
2010-05-11 06:23:50 +02:00
|
|
|
friend struct PairSet;
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2019-12-10 19:04:44 +01:00
|
|
|
int cmp (hb_codepoint_t k) const
|
|
|
|
{ return secondGlyph.cmp (k); }
|
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
struct context_t
|
2020-01-16 00:32:44 +01:00
|
|
|
{
|
2020-03-08 21:09:24 +01:00
|
|
|
const void *base;
|
2020-01-16 00:32:44 +01:00
|
|
|
const ValueFormat *valueFormats;
|
2021-04-24 01:32:56 +02:00
|
|
|
const ValueFormat *newFormats;
|
2020-01-16 00:32:44 +01:00
|
|
|
unsigned len1; /* valueFormats[0].get_len() */
|
|
|
|
const hb_map_t *glyph_map;
|
2020-02-26 22:11:42 +01:00
|
|
|
const hb_map_t *layout_variation_idx_map;
|
2020-01-16 00:32:44 +01:00
|
|
|
};
|
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
bool subset (hb_subset_context_t *c,
|
|
|
|
context_t *closure) const
|
2019-09-17 20:10:08 +02:00
|
|
|
{
|
|
|
|
TRACE_SERIALIZE (this);
|
2021-04-24 01:32:56 +02:00
|
|
|
auto *s = c->serializer;
|
|
|
|
auto *out = s->start_embed (*this);
|
|
|
|
if (unlikely (!s->extend_min (out))) return_trace (false);
|
2019-12-10 19:04:44 +01:00
|
|
|
|
2020-01-16 00:32:44 +01:00
|
|
|
out->secondGlyph = (*closure->glyph_map)[secondGlyph];
|
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
closure->valueFormats[0].copy_values (s,
|
|
|
|
closure->newFormats[0],
|
|
|
|
closure->base, &values[0],
|
|
|
|
closure->layout_variation_idx_map);
|
|
|
|
closure->valueFormats[1].copy_values (s,
|
|
|
|
closure->newFormats[1],
|
|
|
|
closure->base,
|
|
|
|
&values[closure->len1],
|
|
|
|
closure->layout_variation_idx_map);
|
2020-01-16 00:32:44 +01:00
|
|
|
|
|
|
|
return_trace (true);
|
2019-09-17 20:10:08 +02:00
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
2020-07-29 06:03:32 +02:00
|
|
|
const ValueFormat *valueFormats,
|
|
|
|
const void *base) const
|
2020-02-26 22:11:42 +01:00
|
|
|
{
|
|
|
|
unsigned record1_len = valueFormats[0].get_len ();
|
|
|
|
unsigned record2_len = valueFormats[1].get_len ();
|
|
|
|
const hb_array_t<const Value> values_array = values.as_array (record1_len + record2_len);
|
|
|
|
|
|
|
|
if (valueFormats[0].has_device ())
|
|
|
|
valueFormats[0].collect_variation_indices (c, base, values_array.sub_array (0, record1_len));
|
|
|
|
|
|
|
|
if (valueFormats[1].has_device ())
|
|
|
|
valueFormats[1].collect_variation_indices (c, base, values_array.sub_array (record1_len, record2_len));
|
|
|
|
}
|
|
|
|
|
2021-04-24 02:41:09 +02:00
|
|
|
bool intersects (const hb_set_t& glyphset) const
|
|
|
|
{
|
|
|
|
return glyphset.has(secondGlyph);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Value* get_values_1 () const
|
|
|
|
{
|
|
|
|
return &values[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
const Value* get_values_2 (ValueFormat format1) const
|
|
|
|
{
|
|
|
|
return &values[format1.get_len ()];
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2021-09-19 22:30:12 +02:00
|
|
|
HBGlyphID16 secondGlyph; /* GlyphID of second glyph in the
|
2009-05-18 23:09:33 +02:00
|
|
|
* pair--first glyph is listed in the
|
|
|
|
* Coverage table */
|
|
|
|
ValueRecord values; /* Positioning data for the first glyph
|
|
|
|
* followed by for second glyph */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2010-05-11 01:01:17 +02:00
|
|
|
DEFINE_SIZE_ARRAY (2, values);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PairSet
|
|
|
|
{
|
2009-05-20 04:16:04 +02:00
|
|
|
friend struct PairPosFormat1;
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs,
|
2019-03-30 05:59:28 +01:00
|
|
|
const ValueFormat *valueFormats) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{
|
2018-12-01 02:45:40 +01:00
|
|
|
unsigned int len1 = valueFormats[0].get_len ();
|
|
|
|
unsigned int len2 = valueFormats[1].get_len ();
|
2018-09-03 04:47:50 +02:00
|
|
|
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
|
|
|
|
2018-09-10 23:29:26 +02:00
|
|
|
const PairValueRecord *record = &firstPairValueRecord;
|
2018-09-03 04:47:50 +02:00
|
|
|
unsigned int count = len;
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (glyphs->has (record->secondGlyph))
|
2018-11-15 20:40:56 +01:00
|
|
|
return true;
|
2018-09-03 04:47:50 +02:00
|
|
|
record = &StructAtOffset<const PairValueRecord> (record, record_size);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c,
|
2020-07-18 19:44:52 +02:00
|
|
|
const ValueFormat *valueFormats) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
2018-12-01 02:45:40 +01:00
|
|
|
unsigned int len1 = valueFormats[0].get_len ();
|
|
|
|
unsigned int len2 = valueFormats[1].get_len ();
|
2018-01-10 03:07:30 +01:00
|
|
|
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
2012-11-24 07:38:41 +01:00
|
|
|
|
2018-09-10 23:29:26 +02:00
|
|
|
const PairValueRecord *record = &firstPairValueRecord;
|
2017-12-16 15:12:06 +01:00
|
|
|
c->input->add_array (&record->secondGlyph, len, record_size);
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
2020-07-29 06:03:32 +02:00
|
|
|
const ValueFormat *valueFormats) const
|
2020-02-26 22:11:42 +01:00
|
|
|
{
|
|
|
|
unsigned len1 = valueFormats[0].get_len ();
|
|
|
|
unsigned len2 = valueFormats[1].get_len ();
|
|
|
|
unsigned record_size = HBUINT16::static_size * (1 + len1 + len2);
|
|
|
|
|
|
|
|
const PairValueRecord *record = &firstPairValueRecord;
|
|
|
|
unsigned count = len;
|
|
|
|
for (unsigned i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (c->glyph_set->has (record->secondGlyph))
|
|
|
|
{ record->collect_variation_indices (c, valueFormats, this); }
|
|
|
|
|
|
|
|
record = &StructAtOffset<const PairValueRecord> (record, record_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c,
|
2019-12-10 19:04:44 +01:00
|
|
|
const ValueFormat *valueFormats,
|
|
|
|
unsigned int pos) const
|
2010-05-11 06:23:50 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
2018-12-01 02:45:40 +01:00
|
|
|
unsigned int len1 = valueFormats[0].get_len ();
|
|
|
|
unsigned int len2 = valueFormats[1].get_len ();
|
2018-01-10 03:07:30 +01:00
|
|
|
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
2010-05-11 06:23:50 +02:00
|
|
|
|
2019-12-10 19:04:44 +01:00
|
|
|
const PairValueRecord *record = hb_bsearch (buffer->info[pos].codepoint,
|
|
|
|
&firstPairValueRecord,
|
|
|
|
len,
|
|
|
|
record_size);
|
|
|
|
if (record)
|
2010-05-11 06:23:50 +02:00
|
|
|
{
|
2021-10-12 16:42:43 +02:00
|
|
|
bool applied_first = valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos());
|
|
|
|
bool applied_second = valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]);
|
|
|
|
if (applied_first || applied_second)
|
2019-12-10 19:04:44 +01:00
|
|
|
buffer->unsafe_to_break (buffer->idx, pos + 1);
|
|
|
|
if (len2)
|
|
|
|
pos++;
|
|
|
|
buffer->idx = pos;
|
|
|
|
return_trace (true);
|
2010-05-11 06:23:50 +02:00
|
|
|
}
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (false);
|
2010-05-11 06:23:50 +02:00
|
|
|
}
|
|
|
|
|
2019-09-17 20:10:08 +02:00
|
|
|
bool subset (hb_subset_context_t *c,
|
2021-04-24 01:32:56 +02:00
|
|
|
const ValueFormat valueFormats[2],
|
|
|
|
const ValueFormat newFormats[2]) const
|
2019-09-17 20:10:08 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
|
|
|
auto snap = c->serializer->snapshot ();
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
out->len = 0;
|
|
|
|
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2019-09-17 20:10:08 +02:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
2019-10-25 19:07:26 +02:00
|
|
|
unsigned len1 = valueFormats[0].get_len ();
|
|
|
|
unsigned len2 = valueFormats[1].get_len ();
|
|
|
|
unsigned record_size = HBUINT16::static_size + Value::static_size * (len1 + len2);
|
2019-09-17 20:10:08 +02:00
|
|
|
|
2021-04-24 01:32:56 +02:00
|
|
|
PairValueRecord::context_t context =
|
2020-01-16 00:32:44 +01:00
|
|
|
{
|
|
|
|
this,
|
|
|
|
valueFormats,
|
2021-04-24 01:32:56 +02:00
|
|
|
newFormats,
|
2020-01-16 00:32:44 +01:00
|
|
|
len1,
|
2020-02-26 22:11:42 +01:00
|
|
|
&glyph_map,
|
|
|
|
c->plan->layout_variation_idx_map
|
2020-01-16 00:32:44 +01:00
|
|
|
};
|
|
|
|
|
2019-09-17 20:10:08 +02:00
|
|
|
const PairValueRecord *record = &firstPairValueRecord;
|
|
|
|
unsigned count = len, num = 0;
|
|
|
|
for (unsigned i = 0; i < count; i++)
|
|
|
|
{
|
2020-01-22 20:20:56 +01:00
|
|
|
if (glyphset.has (record->secondGlyph)
|
2021-04-24 01:32:56 +02:00
|
|
|
&& record->subset (c, &context)) num++;
|
2019-09-17 20:10:08 +02:00
|
|
|
record = &StructAtOffset<const PairValueRecord> (record, record_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
out->len = num;
|
|
|
|
if (!num) c->serializer->revert (snap);
|
|
|
|
return_trace (num);
|
|
|
|
}
|
|
|
|
|
2018-09-03 04:47:50 +02:00
|
|
|
struct sanitize_closure_t
|
|
|
|
{
|
2015-02-17 15:27:44 +01:00
|
|
|
const ValueFormat *valueFormats;
|
2018-12-01 02:45:40 +01:00
|
|
|
unsigned int len1; /* valueFormats[0].get_len() */
|
2010-05-11 06:23:50 +02:00
|
|
|
unsigned int stride; /* 1 + len1 + len2 */
|
|
|
|
};
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2010-05-13 20:18:49 +02:00
|
|
|
if (!(c->check_struct (this)
|
2018-11-12 20:23:31 +01:00
|
|
|
&& c->check_range (&firstPairValueRecord,
|
|
|
|
len,
|
|
|
|
HBUINT16::static_size,
|
|
|
|
closure->stride))) return_trace (false);
|
2010-05-11 06:23:50 +02:00
|
|
|
|
|
|
|
unsigned int count = len;
|
2018-09-10 23:29:26 +02:00
|
|
|
const PairValueRecord *record = &firstPairValueRecord;
|
2020-01-22 20:20:56 +01:00
|
|
|
return_trace (closure->valueFormats[0].sanitize_values_stride_unsafe (c, this, &record->values[0], count, closure->stride) &&
|
|
|
|
closure->valueFormats[1].sanitize_values_stride_unsafe (c, this, &record->values[closure->len1], count, closure->stride));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-09-10 23:29:26 +02:00
|
|
|
HBUINT16 len; /* Number of PairValueRecords */
|
|
|
|
PairValueRecord firstPairValueRecord;
|
|
|
|
/* Array of PairValueRecords--ordered
|
|
|
|
* by GlyphID of the second glyph */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2018-09-10 23:29:26 +02:00
|
|
|
DEFINE_SIZE_MIN (2);
|
2009-05-20 04:16:04 +02:00
|
|
|
};
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PairPosFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{
|
2019-03-30 05:57:17 +01:00
|
|
|
return
|
|
|
|
+ hb_zip (this+coverage, pairSet)
|
|
|
|
| hb_filter (*glyphs, hb_first)
|
|
|
|
| hb_map (hb_second)
|
2021-03-31 20:49:14 +02:00
|
|
|
| hb_map ([glyphs, this] (const Offset16To<PairSet> &_)
|
2019-03-30 05:57:17 +01:00
|
|
|
{ return (this+_).intersects (glyphs, valueFormat); })
|
|
|
|
| hb_any
|
|
|
|
;
|
2018-09-03 04:47:50 +02:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
if ((!valueFormat[0].has_device ()) && (!valueFormat[1].has_device ())) return;
|
|
|
|
|
|
|
|
auto it =
|
|
|
|
+ hb_zip (this+coverage, pairSet)
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
;
|
|
|
|
|
|
|
|
if (!it) return;
|
|
|
|
+ it
|
|
|
|
| hb_map (hb_add (this))
|
|
|
|
| hb_apply ([&] (const PairSet& _) { _.collect_variation_indices (c, valueFormat); })
|
|
|
|
;
|
|
|
|
}
|
2019-10-23 01:00:43 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
2020-04-23 19:55:41 +02:00
|
|
|
if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
unsigned int count = pairSet.len;
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2016-12-14 18:56:17 +01:00
|
|
|
(this+pairSet[i]).collect_glyphs (c, valueFormat);
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+coverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 04:16:04 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (index == NOT_COVERED)) return_trace (false);
|
2009-05-20 04:16:04 +02:00
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
|
2015-01-29 13:40:39 +01:00
|
|
|
skippy_iter.reset (buffer->idx, 1);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!skippy_iter.next ()) return_trace (false);
|
2009-05-20 04:16:04 +02:00
|
|
|
|
2016-12-14 18:56:17 +01:00
|
|
|
return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx));
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2019-09-17 20:10:08 +02:00
|
|
|
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2019-09-17 20:10:08 +02:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
out->format = format;
|
|
|
|
out->valueFormat[0] = valueFormat[0];
|
|
|
|
out->valueFormat[1] = valueFormat[1];
|
2021-07-30 00:07:13 +02:00
|
|
|
if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
|
2021-04-24 02:41:09 +02:00
|
|
|
{
|
|
|
|
hb_pair_t<unsigned, unsigned> newFormats = compute_effective_value_formats (glyphset);
|
|
|
|
out->valueFormat[0] = newFormats.first;
|
|
|
|
out->valueFormat[1] = newFormats.second;
|
|
|
|
}
|
2019-09-17 20:10:08 +02:00
|
|
|
|
|
|
|
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
|
|
|
|
|
|
|
+ hb_zip (this+coverage, pairSet)
|
|
|
|
| hb_filter (glyphset, hb_first)
|
2021-03-31 20:49:14 +02:00
|
|
|
| hb_filter ([this, c, out] (const Offset16To<PairSet>& _)
|
2019-09-17 20:10:08 +02:00
|
|
|
{
|
2021-09-22 23:15:55 +02:00
|
|
|
auto snap = c->serializer->snapshot ();
|
2019-09-17 20:10:08 +02:00
|
|
|
auto *o = out->pairSet.serialize_append (c->serializer);
|
|
|
|
if (unlikely (!o)) return false;
|
2021-04-24 02:41:09 +02:00
|
|
|
bool ret = o->serialize_subset (c, _, this, valueFormat, out->valueFormat);
|
2019-09-17 20:10:08 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
out->pairSet.pop ();
|
|
|
|
c->serializer->revert (snap);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
hb_second)
|
|
|
|
| hb_map (hb_first)
|
|
|
|
| hb_map (glyph_map)
|
|
|
|
| hb_sink (new_coverage)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
out->coverage.serialize_serialize (c->serializer, new_coverage.iter ());
|
2019-09-17 20:10:08 +02:00
|
|
|
|
|
|
|
return_trace (bool (new_coverage));
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2021-04-24 02:41:09 +02:00
|
|
|
|
|
|
|
hb_pair_t<unsigned, unsigned> compute_effective_value_formats (const hb_set_t& glyphset) const
|
|
|
|
{
|
|
|
|
unsigned len1 = valueFormat[0].get_len ();
|
|
|
|
unsigned len2 = valueFormat[1].get_len ();
|
|
|
|
unsigned record_size = HBUINT16::static_size + Value::static_size * (len1 + len2);
|
|
|
|
|
|
|
|
unsigned format1 = 0;
|
|
|
|
unsigned format2 = 0;
|
|
|
|
for (const Offset16To<PairSet>& _ :
|
|
|
|
+ hb_zip (this+coverage, pairSet) | hb_filter (glyphset, hb_first) | hb_map (hb_second))
|
|
|
|
{
|
|
|
|
const PairSet& set = (this + _);
|
|
|
|
const PairValueRecord *record = &set.firstPairValueRecord;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < set.len; i++)
|
|
|
|
{
|
|
|
|
if (record->intersects (glyphset))
|
|
|
|
{
|
|
|
|
format1 = format1 | valueFormat[0].get_effective_format (record->get_values_1 ());
|
|
|
|
format2 = format2 | valueFormat[1].get_effective_format (record->get_values_2 (valueFormat[0]));
|
|
|
|
}
|
|
|
|
record = &StructAtOffset<const PairValueRecord> (record, record_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hb_pair (format1, format2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2010-03-29 06:04:12 +02:00
|
|
|
|
2015-10-13 06:30:50 +02:00
|
|
|
if (!c->check_struct (this)) return_trace (false);
|
|
|
|
|
2018-12-01 02:45:40 +01:00
|
|
|
unsigned int len1 = valueFormat[0].get_len ();
|
|
|
|
unsigned int len2 = valueFormat[1].get_len ();
|
2018-09-03 04:47:50 +02:00
|
|
|
PairSet::sanitize_closure_t closure =
|
|
|
|
{
|
2016-12-14 18:56:17 +01:00
|
|
|
valueFormat,
|
2010-05-11 06:23:50 +02:00
|
|
|
len1,
|
|
|
|
1 + len1 + len2
|
|
|
|
};
|
2010-03-29 06:04:12 +02:00
|
|
|
|
2015-10-13 06:30:50 +02:00
|
|
|
return_trace (coverage.sanitize (c, this) && pairSet.sanitize (c, this, &closure));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-18 23:09:33 +02:00
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
2018-12-01 02:45:40 +01:00
|
|
|
ValueFormat valueFormat[2]; /* [0] Defines the types of data in
|
2009-05-18 23:09:33 +02:00
|
|
|
* ValueRecord1--for the first glyph
|
|
|
|
* in the pair--may be zero (0) */
|
2018-12-01 02:45:40 +01:00
|
|
|
/* [1] Defines the types of data in
|
2009-05-18 23:09:33 +02:00
|
|
|
* ValueRecord2--for the second glyph
|
|
|
|
* in the pair--may be zero (0) */
|
2021-03-31 23:31:32 +02:00
|
|
|
Array16OfOffset16To<PairSet>
|
2009-05-18 23:09:33 +02:00
|
|
|
pairSet; /* Array of PairSet tables
|
|
|
|
* ordered by Coverage Index */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
2010-05-11 01:01:17 +02:00
|
|
|
DEFINE_SIZE_ARRAY (10, pairSet);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PairPosFormat2
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{
|
|
|
|
return (this+coverage).intersects (glyphs) &&
|
|
|
|
(this+classDef2).intersects (glyphs);
|
|
|
|
}
|
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
2021-04-16 01:52:11 +02:00
|
|
|
if (!intersects (c->glyph_set)) return;
|
2020-02-26 22:11:42 +01:00
|
|
|
if ((!valueFormat1.has_device ()) && (!valueFormat2.has_device ())) return;
|
|
|
|
|
2021-04-16 01:52:11 +02:00
|
|
|
hb_set_t klass1_glyphs, klass2_glyphs;
|
|
|
|
if (!(this+classDef1).collect_coverage (&klass1_glyphs)) return;
|
|
|
|
if (!(this+classDef2).collect_coverage (&klass2_glyphs)) return;
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
hb_set_t class1_set, class2_set;
|
2021-03-16 21:19:26 +01:00
|
|
|
for (const unsigned cp : + c->glyph_set->iter () | hb_filter (this + coverage))
|
2020-02-26 22:11:42 +01:00
|
|
|
{
|
2021-04-16 01:52:11 +02:00
|
|
|
if (!klass1_glyphs.has (cp)) class1_set.add (0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned klass1 = (this+classDef1).get (cp);
|
|
|
|
class1_set.add (klass1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class2_set.add (0);
|
|
|
|
for (const unsigned cp : + c->glyph_set->iter () | hb_filter (klass2_glyphs))
|
|
|
|
{
|
2020-02-26 22:11:42 +01:00
|
|
|
unsigned klass2 = (this+classDef2).get (cp);
|
|
|
|
class2_set.add (klass2);
|
|
|
|
}
|
|
|
|
|
2020-10-08 23:44:54 +02:00
|
|
|
if (class1_set.is_empty ()
|
|
|
|
|| class2_set.is_empty ()
|
|
|
|
|| (class2_set.get_population() == 1 && class2_set.has(0)))
|
|
|
|
return;
|
2020-07-18 19:44:52 +02:00
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
unsigned len1 = valueFormat1.get_len ();
|
|
|
|
unsigned len2 = valueFormat2.get_len ();
|
|
|
|
const hb_array_t<const Value> values_array = values.as_array ((unsigned)class1Count * (unsigned) class2Count * (len1 + len2));
|
|
|
|
for (const unsigned class1_idx : class1_set.iter ())
|
|
|
|
{
|
|
|
|
for (const unsigned class2_idx : class2_set.iter ())
|
|
|
|
{
|
2020-07-29 06:03:32 +02:00
|
|
|
unsigned start_offset = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2);
|
|
|
|
if (valueFormat1.has_device ())
|
|
|
|
valueFormat1.collect_variation_indices (c, this, values_array.sub_array (start_offset, len1));
|
2020-07-18 19:44:52 +02:00
|
|
|
|
2020-07-29 06:03:32 +02:00
|
|
|
if (valueFormat2.has_device ())
|
|
|
|
valueFormat2.collect_variation_indices (c, this, values_array.sub_array (start_offset+len1, len2));
|
2020-02-26 22:11:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-23 01:00:43 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
2020-04-23 19:55:41 +02:00
|
|
|
if (unlikely (!(this+coverage).collect_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+classDef2).collect_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+coverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 04:30:09 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (index == NOT_COVERED)) return_trace (false);
|
2009-05-20 04:30:09 +02:00
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
|
2015-01-29 13:40:39 +01:00
|
|
|
skippy_iter.reset (buffer->idx, 1);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!skippy_iter.next ()) return_trace (false);
|
2009-05-20 04:30:09 +02:00
|
|
|
|
|
|
|
unsigned int len1 = valueFormat1.get_len ();
|
|
|
|
unsigned int len2 = valueFormat2.get_len ();
|
|
|
|
unsigned int record_len = len1 + len2;
|
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int klass1 = (this+classDef1).get_class (buffer->cur().codepoint);
|
|
|
|
unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false);
|
2009-05-20 04:30:09 +02:00
|
|
|
|
2010-03-16 08:46:17 +01:00
|
|
|
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
|
2021-10-12 16:42:43 +02:00
|
|
|
bool applied_first = valueFormat1.apply_value (c, this, v, buffer->cur_pos());
|
|
|
|
bool applied_second = valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]);
|
|
|
|
if (applied_first || applied_second)
|
2018-11-07 21:40:55 +01:00
|
|
|
buffer->unsafe_to_break (buffer->idx, skippy_iter.idx + 1);
|
2009-05-20 04:30:09 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx = skippy_iter.idx;
|
2009-05-20 04:30:09 +02:00
|
|
|
if (len2)
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx++;
|
2009-05-20 04:30:09 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2019-09-17 20:10:08 +02:00
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
out->format = format;
|
|
|
|
|
|
|
|
hb_map_t klass1_map;
|
2021-04-16 01:52:11 +02:00
|
|
|
out->classDef1.serialize_subset (c, classDef1, this, &klass1_map, true, true, &(this + coverage));
|
2019-09-17 20:10:08 +02:00
|
|
|
out->class1Count = klass1_map.get_population ();
|
|
|
|
|
|
|
|
hb_map_t klass2_map;
|
2021-04-16 01:52:11 +02:00
|
|
|
out->classDef2.serialize_subset (c, classDef2, this, &klass2_map, true, false);
|
2019-09-17 20:10:08 +02:00
|
|
|
out->class2Count = klass2_map.get_population ();
|
|
|
|
|
2020-01-16 00:32:44 +01:00
|
|
|
unsigned len1 = valueFormat1.get_len ();
|
|
|
|
unsigned len2 = valueFormat2.get_len ();
|
2019-09-17 20:10:08 +02:00
|
|
|
|
2021-04-24 02:06:06 +02:00
|
|
|
hb_pair_t<unsigned, unsigned> newFormats = hb_pair (valueFormat1, valueFormat2);
|
2021-07-30 00:07:13 +02:00
|
|
|
if (c->plan->flags & HB_SUBSET_FLAGS_NO_HINTING)
|
2021-04-24 02:06:06 +02:00
|
|
|
newFormats = compute_effective_value_formats (klass1_map, klass2_map);
|
|
|
|
|
|
|
|
out->valueFormat1 = newFormats.first;
|
|
|
|
out->valueFormat2 = newFormats.second;
|
|
|
|
|
|
|
|
for (unsigned class1_idx : + hb_range ((unsigned) class1Count) | hb_filter (klass1_map))
|
|
|
|
{
|
|
|
|
for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map))
|
|
|
|
{
|
|
|
|
unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2);
|
|
|
|
valueFormat1.copy_values (c->serializer, newFormats.first, this, &values[idx], c->plan->layout_variation_idx_map);
|
|
|
|
valueFormat2.copy_values (c->serializer, newFormats.second, this, &values[idx + len1], c->plan->layout_variation_idx_map);
|
|
|
|
}
|
|
|
|
}
|
2019-09-17 20:10:08 +02:00
|
|
|
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2019-09-17 20:10:08 +02:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto it =
|
|
|
|
+ hb_iter (this+coverage)
|
|
|
|
| hb_filter (glyphset)
|
|
|
|
| hb_map_retains_sorting (glyph_map)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
out->coverage.serialize_serialize (c->serializer, it);
|
2019-09-17 20:10:08 +02:00
|
|
|
return_trace (out->class1Count && out->class2Count && bool (it));
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2021-04-24 02:06:06 +02:00
|
|
|
|
|
|
|
hb_pair_t<unsigned, unsigned> compute_effective_value_formats (const hb_map_t& klass1_map,
|
|
|
|
const hb_map_t& klass2_map) const
|
|
|
|
{
|
|
|
|
unsigned len1 = valueFormat1.get_len ();
|
|
|
|
unsigned len2 = valueFormat2.get_len ();
|
|
|
|
|
|
|
|
unsigned format1 = 0;
|
|
|
|
unsigned format2 = 0;
|
|
|
|
|
|
|
|
for (unsigned class1_idx : + hb_range ((unsigned) class1Count) | hb_filter (klass1_map))
|
|
|
|
{
|
|
|
|
for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map))
|
|
|
|
{
|
|
|
|
unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2);
|
|
|
|
format1 = format1 | valueFormat1.get_effective_format (&values[idx]);
|
|
|
|
format2 = format2 | valueFormat2.get_effective_format (&values[idx + len1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hb_pair (format1, format2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2010-05-13 20:18:49 +02:00
|
|
|
if (!(c->check_struct (this)
|
|
|
|
&& coverage.sanitize (c, this)
|
|
|
|
&& classDef1.sanitize (c, this)
|
2015-09-29 15:57:02 +02:00
|
|
|
&& classDef2.sanitize (c, this))) return_trace (false);
|
2009-08-14 23:31:16 +02:00
|
|
|
|
2010-03-29 06:04:12 +02:00
|
|
|
unsigned int len1 = valueFormat1.get_len ();
|
|
|
|
unsigned int len2 = valueFormat2.get_len ();
|
|
|
|
unsigned int stride = len1 + len2;
|
2010-03-16 08:46:17 +01:00
|
|
|
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
|
2010-03-29 06:04:12 +02:00
|
|
|
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
|
2018-11-12 20:23:31 +01:00
|
|
|
return_trace (c->check_range ((const void *) values,
|
|
|
|
count,
|
|
|
|
record_size) &&
|
2018-12-01 02:45:40 +01:00
|
|
|
valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
|
2015-09-29 15:57:02 +02:00
|
|
|
valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
2009-05-20 04:30:09 +02:00
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 2 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-18 23:09:33 +02:00
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
2009-05-19 01:47:52 +02:00
|
|
|
ValueFormat valueFormat1; /* ValueRecord definition--for the
|
2009-05-18 23:09:33 +02:00
|
|
|
* first glyph of the pair--may be zero
|
|
|
|
* (0) */
|
2009-05-19 01:47:52 +02:00
|
|
|
ValueFormat valueFormat2; /* ValueRecord definition--for the
|
2009-05-18 23:09:33 +02:00
|
|
|
* second glyph of the pair--may be
|
|
|
|
* zero (0) */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<ClassDef>
|
2009-05-18 23:09:33 +02:00
|
|
|
classDef1; /* Offset to ClassDef table--from
|
|
|
|
* beginning of PairPos subtable--for
|
|
|
|
* the first glyph of the pair */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<ClassDef>
|
2009-05-18 23:09:33 +02:00
|
|
|
classDef2; /* Offset to ClassDef table--from
|
|
|
|
* beginning of PairPos subtable--for
|
|
|
|
* the second glyph of the pair */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 class1Count; /* Number of classes in ClassDef1
|
2009-05-18 23:09:33 +02:00
|
|
|
* table--includes Class0 */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 class2Count; /* Number of classes in ClassDef2
|
2009-05-18 23:09:33 +02:00
|
|
|
* table--includes Class0 */
|
|
|
|
ValueRecord values; /* Matrix of value pairs:
|
|
|
|
* class1-major, class2-minor,
|
|
|
|
* Each entry has value1 and value2 */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2010-05-11 01:01:17 +02:00
|
|
|
DEFINE_SIZE_ARRAY (16, values);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PairPos
|
|
|
|
{
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2012-07-28 23:31:01 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, u.format);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (u.format) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
|
|
|
case 2: return_trace (c->dispatch (u.format2, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default:return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
PairPosFormat1 format1;
|
|
|
|
PairPosFormat2 format2;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct EntryExitRecord
|
|
|
|
{
|
2010-05-10 22:38:32 +02:00
|
|
|
friend struct CursivePosFormat1;
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
|
|
|
const void *src_base) const
|
|
|
|
{
|
|
|
|
(src_base+entryAnchor).collect_variation_indices (c);
|
|
|
|
(src_base+exitAnchor).collect_variation_indices (c);
|
|
|
|
}
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
EntryExitRecord* subset (hb_subset_context_t *c,
|
|
|
|
const void *src_base) const
|
2019-09-19 01:11:44 +02:00
|
|
|
{
|
|
|
|
TRACE_SERIALIZE (this);
|
2021-04-02 23:37:10 +02:00
|
|
|
auto *out = c->serializer->embed (this);
|
2019-09-19 01:11:44 +02:00
|
|
|
if (unlikely (!out)) return_trace (nullptr);
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
out->entryAnchor.serialize_subset (c, entryAnchor, src_base);
|
|
|
|
out->exitAnchor.serialize_subset (c, exitAnchor, src_base);
|
2019-09-19 01:11:44 +02:00
|
|
|
return_trace (out);
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Anchor>
|
2009-05-18 23:09:33 +02:00
|
|
|
entryAnchor; /* Offset to EntryAnchor table--from
|
|
|
|
* beginning of CursivePos
|
|
|
|
* subtable--may be NULL */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Anchor>
|
2009-05-18 23:09:33 +02:00
|
|
|
exitAnchor; /* Offset to ExitAnchor table--from
|
|
|
|
* beginning of CursivePos
|
|
|
|
* subtable--may be NULL */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (4);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2015-08-25 21:24:59 +02:00
|
|
|
static void
|
|
|
|
reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, unsigned int new_parent);
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct CursivePosFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{ return (this+coverage).intersects (glyphs); }
|
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
+ hb_zip (this+coverage, entryExitRecord)
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
| hb_apply ([&] (const EntryExitRecord& record) { record.collect_variation_indices (c, this); })
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2020-04-23 19:55:41 +02:00
|
|
|
{ if (unlikely (!(this+coverage).collect_coverage (c->input))) return; }
|
2012-11-24 07:38:41 +01:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+coverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 05:25:41 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
2009-05-20 10:16:35 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
|
2018-10-12 02:45:00 +02:00
|
|
|
if (!this_record.entryAnchor) return_trace (false);
|
2010-10-27 17:54:26 +02:00
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
|
2015-01-29 13:40:39 +01:00
|
|
|
skippy_iter.reset (buffer->idx, 1);
|
2018-10-12 02:45:00 +02:00
|
|
|
if (!skippy_iter.prev ()) return_trace (false);
|
2010-10-27 17:54:26 +02:00
|
|
|
|
2018-10-12 02:45:00 +02:00
|
|
|
const EntryExitRecord &prev_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)];
|
|
|
|
if (!prev_record.exitAnchor) return_trace (false);
|
2009-05-20 05:25:41 +02:00
|
|
|
|
2018-10-12 02:45:00 +02:00
|
|
|
unsigned int i = skippy_iter.idx;
|
|
|
|
unsigned int j = buffer->idx;
|
2009-05-20 05:25:41 +02:00
|
|
|
|
2017-08-11 05:23:17 +02:00
|
|
|
buffer->unsafe_to_break (i, j);
|
2018-01-10 05:13:47 +01:00
|
|
|
float entry_x, entry_y, exit_x, exit_y;
|
2018-10-12 02:45:00 +02:00
|
|
|
(this+prev_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
|
|
|
|
(this+this_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y);
|
2009-05-27 06:17:37 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_glyph_position_t *pos = buffer->pos;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
|
|
|
hb_position_t d;
|
|
|
|
/* Main-direction adjustment */
|
|
|
|
switch (c->direction) {
|
|
|
|
case HB_DIRECTION_LTR:
|
2019-05-08 08:26:09 +02:00
|
|
|
pos[i].x_advance = roundf (exit_x) + pos[i].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2019-05-08 08:26:09 +02:00
|
|
|
d = roundf (entry_x) + pos[j].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
pos[j].x_advance -= d;
|
|
|
|
pos[j].x_offset -= d;
|
|
|
|
break;
|
|
|
|
case HB_DIRECTION_RTL:
|
2019-05-08 08:26:09 +02:00
|
|
|
d = roundf (exit_x) + pos[i].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
pos[i].x_advance -= d;
|
|
|
|
pos[i].x_offset -= d;
|
|
|
|
|
2019-05-08 08:26:09 +02:00
|
|
|
pos[j].x_advance = roundf (entry_x) + pos[j].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
break;
|
|
|
|
case HB_DIRECTION_TTB:
|
2019-05-08 08:26:09 +02:00
|
|
|
pos[i].y_advance = roundf (exit_y) + pos[i].y_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2019-05-08 08:26:09 +02:00
|
|
|
d = roundf (entry_y) + pos[j].y_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
pos[j].y_advance -= d;
|
|
|
|
pos[j].y_offset -= d;
|
|
|
|
break;
|
|
|
|
case HB_DIRECTION_BTT:
|
2019-05-08 08:26:09 +02:00
|
|
|
d = roundf (exit_y) + pos[i].y_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
pos[i].y_advance -= d;
|
|
|
|
pos[i].y_offset -= d;
|
|
|
|
|
2019-05-08 08:26:09 +02:00
|
|
|
pos[j].y_advance = roundf (entry_y);
|
2011-05-25 03:04:15 +02:00
|
|
|
break;
|
|
|
|
case HB_DIRECTION_INVALID:
|
|
|
|
default:
|
|
|
|
break;
|
2009-05-20 05:25:41 +02:00
|
|
|
}
|
|
|
|
|
2011-05-25 03:04:15 +02:00
|
|
|
/* Cross-direction adjustment */
|
2015-08-25 19:55:34 +02:00
|
|
|
|
|
|
|
/* We attach child to parent (think graph theory and rooted trees whereas
|
|
|
|
* the root stays on baseline and each node aligns itself against its
|
|
|
|
* parent.
|
|
|
|
*
|
|
|
|
* Optimize things for the case of RightToLeft, as that's most common in
|
2018-10-12 02:45:00 +02:00
|
|
|
* Arabic. */
|
2015-08-25 19:55:34 +02:00
|
|
|
unsigned int child = i;
|
|
|
|
unsigned int parent = j;
|
|
|
|
hb_position_t x_offset = entry_x - exit_x;
|
|
|
|
hb_position_t y_offset = entry_y - exit_y;
|
|
|
|
if (!(c->lookup_props & LookupFlag::RightToLeft))
|
|
|
|
{
|
|
|
|
unsigned int k = child;
|
|
|
|
child = parent;
|
|
|
|
parent = k;
|
|
|
|
x_offset = -x_offset;
|
|
|
|
y_offset = -y_offset;
|
2009-05-20 05:25:41 +02:00
|
|
|
}
|
|
|
|
|
2015-08-25 21:24:59 +02:00
|
|
|
/* If child was already connected to someone else, walk through its old
|
|
|
|
* chain and reverse the link direction, such that the whole tree of its
|
|
|
|
* previous connection now attaches to new parent. Watch out for case
|
|
|
|
* where new parent is on the path from old chain...
|
|
|
|
*/
|
|
|
|
reverse_cursive_minor_offset (pos, child, c->direction, parent);
|
|
|
|
|
2016-02-11 09:25:28 +01:00
|
|
|
pos[child].attach_type() = ATTACH_TYPE_CURSIVE;
|
|
|
|
pos[child].attach_chain() = (int) parent - (int) child;
|
2016-02-11 10:48:13 +01:00
|
|
|
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT;
|
2015-08-25 19:55:34 +02:00
|
|
|
if (likely (HB_DIRECTION_IS_HORIZONTAL (c->direction)))
|
|
|
|
pos[child].y_offset = y_offset;
|
|
|
|
else
|
|
|
|
pos[child].x_offset = x_offset;
|
|
|
|
|
2021-07-08 18:53:45 +02:00
|
|
|
/* If parent was attached to child, separate them.
|
2020-06-18 02:41:15 +02:00
|
|
|
* https://github.com/harfbuzz/harfbuzz/issues/2469
|
|
|
|
*/
|
|
|
|
if (unlikely (pos[parent].attach_chain() == -pos[child].attach_chain()))
|
|
|
|
pos[parent].attach_chain() = 0;
|
|
|
|
|
2018-10-12 02:45:00 +02:00
|
|
|
buffer->idx++;
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2019-09-19 01:11:44 +02:00
|
|
|
template <typename Iterator,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
2021-04-02 23:37:10 +02:00
|
|
|
void serialize (hb_subset_context_t *c,
|
2020-02-26 22:11:42 +01:00
|
|
|
Iterator it,
|
2021-04-02 23:37:10 +02:00
|
|
|
const void *src_base)
|
2019-09-19 01:11:44 +02:00
|
|
|
{
|
2021-04-02 23:37:10 +02:00
|
|
|
if (unlikely (!c->serializer->extend_min ((*this)))) return;
|
2019-09-19 01:11:44 +02:00
|
|
|
this->format = 1;
|
|
|
|
this->entryExitRecord.len = it.len ();
|
|
|
|
|
|
|
|
for (const EntryExitRecord& entry_record : + it
|
|
|
|
| hb_map (hb_second))
|
2021-04-02 23:37:10 +02:00
|
|
|
entry_record.subset (c, src_base);
|
2019-09-19 01:11:44 +02:00
|
|
|
|
|
|
|
auto glyphs =
|
|
|
|
+ it
|
|
|
|
| hb_map_retains_sorting (hb_first)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
coverage.serialize_serialize (c->serializer, glyphs);
|
2019-09-19 01:11:44 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2019-09-19 01:11:44 +02:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!out)) return_trace (false);
|
|
|
|
|
|
|
|
auto it =
|
|
|
|
+ hb_zip (this+coverage, entryExitRecord)
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
| hb_map_retains_sorting ([&] (hb_pair_t<hb_codepoint_t, const EntryExitRecord&> p) -> hb_pair_t<hb_codepoint_t, const EntryExitRecord&>
|
2019-10-01 12:19:55 +02:00
|
|
|
{ return hb_pair (glyph_map[p.first], p.second);})
|
2019-09-19 01:11:44 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
bool ret = bool (it);
|
2021-04-02 23:37:10 +02:00
|
|
|
out->serialize (c, it, this);
|
2019-09-19 01:11:44 +02:00
|
|
|
return_trace (ret);
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (coverage.sanitize (c, this) && entryExitRecord.sanitize (c, this));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-18 23:09:33 +02:00
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
2021-04-01 00:04:43 +02:00
|
|
|
Array16Of<EntryExitRecord>
|
2009-05-18 23:09:33 +02:00
|
|
|
entryExitRecord; /* Array of EntryExit records--in
|
|
|
|
* Coverage Index order */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
2010-05-11 01:01:17 +02:00
|
|
|
DEFINE_SIZE_ARRAY (6, entryExitRecord);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct CursivePos
|
|
|
|
{
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2012-07-28 23:31:01 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, u.format);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (u.format) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default:return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
CursivePosFormat1 format1;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-15 00:14:03 +02:00
|
|
|
typedef AnchorMatrix BaseArray; /* base-major--
|
|
|
|
* in order of BaseCoverage Index--,
|
|
|
|
* mark-minor--
|
2009-05-21 10:47:05 +02:00
|
|
|
* ordered by class--zero-based. */
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
static void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage,
|
|
|
|
const MarkArray &mark_array,
|
|
|
|
const hb_set_t &glyphset,
|
|
|
|
hb_map_t* klass_mapping /* INOUT */)
|
|
|
|
{
|
|
|
|
hb_set_t orig_classes;
|
|
|
|
|
|
|
|
+ hb_zip (mark_coverage, mark_array)
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
| hb_map (&MarkRecord::get_class)
|
|
|
|
| hb_sink (orig_classes)
|
|
|
|
;
|
|
|
|
|
|
|
|
unsigned idx = 0;
|
|
|
|
for (auto klass : orig_classes.iter ())
|
|
|
|
{
|
|
|
|
if (klass_mapping->has (klass)) continue;
|
|
|
|
klass_mapping->set (klass, idx);
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkBasePosFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2020-07-18 19:44:52 +02:00
|
|
|
{
|
|
|
|
return (this+markCoverage).intersects (glyphs) &&
|
|
|
|
(this+baseCoverage).intersects (glyphs);
|
|
|
|
}
|
2018-09-03 04:47:50 +02:00
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
+ hb_zip (this+markCoverage, this+markArray)
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
| hb_apply ([&] (const MarkRecord& record) { record.collect_variation_indices (c, &(this+markArray)); })
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_map_t klass_mapping;
|
|
|
|
Markclass_closure_and_remap_indexes (this+markCoverage, this+markArray, *c->glyph_set, &klass_mapping);
|
|
|
|
|
|
|
|
unsigned basecount = (this+baseArray).rows;
|
|
|
|
auto base_iter =
|
|
|
|
+ hb_zip (this+baseCoverage, hb_range (basecount))
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_sorted_vector_t<unsigned> base_indexes;
|
|
|
|
for (const unsigned row : base_iter)
|
|
|
|
{
|
|
|
|
+ hb_range ((unsigned) classCount)
|
|
|
|
| hb_filter (klass_mapping)
|
|
|
|
| hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; })
|
|
|
|
| hb_sink (base_indexes)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
(this+baseArray).collect_variation_indices (c, base_indexes.iter ());
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
2020-04-23 19:55:41 +02:00
|
|
|
if (unlikely (!(this+markCoverage).collect_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+baseCoverage).collect_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+markCoverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int mark_index = (this+markCoverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (mark_index == NOT_COVERED)) return_trace (false);
|
2009-05-21 12:32:01 +02:00
|
|
|
|
2016-02-11 10:57:52 +01:00
|
|
|
/* Now we search backwards for a non-mark glyph */
|
2018-01-18 01:46:51 +01:00
|
|
|
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
|
2015-01-29 13:40:39 +01:00
|
|
|
skippy_iter.reset (buffer->idx, 1);
|
2013-02-13 17:22:42 +01:00
|
|
|
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
|
2012-06-09 04:04:23 +02:00
|
|
|
do {
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!skippy_iter.prev ()) return_trace (false);
|
2018-02-11 04:50:26 +01:00
|
|
|
/* We only want to attach to the first of a MultipleSubst sequence.
|
|
|
|
* https://github.com/harfbuzz/harfbuzz/issues/740
|
Adjust MarkBasePos heuristic in presence of MultipleSubst
From the issue:
"In this font, the virama,ya first forms a ligature, then decomposes back to
virama,ya. This causes those two to be marked parts of a MultipleSubst
sequence. When attaching the matra, we look for the first of the MultipleSubst
sequence because that's where we attach to (because of eg #740). In this case,
the first glyph in the MultipleSubst sequence is a mark, so we skip it and
attach to the base char before it."
Font in question is Nirmala UI from Windows 10. Test sequence:
U+0926,U+094D,U+092F,U+0941
Fixes https://github.com/harfbuzz/harfbuzz/issues/1020
2018-06-30 13:29:25 +02:00
|
|
|
* Reject others...
|
|
|
|
* ...but stop if we find a mark in the MultipleSubst sequence:
|
|
|
|
* https://github.com/harfbuzz/harfbuzz/issues/1020 */
|
2017-10-03 13:46:25 +02:00
|
|
|
if (!_hb_glyph_info_multiplied (&buffer->info[skippy_iter.idx]) ||
|
2018-02-11 04:50:26 +01:00
|
|
|
0 == _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]) ||
|
|
|
|
(skippy_iter.idx == 0 ||
|
Adjust MarkBasePos heuristic in presence of MultipleSubst
From the issue:
"In this font, the virama,ya first forms a ligature, then decomposes back to
virama,ya. This causes those two to be marked parts of a MultipleSubst
sequence. When attaching the matra, we look for the first of the MultipleSubst
sequence because that's where we attach to (because of eg #740). In this case,
the first glyph in the MultipleSubst sequence is a mark, so we skip it and
attach to the base char before it."
Font in question is Nirmala UI from Windows 10. Test sequence:
U+0926,U+094D,U+092F,U+0941
Fixes https://github.com/harfbuzz/harfbuzz/issues/1020
2018-06-30 13:29:25 +02:00
|
|
|
_hb_glyph_info_is_mark (&buffer->info[skippy_iter.idx - 1]) ||
|
2018-02-11 04:50:26 +01:00
|
|
|
_hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx]) !=
|
2018-02-19 00:57:09 +01:00
|
|
|
_hb_glyph_info_get_lig_id (&buffer->info[skippy_iter.idx - 1]) ||
|
|
|
|
_hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx]) !=
|
|
|
|
_hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx - 1]) + 1
|
|
|
|
))
|
2017-10-03 13:46:25 +02:00
|
|
|
break;
|
2012-06-09 04:04:23 +02:00
|
|
|
skippy_iter.reject ();
|
2018-10-18 17:18:42 +02:00
|
|
|
} while (true);
|
2009-08-12 21:40:04 +02:00
|
|
|
|
2013-10-18 00:42:39 +02:00
|
|
|
/* Checking that matched glyph is actually a base glyph by GDEF is too strong; disabled */
|
2016-02-11 10:57:52 +01:00
|
|
|
//if (!_hb_glyph_info_is_base_glyph (&buffer->info[skippy_iter.idx])) { return_trace (false); }
|
2009-05-21 12:32:01 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int base_index = (this+baseCoverage).get_coverage (buffer->info[skippy_iter.idx].codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (base_index == NOT_COVERED) return_trace (false);
|
2009-05-21 12:32:01 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx));
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2020-02-04 22:24:37 +01:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
out->format = format;
|
|
|
|
|
|
|
|
hb_map_t klass_mapping;
|
|
|
|
Markclass_closure_and_remap_indexes (this+markCoverage, this+markArray, glyphset, &klass_mapping);
|
2020-03-08 21:09:24 +01:00
|
|
|
|
2020-02-04 22:24:37 +01:00
|
|
|
if (!klass_mapping.get_population ()) return_trace (false);
|
|
|
|
out->classCount = klass_mapping.get_population ();
|
|
|
|
|
|
|
|
auto mark_iter =
|
|
|
|
+ hb_zip (this+markCoverage, this+markArray)
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
|
|
|
+ mark_iter
|
|
|
|
| hb_map (hb_first)
|
|
|
|
| hb_map (glyph_map)
|
|
|
|
| hb_sink (new_coverage)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
if (!out->markCoverage.serialize_serialize (c->serializer, new_coverage.iter ()))
|
2020-02-04 22:24:37 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
out->markArray.serialize_subset (c, markArray, this,
|
|
|
|
(this+markCoverage).iter (),
|
|
|
|
&klass_mapping);
|
2020-02-04 22:24:37 +01:00
|
|
|
|
|
|
|
unsigned basecount = (this+baseArray).rows;
|
|
|
|
auto base_iter =
|
|
|
|
+ hb_zip (this+baseCoverage, hb_range (basecount))
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
;
|
|
|
|
|
|
|
|
new_coverage.reset ();
|
|
|
|
+ base_iter
|
|
|
|
| hb_map (hb_first)
|
|
|
|
| hb_map (glyph_map)
|
|
|
|
| hb_sink (new_coverage)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
if (!out->baseCoverage.serialize_serialize (c->serializer, new_coverage.iter ()))
|
2020-02-04 22:24:37 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
|
|
|
hb_sorted_vector_t<unsigned> base_indexes;
|
|
|
|
for (const unsigned row : + base_iter
|
|
|
|
| hb_map (hb_second))
|
|
|
|
{
|
|
|
|
+ hb_range ((unsigned) classCount)
|
|
|
|
| hb_filter (klass_mapping)
|
|
|
|
| hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; })
|
|
|
|
| hb_sink (base_indexes)
|
|
|
|
;
|
|
|
|
}
|
2021-04-02 23:37:10 +02:00
|
|
|
|
|
|
|
out->baseArray.serialize_subset (c, baseArray, this,
|
|
|
|
base_iter.len (),
|
|
|
|
base_indexes.iter ());
|
2020-02-04 22:24:37 +01:00
|
|
|
|
|
|
|
return_trace (true);
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
markCoverage.sanitize (c, this) &&
|
|
|
|
baseCoverage.sanitize (c, this) &&
|
|
|
|
markArray.sanitize (c, this) &&
|
|
|
|
baseArray.sanitize (c, this, (unsigned int) classCount));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-21 10:47:05 +02:00
|
|
|
markCoverage; /* Offset to MarkCoverage table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkBasePos subtable */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-21 10:47:05 +02:00
|
|
|
baseCoverage; /* Offset to BaseCoverage table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkBasePos subtable */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 classCount; /* Number of classes defined for marks */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<MarkArray>
|
2009-05-21 10:47:05 +02:00
|
|
|
markArray; /* Offset to MarkArray table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkBasePos subtable */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<BaseArray>
|
2009-05-21 10:47:05 +02:00
|
|
|
baseArray; /* Offset to BaseArray table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkBasePos subtable */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (12);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkBasePos
|
|
|
|
{
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2012-07-28 23:31:01 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, u.format);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (u.format) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default:return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
MarkBasePosFormat1 format1;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-15 00:14:03 +02:00
|
|
|
typedef AnchorMatrix LigatureAttach; /* component-major--
|
|
|
|
* in order of writing direction--,
|
|
|
|
* mark-minor--
|
2009-05-23 00:29:45 +02:00
|
|
|
* ordered by class--zero-based. */
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2020-02-07 00:08:26 +01:00
|
|
|
/* Array of LigatureAttach tables ordered by LigatureCoverage Index */
|
2021-03-31 23:33:22 +02:00
|
|
|
struct LigatureArray : List16OfOffset16To<LigatureAttach>
|
2020-02-07 00:08:26 +01:00
|
|
|
{
|
|
|
|
template <typename Iterator,
|
|
|
|
hb_requires (hb_is_iterator (Iterator))>
|
2020-10-05 22:14:53 +02:00
|
|
|
bool subset (hb_subset_context_t *c,
|
2021-04-02 23:37:10 +02:00
|
|
|
Iterator coverage,
|
2020-10-05 22:14:53 +02:00
|
|
|
unsigned class_count,
|
|
|
|
const hb_map_t *klass_mapping) const
|
2020-02-07 00:08:26 +01:00
|
|
|
{
|
2020-10-05 22:14:53 +02:00
|
|
|
TRACE_SUBSET (this);
|
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2020-02-07 00:08:26 +01:00
|
|
|
|
2020-10-05 22:14:53 +02:00
|
|
|
auto *out = c->serializer->start_embed (this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
2020-10-02 01:44:16 +02:00
|
|
|
|
2021-02-20 00:48:30 +01:00
|
|
|
for (const auto _ : + hb_zip (coverage, *this)
|
|
|
|
| hb_filter (glyphset, hb_first))
|
2020-02-07 00:08:26 +01:00
|
|
|
{
|
2020-10-05 22:14:53 +02:00
|
|
|
auto *matrix = out->serialize_append (c->serializer);
|
|
|
|
if (unlikely (!matrix)) return_trace (false);
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
const LigatureAttach& src = (this + _.second);
|
|
|
|
auto indexes =
|
|
|
|
+ hb_range (src.rows * class_count)
|
|
|
|
| hb_filter ([=] (unsigned index) { return klass_mapping->has (index % class_count); })
|
|
|
|
;
|
2020-10-05 22:14:53 +02:00
|
|
|
matrix->serialize_subset (c,
|
2021-02-20 00:48:30 +01:00
|
|
|
_.second,
|
2020-10-05 22:14:53 +02:00
|
|
|
this,
|
2021-04-02 23:37:10 +02:00
|
|
|
src.rows,
|
|
|
|
indexes);
|
2020-02-07 00:08:26 +01:00
|
|
|
}
|
|
|
|
return_trace (this->len);
|
|
|
|
}
|
|
|
|
};
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkLigPosFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2020-07-18 19:44:52 +02:00
|
|
|
{
|
|
|
|
return (this+markCoverage).intersects (glyphs) &&
|
|
|
|
(this+ligatureCoverage).intersects (glyphs);
|
|
|
|
}
|
2018-09-03 04:47:50 +02:00
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
+ hb_zip (this+markCoverage, this+markArray)
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
| hb_apply ([&] (const MarkRecord& record) { record.collect_variation_indices (c, &(this+markArray)); })
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_map_t klass_mapping;
|
|
|
|
Markclass_closure_and_remap_indexes (this+markCoverage, this+markArray, *c->glyph_set, &klass_mapping);
|
|
|
|
|
|
|
|
unsigned ligcount = (this+ligatureArray).len;
|
|
|
|
auto lig_iter =
|
|
|
|
+ hb_zip (this+ligatureCoverage, hb_range (ligcount))
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
;
|
|
|
|
|
|
|
|
const LigatureArray& lig_array = this+ligatureArray;
|
|
|
|
for (const unsigned i : lig_iter)
|
|
|
|
{
|
|
|
|
hb_sorted_vector_t<unsigned> lig_indexes;
|
|
|
|
unsigned row_count = lig_array[i].rows;
|
|
|
|
for (unsigned row : + hb_range (row_count))
|
|
|
|
{
|
2020-07-29 06:03:32 +02:00
|
|
|
+ hb_range ((unsigned) classCount)
|
|
|
|
| hb_filter (klass_mapping)
|
|
|
|
| hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; })
|
|
|
|
| hb_sink (lig_indexes)
|
|
|
|
;
|
2020-02-26 22:11:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lig_array[i].collect_variation_indices (c, lig_indexes.iter ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
2020-04-23 19:55:41 +02:00
|
|
|
if (unlikely (!(this+markCoverage).collect_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+ligatureCoverage).collect_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+markCoverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int mark_index = (this+markCoverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (mark_index == NOT_COVERED)) return_trace (false);
|
2009-05-23 00:29:45 +02:00
|
|
|
|
2016-02-11 10:57:52 +01:00
|
|
|
/* Now we search backwards for a non-mark glyph */
|
2018-01-18 01:46:51 +01:00
|
|
|
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
|
2015-01-29 13:40:39 +01:00
|
|
|
skippy_iter.reset (buffer->idx, 1);
|
2013-02-13 17:22:42 +01:00
|
|
|
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!skippy_iter.prev ()) return_trace (false);
|
2009-08-12 21:40:04 +02:00
|
|
|
|
2013-10-18 00:42:39 +02:00
|
|
|
/* Checking that matched glyph is actually a ligature by GDEF is too strong; disabled */
|
2016-02-11 10:57:52 +01:00
|
|
|
//if (!_hb_glyph_info_is_ligature (&buffer->info[skippy_iter.idx])) { return_trace (false); }
|
2009-05-23 00:29:45 +02:00
|
|
|
|
2012-01-17 04:05:08 +01:00
|
|
|
unsigned int j = skippy_iter.idx;
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int lig_index = (this+ligatureCoverage).get_coverage (buffer->info[j].codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (lig_index == NOT_COVERED) return_trace (false);
|
2009-05-23 00:29:45 +02:00
|
|
|
|
|
|
|
const LigatureArray& lig_array = this+ligatureArray;
|
2009-08-15 00:32:56 +02:00
|
|
|
const LigatureAttach& lig_attach = lig_array[lig_index];
|
2009-08-15 00:14:03 +02:00
|
|
|
|
|
|
|
/* Find component to attach to */
|
2009-08-15 01:37:18 +02:00
|
|
|
unsigned int comp_count = lig_attach.rows;
|
2015-09-29 15:57:02 +02:00
|
|
|
if (unlikely (!comp_count)) return_trace (false);
|
2012-05-11 02:33:11 +02:00
|
|
|
|
2009-05-23 00:29:45 +02:00
|
|
|
/* We must now check whether the ligature ID of the current mark glyph
|
|
|
|
* is identical to the ligature ID of the found ligature. If yes, we
|
|
|
|
* can directly use the component index. If not, we attach the mark
|
|
|
|
* glyph to the last component of the ligature. */
|
2012-07-30 06:55:15 +02:00
|
|
|
unsigned int comp_index;
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int lig_id = _hb_glyph_info_get_lig_id (&buffer->info[j]);
|
|
|
|
unsigned int mark_id = _hb_glyph_info_get_lig_id (&buffer->cur());
|
|
|
|
unsigned int mark_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
|
2012-07-30 06:55:15 +02:00
|
|
|
if (lig_id && lig_id == mark_id && mark_comp > 0)
|
2019-05-08 05:54:31 +02:00
|
|
|
comp_index = hb_min (comp_count, _hb_glyph_info_get_lig_comp (&buffer->cur())) - 1;
|
2009-05-23 00:29:45 +02:00
|
|
|
else
|
2009-08-15 01:37:18 +02:00
|
|
|
comp_index = comp_count - 1;
|
2009-05-23 00:29:45 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j));
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2020-10-05 22:14:53 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2020-02-07 00:08:26 +01:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
out->format = format;
|
|
|
|
|
|
|
|
hb_map_t klass_mapping;
|
|
|
|
Markclass_closure_and_remap_indexes (this+markCoverage, this+markArray, glyphset, &klass_mapping);
|
2020-10-02 01:44:16 +02:00
|
|
|
|
2020-02-07 00:08:26 +01:00
|
|
|
if (!klass_mapping.get_population ()) return_trace (false);
|
|
|
|
out->classCount = klass_mapping.get_population ();
|
|
|
|
|
|
|
|
auto mark_iter =
|
|
|
|
+ hb_zip (this+markCoverage, this+markArray)
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
;
|
|
|
|
|
2020-10-05 22:14:53 +02:00
|
|
|
auto new_mark_coverage =
|
2020-02-07 00:08:26 +01:00
|
|
|
+ mark_iter
|
2020-10-05 22:14:53 +02:00
|
|
|
| hb_map_retains_sorting (hb_first)
|
|
|
|
| hb_map_retains_sorting (glyph_map)
|
2020-02-07 00:08:26 +01:00
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
if (!out->markCoverage.serialize_serialize (c->serializer, new_mark_coverage))
|
2020-02-07 00:08:26 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
out->markArray.serialize_subset (c, markArray, this,
|
|
|
|
(this+markCoverage).iter (),
|
|
|
|
&klass_mapping);
|
2020-10-02 01:44:16 +02:00
|
|
|
|
2020-10-05 22:14:53 +02:00
|
|
|
auto new_ligature_coverage =
|
|
|
|
+ hb_iter (this + ligatureCoverage)
|
|
|
|
| hb_filter (glyphset)
|
|
|
|
| hb_map_retains_sorting (glyph_map)
|
2020-02-07 00:08:26 +01:00
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
if (!out->ligatureCoverage.serialize_serialize (c->serializer, new_ligature_coverage))
|
2020-02-07 00:08:26 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
2020-10-05 22:14:53 +02:00
|
|
|
out->ligatureArray.serialize_subset (c, ligatureArray, this,
|
|
|
|
hb_iter (this+ligatureCoverage), classCount, &klass_mapping);
|
2020-02-07 00:08:26 +01:00
|
|
|
|
|
|
|
return_trace (true);
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
markCoverage.sanitize (c, this) &&
|
|
|
|
ligatureCoverage.sanitize (c, this) &&
|
|
|
|
markArray.sanitize (c, this) &&
|
|
|
|
ligatureArray.sanitize (c, this, (unsigned int) classCount));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-23 00:29:45 +02:00
|
|
|
markCoverage; /* Offset to Mark Coverage table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkLigPos subtable */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-23 00:29:45 +02:00
|
|
|
ligatureCoverage; /* Offset to Ligature Coverage
|
2009-05-18 23:09:33 +02:00
|
|
|
* table--from beginning of MarkLigPos
|
|
|
|
* subtable */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 classCount; /* Number of defined mark classes */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<MarkArray>
|
2009-05-23 00:29:45 +02:00
|
|
|
markArray; /* Offset to MarkArray table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkLigPos subtable */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<LigatureArray>
|
2009-05-23 00:29:45 +02:00
|
|
|
ligatureArray; /* Offset to LigatureArray table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkLigPos subtable */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (12);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2020-10-05 22:14:53 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkLigPos
|
|
|
|
{
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2012-07-28 23:31:01 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, u.format);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (u.format) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default:return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
MarkLigPosFormat1 format1;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-15 00:14:03 +02:00
|
|
|
typedef AnchorMatrix Mark2Array; /* mark2-major--
|
|
|
|
* in order of Mark2Coverage Index--,
|
|
|
|
* mark1-minor--
|
|
|
|
* ordered by class--zero-based. */
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkMarkPosFormat1
|
|
|
|
{
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2020-07-18 19:44:52 +02:00
|
|
|
{
|
|
|
|
return (this+mark1Coverage).intersects (glyphs) &&
|
|
|
|
(this+mark2Coverage).intersects (glyphs);
|
|
|
|
}
|
2018-09-03 04:47:50 +02:00
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
void closure_lookups (hb_closure_lookups_context_t *c) const {}
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
+ hb_zip (this+mark1Coverage, this+mark1Array)
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
| hb_apply ([&] (const MarkRecord& record) { record.collect_variation_indices (c, &(this+mark1Array)); })
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_map_t klass_mapping;
|
|
|
|
Markclass_closure_and_remap_indexes (this+mark1Coverage, this+mark1Array, *c->glyph_set, &klass_mapping);
|
|
|
|
|
|
|
|
unsigned mark2_count = (this+mark2Array).rows;
|
|
|
|
auto mark2_iter =
|
|
|
|
+ hb_zip (this+mark2Coverage, hb_range (mark2_count))
|
|
|
|
| hb_filter (c->glyph_set, hb_first)
|
|
|
|
| hb_map (hb_second)
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_sorted_vector_t<unsigned> mark2_indexes;
|
|
|
|
for (const unsigned row : mark2_iter)
|
|
|
|
{
|
|
|
|
+ hb_range ((unsigned) classCount)
|
|
|
|
| hb_filter (klass_mapping)
|
|
|
|
| hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; })
|
|
|
|
| hb_sink (mark2_indexes)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
(this+mark2Array).collect_variation_indices (c, mark2_indexes.iter ());
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
2020-04-23 19:55:41 +02:00
|
|
|
if (unlikely (!(this+mark1Coverage).collect_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+mark2Coverage).collect_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
const Coverage &get_coverage () const { return this+mark1Coverage; }
|
2012-07-28 23:31:01 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_APPLY (this);
|
2013-10-18 19:33:09 +02:00
|
|
|
hb_buffer_t *buffer = c->buffer;
|
|
|
|
unsigned int mark1_index = (this+mark1Coverage).get_coverage (buffer->cur().codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (likely (mark1_index == NOT_COVERED)) return_trace (false);
|
2009-05-21 14:27:07 +02:00
|
|
|
|
|
|
|
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
|
2018-01-18 01:46:51 +01:00
|
|
|
hb_ot_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
|
2015-01-29 13:40:39 +01:00
|
|
|
skippy_iter.reset (buffer->idx, 1);
|
2013-02-13 17:22:42 +01:00
|
|
|
skippy_iter.set_lookup_props (c->lookup_props & ~LookupFlag::IgnoreFlags);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!skippy_iter.prev ()) return_trace (false);
|
2009-08-12 21:40:04 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!_hb_glyph_info_is_mark (&buffer->info[skippy_iter.idx])) { return_trace (false); }
|
2009-05-26 23:58:37 +02:00
|
|
|
|
2012-01-17 04:05:08 +01:00
|
|
|
unsigned int j = skippy_iter.idx;
|
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int id1 = _hb_glyph_info_get_lig_id (&buffer->cur());
|
|
|
|
unsigned int id2 = _hb_glyph_info_get_lig_id (&buffer->info[j]);
|
|
|
|
unsigned int comp1 = _hb_glyph_info_get_lig_comp (&buffer->cur());
|
|
|
|
unsigned int comp2 = _hb_glyph_info_get_lig_comp (&buffer->info[j]);
|
2012-07-29 03:05:25 +02:00
|
|
|
|
2020-07-18 19:44:52 +02:00
|
|
|
if (likely (id1 == id2))
|
|
|
|
{
|
2012-07-29 03:05:25 +02:00
|
|
|
if (id1 == 0) /* Marks belonging to the same base. */
|
|
|
|
goto good;
|
|
|
|
else if (comp1 == comp2) /* Marks belonging to the same ligature component. */
|
2018-11-15 20:40:56 +01:00
|
|
|
goto good;
|
2020-07-18 19:44:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-29 03:05:25 +02:00
|
|
|
/* If ligature ids don't match, it may be the case that one of the marks
|
|
|
|
* itself is a ligature. In which case match. */
|
|
|
|
if ((id1 > 0 && !comp1) || (id2 > 0 && !comp2))
|
|
|
|
goto good;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Didn't match. */
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (false);
|
2009-05-21 14:27:07 +02:00
|
|
|
|
2012-07-29 03:05:25 +02:00
|
|
|
good:
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int mark2_index = (this+mark2Coverage).get_coverage (buffer->info[j].codepoint);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (mark2_index == NOT_COVERED) return_trace (false);
|
2009-05-21 14:27:07 +02:00
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j));
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{
|
|
|
|
TRACE_SUBSET (this);
|
2020-09-29 20:05:08 +02:00
|
|
|
const hb_set_t &glyphset = *c->plan->glyphset_gsub ();
|
2020-02-06 00:29:03 +01:00
|
|
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
|
|
|
|
|
|
|
auto *out = c->serializer->start_embed (*this);
|
|
|
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
|
|
|
out->format = format;
|
|
|
|
|
|
|
|
hb_map_t klass_mapping;
|
|
|
|
Markclass_closure_and_remap_indexes (this+mark1Coverage, this+mark1Array, glyphset, &klass_mapping);
|
2020-03-08 21:09:24 +01:00
|
|
|
|
2020-02-06 00:29:03 +01:00
|
|
|
if (!klass_mapping.get_population ()) return_trace (false);
|
|
|
|
out->classCount = klass_mapping.get_population ();
|
|
|
|
|
|
|
|
auto mark1_iter =
|
|
|
|
+ hb_zip (this+mark1Coverage, this+mark1Array)
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
;
|
|
|
|
|
|
|
|
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
|
|
|
+ mark1_iter
|
|
|
|
| hb_map (hb_first)
|
|
|
|
| hb_map (glyph_map)
|
|
|
|
| hb_sink (new_coverage)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
if (!out->mark1Coverage.serialize_serialize (c->serializer, new_coverage.iter ()))
|
2020-02-06 00:29:03 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
2021-04-02 23:37:10 +02:00
|
|
|
out->mark1Array.serialize_subset (c, mark1Array, this,
|
|
|
|
(this+mark1Coverage).iter (),
|
|
|
|
&klass_mapping);
|
2020-07-18 19:44:52 +02:00
|
|
|
|
2020-02-06 00:29:03 +01:00
|
|
|
unsigned mark2count = (this+mark2Array).rows;
|
|
|
|
auto mark2_iter =
|
|
|
|
+ hb_zip (this+mark2Coverage, hb_range (mark2count))
|
|
|
|
| hb_filter (glyphset, hb_first)
|
|
|
|
;
|
|
|
|
|
|
|
|
new_coverage.reset ();
|
|
|
|
+ mark2_iter
|
|
|
|
| hb_map (hb_first)
|
|
|
|
| hb_map (glyph_map)
|
|
|
|
| hb_sink (new_coverage)
|
|
|
|
;
|
|
|
|
|
2021-06-11 22:40:39 +02:00
|
|
|
if (!out->mark2Coverage.serialize_serialize (c->serializer, new_coverage.iter ()))
|
2020-02-06 00:29:03 +01:00
|
|
|
return_trace (false);
|
|
|
|
|
|
|
|
hb_sorted_vector_t<unsigned> mark2_indexes;
|
|
|
|
for (const unsigned row : + mark2_iter
|
|
|
|
| hb_map (hb_second))
|
|
|
|
{
|
|
|
|
+ hb_range ((unsigned) classCount)
|
|
|
|
| hb_filter (klass_mapping)
|
|
|
|
| hb_map ([&] (const unsigned col) { return row * (unsigned) classCount + col; })
|
|
|
|
| hb_sink (mark2_indexes)
|
|
|
|
;
|
|
|
|
}
|
2021-04-02 23:37:10 +02:00
|
|
|
|
|
|
|
out->mark2Array.serialize_subset (c, mark2Array, this, mark2_iter.len (), mark2_indexes.iter ());
|
2020-02-06 00:29:03 +01:00
|
|
|
|
|
|
|
return_trace (true);
|
2018-09-04 02:33:34 +02:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
mark1Coverage.sanitize (c, this) &&
|
|
|
|
mark2Coverage.sanitize (c, this) &&
|
|
|
|
mark1Array.sanitize (c, this) &&
|
|
|
|
mark2Array.sanitize (c, this, (unsigned int) classCount));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier--format = 1 */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-21 14:27:07 +02:00
|
|
|
mark1Coverage; /* Offset to Combining Mark1 Coverage
|
2009-05-18 23:09:33 +02:00
|
|
|
* table--from beginning of MarkMarkPos
|
|
|
|
* subtable */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Coverage>
|
2009-05-21 14:27:07 +02:00
|
|
|
mark2Coverage; /* Offset to Combining Mark2 Coverage
|
2009-05-18 23:09:33 +02:00
|
|
|
* table--from beginning of MarkMarkPos
|
|
|
|
* subtable */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 classCount; /* Number of defined mark classes */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<MarkArray>
|
2009-05-21 14:27:07 +02:00
|
|
|
mark1Array; /* Offset to Mark1Array table--from
|
|
|
|
* beginning of MarkMarkPos subtable */
|
2021-03-31 20:49:14 +02:00
|
|
|
Offset16To<Mark2Array>
|
2009-05-21 14:27:07 +02:00
|
|
|
mark2Array; /* Offset to Mark2Array table--from
|
|
|
|
* beginning of MarkMarkPos subtable */
|
2010-05-10 22:57:29 +02:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (12);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkMarkPos
|
|
|
|
{
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2012-07-28 23:31:01 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, u.format);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (u.format) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default:return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 format; /* Format identifier */
|
2010-05-11 01:45:41 +02:00
|
|
|
MarkMarkPosFormat1 format1;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-23 22:51:43 +01:00
|
|
|
struct ContextPos : Context {};
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2012-11-23 22:51:43 +01:00
|
|
|
struct ChainContextPos : ChainContext {};
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2012-11-23 22:57:36 +01:00
|
|
|
struct ExtensionPos : Extension<ExtensionPos>
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2018-09-04 01:53:03 +02:00
|
|
|
typedef struct PosLookupSubTable SubTable;
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-22 04:31:33 +02:00
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
/*
|
|
|
|
* PosLookup
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PosLookupSubTable
|
|
|
|
{
|
2018-09-04 02:16:09 +02:00
|
|
|
friend struct Lookup;
|
2009-05-18 23:09:33 +02:00
|
|
|
friend struct PosLookup;
|
|
|
|
|
2012-04-12 19:23:59 +02:00
|
|
|
enum Type {
|
2009-05-20 09:53:00 +02:00
|
|
|
Single = 1,
|
|
|
|
Pair = 2,
|
|
|
|
Cursive = 3,
|
|
|
|
MarkBase = 4,
|
|
|
|
MarkLig = 5,
|
|
|
|
MarkMark = 6,
|
|
|
|
Context = 7,
|
|
|
|
ChainContext = 8,
|
2009-08-18 22:41:59 +02:00
|
|
|
Extension = 9
|
2009-05-20 09:53:00 +02:00
|
|
|
};
|
|
|
|
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type, Ts&&... ds) const
|
2012-06-09 09:02:36 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, lookup_type);
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (lookup_type) {
|
2019-05-05 19:14:17 +02:00
|
|
|
case Single: return_trace (u.single.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case Pair: return_trace (u.pair.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case Cursive: return_trace (u.cursive.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case MarkBase: return_trace (u.markBase.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case MarkLig: return_trace (u.markLig.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case MarkMark: return_trace (u.markMark.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case Context: return_trace (u.context.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case ChainContext: return_trace (u.chainContext.dispatch (c, hb_forward<Ts> (ds)...));
|
|
|
|
case Extension: return_trace (u.extension.dispatch (c, hb_forward<Ts> (ds)...));
|
2015-09-29 15:57:02 +02:00
|
|
|
default: return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
2012-06-09 09:02:36 +02:00
|
|
|
}
|
|
|
|
|
2020-01-19 01:35:52 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs, unsigned int lookup_type) const
|
|
|
|
{
|
|
|
|
hb_intersects_context_t c (glyphs);
|
|
|
|
return dispatch (&c, lookup_type);
|
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
union {
|
2010-05-11 01:45:41 +02:00
|
|
|
SinglePos single;
|
|
|
|
PairPos pair;
|
|
|
|
CursivePos cursive;
|
|
|
|
MarkBasePos markBase;
|
|
|
|
MarkLigPos markLig;
|
|
|
|
MarkMarkPos markMark;
|
2012-07-19 20:35:23 +02:00
|
|
|
ContextPos context;
|
2010-05-11 01:45:41 +02:00
|
|
|
ChainContextPos chainContext;
|
|
|
|
ExtensionPos extension;
|
2009-05-18 23:09:33 +02:00
|
|
|
} u;
|
2010-05-11 00:08:46 +02:00
|
|
|
public:
|
2018-12-12 16:07:38 +01:00
|
|
|
DEFINE_SIZE_MIN (0);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PosLookup : Lookup
|
|
|
|
{
|
2018-09-04 01:53:03 +02:00
|
|
|
typedef struct PosLookupSubTable SubTable;
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
const SubTable& get_subtable (unsigned int i) const
|
2018-09-04 01:53:03 +02:00
|
|
|
{ return Lookup::get_subtable<SubTable> (i); }
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
bool is_reverse () const
|
2013-05-03 23:34:29 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool apply (hb_ot_apply_context_t *c) const
|
2015-02-19 08:47:18 +01:00
|
|
|
{
|
|
|
|
TRACE_APPLY (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (dispatch (c));
|
2015-02-19 08:47:18 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool intersects (const hb_set_t *glyphs) const
|
2018-09-03 04:47:50 +02:00
|
|
|
{
|
|
|
|
hb_intersects_context_t c (glyphs);
|
|
|
|
return dispatch (&c);
|
|
|
|
}
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2019-01-18 20:59:18 +01:00
|
|
|
{ return dispatch (c); }
|
2012-11-24 07:38:41 +01:00
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
hb_closure_lookups_context_t::return_t closure_lookups (hb_closure_lookups_context_t *c, unsigned this_index) const
|
|
|
|
{
|
|
|
|
if (c->is_lookup_visited (this_index))
|
|
|
|
return hb_closure_lookups_context_t::default_return_value ();
|
|
|
|
|
|
|
|
c->set_lookup_visited (this_index);
|
|
|
|
if (!intersects (c->glyphs))
|
|
|
|
{
|
|
|
|
c->set_lookup_inactive (this_index);
|
|
|
|
return hb_closure_lookups_context_t::default_return_value ();
|
|
|
|
}
|
|
|
|
c->set_recurse_func (dispatch_closure_lookups_recurse_func);
|
|
|
|
|
|
|
|
hb_closure_lookups_context_t::return_t ret = dispatch (c);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-08-02 03:18:54 +02:00
|
|
|
template <typename set_t>
|
2020-04-23 19:55:41 +02:00
|
|
|
void collect_coverage (set_t *glyphs) const
|
2012-08-02 03:18:54 +02:00
|
|
|
{
|
2020-04-23 19:55:41 +02:00
|
|
|
hb_collect_coverage_context_t<set_t> c (glyphs);
|
2015-02-17 17:15:34 +01:00
|
|
|
dispatch (&c);
|
2012-08-02 03:18:54 +02:00
|
|
|
}
|
|
|
|
|
2019-12-10 20:31:50 +01:00
|
|
|
static inline bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index);
|
2012-11-22 22:05:59 +01:00
|
|
|
|
2013-03-09 07:59:30 +01:00
|
|
|
template <typename context_t>
|
2018-12-16 20:08:10 +01:00
|
|
|
static typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index);
|
2013-03-09 07:59:30 +01:00
|
|
|
|
2019-10-23 01:00:43 +02:00
|
|
|
HB_INTERNAL static hb_closure_lookups_context_t::return_t dispatch_closure_lookups_recurse_func (hb_closure_lookups_context_t *c, unsigned this_index);
|
|
|
|
|
2019-05-05 19:14:17 +02:00
|
|
|
template <typename context_t, typename ...Ts>
|
2019-05-08 05:58:43 +02:00
|
|
|
typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const
|
2019-05-05 19:14:17 +02:00
|
|
|
{ return Lookup::dispatch<SubTable> (c, hb_forward<Ts> (ds)...); }
|
2013-03-09 07:59:30 +01:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{ return Lookup::subset<SubTable> (c); }
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2018-09-04 02:16:09 +02:00
|
|
|
{ return Lookup::sanitize<SubTable> (c); }
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2018-04-12 11:08:19 +02:00
|
|
|
* GPOS -- Glyph Positioning
|
|
|
|
* https://docs.microsoft.com/en-us/typography/opentype/spec/gpos
|
2009-05-18 23:09:33 +02:00
|
|
|
*/
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct GPOS : GSUBGPOS
|
|
|
|
{
|
2019-01-22 12:08:57 +01:00
|
|
|
static constexpr hb_tag_t tableTag = HB_OT_TAG_GPOS;
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
const PosLookup& get_lookup (unsigned int i) const
|
2019-12-10 20:18:32 +01:00
|
|
|
{ return static_cast<const PosLookup &> (GSUBGPOS::get_lookup (i)); }
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2012-07-31 01:30:01 +02:00
|
|
|
static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
|
2016-02-11 10:34:28 +01:00
|
|
|
static inline void position_finish_advances (hb_font_t *font, hb_buffer_t *buffer);
|
|
|
|
static inline void position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer);
|
2010-10-28 04:48:31 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool subset (hb_subset_context_t *c) const
|
2019-11-01 18:21:36 +01:00
|
|
|
{
|
2021-01-29 00:21:26 +01:00
|
|
|
hb_subset_layout_context_t l (c, tableTag, c->plan->gpos_lookups, c->plan->gpos_langsys, c->plan->gpos_features);
|
2019-11-01 18:21:36 +01:00
|
|
|
return GSUBGPOS::subset<PosLookup> (&l);
|
|
|
|
}
|
2018-09-04 02:33:34 +02:00
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2018-09-04 02:33:34 +02:00
|
|
|
{ return GSUBGPOS::sanitize<PosLookup> (c); }
|
2018-08-26 09:47:55 +02:00
|
|
|
|
2020-06-05 21:57:23 +02:00
|
|
|
HB_INTERNAL bool is_blocklisted (hb_blob_t *blob,
|
2018-11-25 22:51:22 +01:00
|
|
|
hb_face_t *face) const;
|
|
|
|
|
2020-02-26 22:11:42 +01:00
|
|
|
void collect_variation_indices (hb_collect_variation_indices_context_t *c) const
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < GSUBGPOS::get_lookup_count (); i++)
|
|
|
|
{
|
|
|
|
if (!c->gpos_lookups->has (i)) continue;
|
|
|
|
const PosLookup &l = get_lookup (i);
|
|
|
|
l.dispatch (c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 20:27:57 +02:00
|
|
|
void closure_lookups (hb_face_t *face,
|
|
|
|
const hb_set_t *glyphs,
|
|
|
|
hb_set_t *lookup_indexes /* IN/OUT */) const
|
|
|
|
{ GSUBGPOS::closure_lookups<PosLookup> (face, glyphs, lookup_indexes); }
|
|
|
|
|
2018-08-26 09:47:55 +02:00
|
|
|
typedef GSUBGPOS::accelerator_t<GPOS> accelerator_t;
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2015-08-25 21:24:59 +02:00
|
|
|
static void
|
|
|
|
reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, unsigned int new_parent)
|
|
|
|
{
|
2016-02-11 09:25:28 +01:00
|
|
|
int chain = pos[i].attach_chain(), type = pos[i].attach_type();
|
|
|
|
if (likely (!chain || 0 == (type & ATTACH_TYPE_CURSIVE)))
|
2015-08-25 21:24:59 +02:00
|
|
|
return;
|
|
|
|
|
2016-02-11 09:25:28 +01:00
|
|
|
pos[i].attach_chain() = 0;
|
2015-08-25 21:24:59 +02:00
|
|
|
|
2016-02-11 09:25:28 +01:00
|
|
|
unsigned int j = (int) i + chain;
|
2016-02-11 08:53:11 +01:00
|
|
|
|
2015-08-25 21:24:59 +02:00
|
|
|
/* Stop if we see new parent in the chain. */
|
|
|
|
if (j == new_parent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
reverse_cursive_minor_offset (pos, j, direction, new_parent);
|
|
|
|
|
|
|
|
if (HB_DIRECTION_IS_HORIZONTAL (direction))
|
|
|
|
pos[j].y_offset = -pos[i].y_offset;
|
|
|
|
else
|
|
|
|
pos[j].x_offset = -pos[i].x_offset;
|
|
|
|
|
2016-02-11 09:25:28 +01:00
|
|
|
pos[j].attach_chain() = -chain;
|
|
|
|
pos[j].attach_type() = type;
|
2015-08-25 21:24:59 +02:00
|
|
|
}
|
2011-05-25 03:04:15 +02:00
|
|
|
static void
|
2018-10-17 01:24:03 +02:00
|
|
|
propagate_attachment_offsets (hb_glyph_position_t *pos,
|
|
|
|
unsigned int len,
|
|
|
|
unsigned int i,
|
|
|
|
hb_direction_t direction)
|
2011-05-25 03:04:15 +02:00
|
|
|
{
|
2016-02-11 10:48:13 +01:00
|
|
|
/* Adjusts offsets of attached glyphs (both cursive and mark) to accumulate
|
|
|
|
* offset of glyph they are attached to. */
|
2016-02-11 09:25:28 +01:00
|
|
|
int chain = pos[i].attach_chain(), type = pos[i].attach_type();
|
2016-02-11 10:48:13 +01:00
|
|
|
if (likely (!chain))
|
2012-08-23 15:33:30 +02:00
|
|
|
return;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2018-10-17 01:24:03 +02:00
|
|
|
pos[i].attach_chain() = 0;
|
|
|
|
|
2016-02-11 09:25:28 +01:00
|
|
|
unsigned int j = (int) i + chain;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2018-10-17 01:24:03 +02:00
|
|
|
if (unlikely (j >= len))
|
|
|
|
return;
|
2016-02-11 09:25:28 +01:00
|
|
|
|
2018-10-17 01:24:03 +02:00
|
|
|
propagate_attachment_offsets (pos, len, j, direction);
|
2016-02-11 09:28:55 +01:00
|
|
|
|
2016-02-11 10:48:13 +01:00
|
|
|
assert (!!(type & ATTACH_TYPE_MARK) ^ !!(type & ATTACH_TYPE_CURSIVE));
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2016-02-11 10:48:13 +01:00
|
|
|
if (type & ATTACH_TYPE_CURSIVE)
|
|
|
|
{
|
|
|
|
if (HB_DIRECTION_IS_HORIZONTAL (direction))
|
|
|
|
pos[i].y_offset += pos[j].y_offset;
|
|
|
|
else
|
|
|
|
pos[i].x_offset += pos[j].x_offset;
|
|
|
|
}
|
|
|
|
else /*if (type & ATTACH_TYPE_MARK)*/
|
|
|
|
{
|
|
|
|
pos[i].x_offset += pos[j].x_offset;
|
|
|
|
pos[i].y_offset += pos[j].y_offset;
|
2016-02-24 07:53:40 +01:00
|
|
|
|
|
|
|
assert (j < i);
|
|
|
|
if (HB_DIRECTION_IS_FORWARD (direction))
|
|
|
|
for (unsigned int k = j; k < i; k++) {
|
|
|
|
pos[i].x_offset -= pos[k].x_advance;
|
|
|
|
pos[i].y_offset -= pos[k].y_advance;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for (unsigned int k = j + 1; k < i + 1; k++) {
|
|
|
|
pos[i].x_offset += pos[k].x_advance;
|
|
|
|
pos[i].y_offset += pos[k].y_advance;
|
|
|
|
}
|
2016-02-11 10:48:13 +01:00
|
|
|
}
|
2011-05-25 03:04:15 +02:00
|
|
|
}
|
|
|
|
|
2011-07-28 21:42:18 +02:00
|
|
|
void
|
2012-07-31 01:30:01 +02:00
|
|
|
GPOS::position_start (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
|
2011-07-28 21:42:18 +02:00
|
|
|
{
|
2011-07-28 22:48:43 +02:00
|
|
|
unsigned int count = buffer->len;
|
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2016-02-11 09:25:28 +01:00
|
|
|
buffer->pos[i].attach_chain() = buffer->pos[i].attach_type() = 0;
|
2011-07-28 21:42:18 +02:00
|
|
|
}
|
|
|
|
|
2010-10-28 04:48:31 +02:00
|
|
|
void
|
2018-10-27 06:01:11 +02:00
|
|
|
GPOS::position_finish_advances (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSED)
|
2016-02-11 10:34:28 +01:00
|
|
|
{
|
|
|
|
//_hb_buffer_assert_gsubgpos_vars (buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
|
2010-10-28 04:48:31 +02:00
|
|
|
{
|
2014-08-02 23:18:46 +02:00
|
|
|
_hb_buffer_assert_gsubgpos_vars (buffer);
|
|
|
|
|
2011-04-16 00:32:36 +02:00
|
|
|
unsigned int len;
|
|
|
|
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
|
2010-10-28 04:48:31 +02:00
|
|
|
hb_direction_t direction = buffer->props.direction;
|
|
|
|
|
|
|
|
/* Handle attachments */
|
2015-11-05 07:58:58 +01:00
|
|
|
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT)
|
|
|
|
for (unsigned int i = 0; i < len; i++)
|
2018-10-17 01:24:03 +02:00
|
|
|
propagate_attachment_offsets (pos, len, i, direction);
|
2010-10-28 04:48:31 +02:00
|
|
|
}
|
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2018-11-06 05:19:04 +01:00
|
|
|
struct GPOS_accelerator_t : GPOS::accelerator_t {};
|
|
|
|
|
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
/* Out-of-class implementation for methods recursing */
|
|
|
|
|
2019-06-26 22:44:10 +02:00
|
|
|
#ifndef HB_NO_OT_LAYOUT
|
2012-11-24 00:04:08 +01:00
|
|
|
template <typename context_t>
|
2019-12-10 20:21:26 +01:00
|
|
|
/*static*/ typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
|
2012-11-24 00:04:08 +01:00
|
|
|
{
|
2018-11-06 05:19:04 +01:00
|
|
|
const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (lookup_index);
|
2013-03-09 07:55:04 +01:00
|
|
|
return l.dispatch (c);
|
2012-11-24 00:04:08 +01:00
|
|
|
}
|
2019-10-23 01:00:43 +02:00
|
|
|
|
|
|
|
/*static*/ inline hb_closure_lookups_context_t::return_t PosLookup::dispatch_closure_lookups_recurse_func (hb_closure_lookups_context_t *c, unsigned this_index)
|
|
|
|
{
|
|
|
|
const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (this_index);
|
|
|
|
return l.closure_lookups (c, this_index);
|
|
|
|
}
|
|
|
|
|
2019-12-10 20:31:50 +01:00
|
|
|
/*static*/ bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2018-11-06 05:19:04 +01:00
|
|
|
const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (lookup_index);
|
2012-11-24 07:13:20 +01:00
|
|
|
unsigned int saved_lookup_props = c->lookup_props;
|
2015-08-18 15:36:43 +02:00
|
|
|
unsigned int saved_lookup_index = c->lookup_index;
|
|
|
|
c->set_lookup_index (lookup_index);
|
|
|
|
c->set_lookup_props (l.get_props ());
|
2015-02-19 08:40:23 +01:00
|
|
|
bool ret = l.dispatch (c);
|
2015-08-18 15:36:43 +02:00
|
|
|
c->set_lookup_index (saved_lookup_index);
|
2015-01-29 08:01:12 +01:00
|
|
|
c->set_lookup_props (saved_lookup_props);
|
2012-11-24 07:13:20 +01:00
|
|
|
return ret;
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
2019-06-26 22:44:10 +02:00
|
|
|
#endif
|
2009-05-18 23:09:33 +02:00
|
|
|
|
|
|
|
|
2012-11-17 03:49:54 +01:00
|
|
|
} /* namespace OT */
|
2012-08-28 23:57:49 +02:00
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
2011-08-17 14:19:59 +02:00
|
|
|
#endif /* HB_OT_LAYOUT_GPOS_TABLE_HH */
|