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
|
|
|
|
2009-08-03 02:03:12 +02:00
|
|
|
#include "hb-ot-layout-gsubgpos-private.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 {
|
|
|
|
|
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
|
|
|
|
2010-05-11 01:01:17 +02:00
|
|
|
typedef Value ValueRecord[VAR];
|
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
|
2018-01-10 03:07:30 +01:00
|
|
|
HBINT16 xPlacement; /* Horizontal adjustment for
|
2009-05-21 10:49:04 +02:00
|
|
|
* placement--in design units */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBINT16 yPlacement; /* Vertical adjustment for
|
2009-05-21 10:49:04 +02:00
|
|
|
* placement--in design units */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBINT16 xAdvance; /* Horizontal adjustment for
|
2009-05-21 10:49:04 +02:00
|
|
|
* advance--in design units (only used
|
|
|
|
* for horizontal writing) */
|
2018-01-10 03:07:30 +01:00
|
|
|
HBINT16 yAdvance; /* Vertical adjustment for advance--in
|
2009-05-21 10:49:04 +02:00
|
|
|
* design units (only used for vertical
|
|
|
|
* writing) */
|
|
|
|
Offset xPlaDevice; /* Offset to Device table for
|
|
|
|
* horizontal placement--measured from
|
|
|
|
* beginning of PosTable (may be NULL) */
|
|
|
|
Offset yPlaDevice; /* Offset to Device table for vertical
|
|
|
|
* placement--measured from beginning
|
|
|
|
* of PosTable (may be NULL) */
|
|
|
|
Offset xAdvDevice; /* Offset to Device table for
|
|
|
|
* horizontal advance--measured from
|
|
|
|
* beginning of PosTable (may be NULL) */
|
|
|
|
Offset yAdvDevice; /* Offset to Device table for vertical
|
|
|
|
* advance--measured from beginning of
|
|
|
|
* PosTable (may be NULL) */
|
|
|
|
#endif
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2010-10-02 00:58:50 +02:00
|
|
|
inline unsigned int get_len (void) const
|
2018-02-17 01:06:17 +01:00
|
|
|
{ return _hb_popcount ((unsigned int) *this); }
|
2010-10-02 00:58:50 +02:00
|
|
|
inline unsigned int get_size (void) const
|
2010-05-07 01:33:31 +02:00
|
|
|
{ return get_len () * Value::static_size; }
|
2010-04-21 08:02:57 +02:00
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
void apply_value (hb_ot_apply_context_t *c,
|
2011-05-11 06:02:02 +02:00
|
|
|
const void *base,
|
|
|
|
const Value *values,
|
|
|
|
hb_glyph_position_t &glyph_pos) const
|
2010-04-21 08:02:57 +02:00
|
|
|
{
|
|
|
|
unsigned int format = *this;
|
|
|
|
if (!format) return;
|
|
|
|
|
2016-09-10 02:03:11 +02:00
|
|
|
hb_font_t *font = c->font;
|
|
|
|
hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction);
|
|
|
|
|
2011-05-11 06:04:15 +02:00
|
|
|
if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++));
|
|
|
|
if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++));
|
2011-05-20 21:59:59 +02:00
|
|
|
if (format & xAdvance) {
|
2014-01-22 19:31:30 +01:00
|
|
|
if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_short (values));
|
|
|
|
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) {
|
2014-01-22 19:31:30 +01:00
|
|
|
if (unlikely (!horizontal)) glyph_pos.y_advance -= font->em_scale_y (get_short (values));
|
|
|
|
values++;
|
2011-05-20 21:59:59 +02:00
|
|
|
}
|
2009-05-19 01:47:52 +02:00
|
|
|
|
2010-04-29 20:31:56 +02:00
|
|
|
if (!has_device ()) return;
|
|
|
|
|
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
|
|
|
|
2016-03-01 11:29:36 +01:00
|
|
|
if (!use_x_device && !use_y_device) return;
|
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) {
|
2016-09-10 02:03:11 +02:00
|
|
|
if (use_x_device) glyph_pos.x_offset += (base + get_device (values)).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) {
|
2016-09-10 02:03:11 +02:00
|
|
|
if (use_y_device) glyph_pos.y_offset += (base + get_device (values)).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) {
|
2016-09-10 02:03:11 +02:00
|
|
|
if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).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 */
|
2016-09-10 02:03:11 +02:00
|
|
|
if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font, store);
|
2014-01-22 19:31:30 +01:00
|
|
|
values++;
|
2009-05-19 01:47:52 +02:00
|
|
|
}
|
|
|
|
}
|
2010-04-21 08:02:57 +02:00
|
|
|
|
|
|
|
private:
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize_value_devices (hb_sanitize_context_t *c, const void *base, const Value *values) const
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2010-05-06 19:06:15 +02:00
|
|
|
static inline OffsetTo<Device>& get_device (Value* value)
|
|
|
|
{ return *CastP<OffsetTo<Device> > (value); }
|
|
|
|
static inline const OffsetTo<Device>& get_device (const Value* value)
|
|
|
|
{ return *CastP<OffsetTo<Device> > (value); }
|
|
|
|
|
2018-01-10 03:07:30 +01:00
|
|
|
static inline const HBINT16& get_short (const Value* value)
|
|
|
|
{ return *CastP<HBINT16> (value); }
|
2010-05-06 19:06:15 +02:00
|
|
|
|
2010-04-21 08:02:57 +02:00
|
|
|
public:
|
|
|
|
|
2010-10-02 00:58:50 +02:00
|
|
|
inline bool has_device (void) const {
|
2010-04-21 08:02:57 +02:00
|
|
|
unsigned int format = *this;
|
|
|
|
return (format & devices) != 0;
|
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize_value (hb_sanitize_context_t *c, const void *base, const Value *values) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize_values (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count) const
|
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2010-04-21 08:02:57 +02:00
|
|
|
unsigned int len = get_len ();
|
|
|
|
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!c->check_array (values, get_size (), count)) 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))
|
2015-09-29 15:57:02 +02: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. */
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count, unsigned int stride) const
|
|
|
|
{
|
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))
|
2015-09-29 15:57:02 +02: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
|
|
|
}
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct AnchorFormat1
|
|
|
|
{
|
2018-01-18 01:46:51 +01:00
|
|
|
inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
|
2018-01-10 05:13:47 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
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-01-18 01:46:51 +01:00
|
|
|
inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id,
|
2018-01-10 05:13:47 +01:00
|
|
|
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;
|
|
|
|
unsigned int x_ppem = font->x_ppem;
|
|
|
|
unsigned int y_ppem = font->y_ppem;
|
|
|
|
hb_position_t cx, cy;
|
|
|
|
hb_bool_t ret;
|
2010-04-29 09:59:06 +02:00
|
|
|
|
2016-09-10 01:27:03 +02:00
|
|
|
ret = (x_ppem || y_ppem) &&
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
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-01-18 01:46:51 +01:00
|
|
|
inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
|
2018-01-10 05:13:47 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
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 */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Device>
|
|
|
|
xDeviceTable; /* Offset to Device table for X
|
|
|
|
* coordinate-- from beginning of
|
|
|
|
* Anchor table (may be NULL) */
|
|
|
|
OffsetTo<Device>
|
|
|
|
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-01-18 01:46:51 +01:00
|
|
|
inline void get_anchor (hb_ot_apply_context_t *c, hb_codepoint_t glyph_id,
|
2018-01-10 05:13:47 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2013-01-08 23:15:46 +01:00
|
|
|
inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols, bool *found) const {
|
|
|
|
*found = false;
|
2010-05-04 04:51:19 +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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const
|
|
|
|
{
|
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);
|
2016-09-10 00:40:15 +02:00
|
|
|
if (unlikely (_hb_unsigned_int_mul_overflows (rows, cols))) return_trace (false);
|
2009-08-15 00:14:03 +02:00
|
|
|
unsigned int count = rows * cols;
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!c->check_array (matrixZ, matrixZ[0].static_size, 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 */
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-08-15 00:14:03 +02:00
|
|
|
OffsetTo<Anchor>
|
2014-12-13 06:07:53 +01:00
|
|
|
matrixZ[VAR]; /* 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
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
HBUINT16 klass; /* Class defined for this mark */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Anchor>
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2010-05-10 23:28:16 +02:00
|
|
|
struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage order */
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2018-01-18 01:46:51 +01:00
|
|
|
inline bool apply (hb_ot_apply_context_t *c,
|
2009-08-15 01:33:24 +02:00
|
|
|
unsigned int mark_index, unsigned int glyph_index,
|
|
|
|
const AnchorMatrix &anchors, unsigned int class_count,
|
|
|
|
unsigned int glyph_pos) const
|
|
|
|
{
|
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;
|
2010-05-10 23:28:16 +02:00
|
|
|
const MarkRecord &record = ArrayOf<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();
|
2018-01-10 05:13:47 +01:00
|
|
|
o.x_offset = round (base_x - mark_x);
|
|
|
|
o.y_offset = round (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
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (ArrayOf<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
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:18:07 +01:00
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+coverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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 */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
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
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:18:07 +01:00
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+coverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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 */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
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
|
|
|
|
{
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c) 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) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1));
|
|
|
|
case 2: return_trace (c->dispatch (u.format2));
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
GlyphID secondGlyph; /* GlyphID of second glyph in the
|
|
|
|
* 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;
|
|
|
|
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c,
|
|
|
|
const ValueFormat *valueFormats) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
|
|
|
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
|
|
|
|
2014-12-13 06:07:53 +01:00
|
|
|
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
|
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
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline bool apply (hb_ot_apply_context_t *c,
|
2010-05-11 06:23:50 +02:00
|
|
|
const ValueFormat *valueFormats,
|
|
|
|
unsigned int pos) const
|
|
|
|
{
|
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;
|
2010-05-11 06:23:50 +02: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
|
|
|
|
2015-01-20 02:00:31 +01:00
|
|
|
const PairValueRecord *record_array = CastP<PairValueRecord> (arrayZ);
|
2012-11-24 07:38:41 +01:00
|
|
|
unsigned int count = len;
|
2015-01-20 02:00:31 +01:00
|
|
|
|
|
|
|
/* Hand-coded bsearch. */
|
|
|
|
if (unlikely (!count))
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (false);
|
2015-01-20 02:00:31 +01:00
|
|
|
hb_codepoint_t x = buffer->info[pos].codepoint;
|
|
|
|
int min = 0, max = (int) count - 1;
|
|
|
|
while (min <= max)
|
2010-05-11 06:23:50 +02:00
|
|
|
{
|
2015-01-20 02:00:31 +01:00
|
|
|
int mid = (min + max) / 2;
|
|
|
|
const PairValueRecord *record = &StructAtOffset<PairValueRecord> (record_array, record_size * mid);
|
|
|
|
hb_codepoint_t mid_x = record->secondGlyph;
|
|
|
|
if (x < mid_x)
|
|
|
|
max = mid - 1;
|
|
|
|
else if (x > mid_x)
|
|
|
|
min = mid + 1;
|
|
|
|
else
|
2010-05-11 06:23:50 +02:00
|
|
|
{
|
2017-08-11 05:19:15 +02:00
|
|
|
buffer->unsafe_to_break (buffer->idx, pos + 1);
|
2016-09-10 02:03:11 +02:00
|
|
|
valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos());
|
|
|
|
valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]);
|
2010-05-11 06:23:50 +02:00
|
|
|
if (len2)
|
|
|
|
pos++;
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx = pos;
|
2015-09-29 15:57:02 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
struct sanitize_closure_t {
|
2015-02-17 15:27:44 +01:00
|
|
|
const void *base;
|
|
|
|
const ValueFormat *valueFormats;
|
2010-05-11 06:23:50 +02:00
|
|
|
unsigned int len1; /* valueFormats[0].get_len() */
|
|
|
|
unsigned int stride; /* 1 + len1 + len2 */
|
|
|
|
};
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) const
|
|
|
|
{
|
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-01-10 03:07:30 +01:00
|
|
|
&& c->check_array (arrayZ, HBUINT16::static_size * closure->stride, len))) return_trace (false);
|
2010-05-11 06:23:50 +02:00
|
|
|
|
|
|
|
unsigned int count = len;
|
2015-02-17 15:27:44 +01:00
|
|
|
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride) &&
|
|
|
|
closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &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-01-10 03:07:30 +01:00
|
|
|
HBUINT16 len; /* Number of PairValueRecords */
|
|
|
|
HBUINT16 arrayZ[VAR]; /* Array of PairValueRecords--ordered
|
2009-05-20 04:16:04 +02:00
|
|
|
* by GlyphID of the second glyph */
|
2010-05-10 22:38:32 +02:00
|
|
|
public:
|
2014-12-13 06:07:53 +01:00
|
|
|
DEFINE_SIZE_ARRAY (2, arrayZ);
|
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
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:12:06 +01:00
|
|
|
if (unlikely (!(this+coverage).add_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
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+coverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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);
|
|
|
|
|
2016-12-14 18:56:17 +01:00
|
|
|
unsigned int len1 = valueFormat[0].get_len ();
|
|
|
|
unsigned int len2 = valueFormat[1].get_len ();
|
2010-05-11 06:23:50 +02:00
|
|
|
PairSet::sanitize_closure_t closure = {
|
|
|
|
this,
|
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 */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
2016-12-14 18:56:17 +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) */
|
2016-12-14 18:56:17 +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) */
|
|
|
|
OffsetArrayOf<PairSet>
|
|
|
|
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
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:12:06 +01:00
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
2017-12-16 17:07:37 +01:00
|
|
|
if (unlikely (!(this+classDef2).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+coverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
|
2017-08-11 05:19:15 +02:00
|
|
|
buffer->unsafe_to_break (buffer->idx, skippy_iter.idx + 1);
|
2010-03-16 08:46:17 +01:00
|
|
|
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
|
2016-09-10 02:03:11 +02:00
|
|
|
valueFormat1.apply_value (c, this, v, buffer->cur_pos());
|
|
|
|
valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]);
|
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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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;
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (c->check_array (values, record_size, count) &&
|
|
|
|
valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
|
|
|
|
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 */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
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) */
|
|
|
|
OffsetTo<ClassDef>
|
|
|
|
classDef1; /* Offset to ClassDef table--from
|
|
|
|
* beginning of PairPos subtable--for
|
|
|
|
* the first glyph of the pair */
|
|
|
|
OffsetTo<ClassDef>
|
|
|
|
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
|
|
|
|
{
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c) 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) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1));
|
|
|
|
case 2: return_trace (c->dispatch (u.format2));
|
|
|
|
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;
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
protected:
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Anchor>
|
|
|
|
entryAnchor; /* Offset to EntryAnchor table--from
|
|
|
|
* beginning of CursivePos
|
|
|
|
* subtable--may be NULL */
|
|
|
|
OffsetTo<Anchor>
|
|
|
|
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
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:12:06 +01:00
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+coverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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)];
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!this_record.exitAnchor) 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);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!skippy_iter.next ()) return_trace (false);
|
2010-10-27 17:54:26 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
const EntryExitRecord &next_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)];
|
2015-09-29 15:57:02 +02:00
|
|
|
if (!next_record.entryAnchor) return_trace (false);
|
2009-05-20 05:25:41 +02:00
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
unsigned int i = buffer->idx;
|
2012-01-17 04:05:08 +01:00
|
|
|
unsigned int j = skippy_iter.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;
|
2016-09-10 01:27:03 +02:00
|
|
|
(this+this_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
|
|
|
|
(this+next_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:
|
2018-01-10 05:13:47 +01:00
|
|
|
pos[i].x_advance = round (exit_x) + pos[i].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2018-01-10 05:13:47 +01:00
|
|
|
d = round (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:
|
2018-01-10 05:13:47 +01:00
|
|
|
d = round (exit_x) + pos[i].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
pos[i].x_advance -= d;
|
|
|
|
pos[i].x_offset -= d;
|
|
|
|
|
2018-01-10 05:13:47 +01:00
|
|
|
pos[j].x_advance = round (entry_x) + pos[j].x_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
break;
|
|
|
|
case HB_DIRECTION_TTB:
|
2018-01-10 05:13:47 +01:00
|
|
|
pos[i].y_advance = round (exit_y) + pos[i].y_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2018-01-10 05:13:47 +01:00
|
|
|
d = round (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:
|
2018-01-10 05:13:47 +01:00
|
|
|
d = round (exit_y) + pos[i].y_offset;
|
2011-05-25 03:04:15 +02:00
|
|
|
pos[i].y_advance -= d;
|
|
|
|
pos[i].y_offset -= d;
|
|
|
|
|
2018-01-10 05:13:47 +01:00
|
|
|
pos[j].y_advance = round (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
|
|
|
|
* Arabinc. */
|
|
|
|
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;
|
|
|
|
|
2013-10-18 19:33:09 +02:00
|
|
|
buffer->idx = j;
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (true);
|
2009-05-18 23:09:33 +02:00
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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 */
|
2009-05-18 23:09:33 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
coverage; /* Offset to Coverage table--from
|
|
|
|
* beginning of subtable */
|
|
|
|
ArrayOf<EntryExitRecord>
|
|
|
|
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
|
|
|
|
{
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c) 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) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1));
|
|
|
|
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
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkBasePosFormat1
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:12:06 +01:00
|
|
|
if (unlikely (!(this+markCoverage).add_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+baseCoverage).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+markCoverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
|
* Reject others. */
|
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 ||
|
|
|
|
_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 ();
|
|
|
|
} while (1);
|
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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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 */
|
2009-05-21 10:47:05 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
markCoverage; /* Offset to MarkCoverage table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkBasePos subtable */
|
2009-05-21 10:47:05 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
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 */
|
2009-05-21 10:47:05 +02:00
|
|
|
OffsetTo<MarkArray>
|
|
|
|
markArray; /* Offset to MarkArray table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkBasePos subtable */
|
2009-05-21 10:47:05 +02:00
|
|
|
OffsetTo<BaseArray>
|
|
|
|
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
|
|
|
|
{
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c) 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) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1));
|
|
|
|
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
|
|
|
|
2009-08-15 00:32:56 +02:00
|
|
|
typedef OffsetListOf<LigatureAttach> LigatureArray;
|
2009-05-23 00:29:45 +02:00
|
|
|
/* Array of LigatureAttach
|
2009-05-18 23:09:33 +02:00
|
|
|
* tables ordered by
|
|
|
|
* LigatureCoverage Index */
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkLigPosFormat1
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:12:06 +01:00
|
|
|
if (unlikely (!(this+markCoverage).add_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+ligatureCoverage).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+markCoverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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)
|
2013-10-18 19:33:09 +02:00
|
|
|
comp_index = 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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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 */
|
2009-05-23 00:29:45 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
markCoverage; /* Offset to Mark Coverage table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkLigPos subtable */
|
2009-05-23 00:29:45 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
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 */
|
2009-05-23 00:29:45 +02:00
|
|
|
OffsetTo<MarkArray>
|
|
|
|
markArray; /* Offset to MarkArray table--from
|
2009-05-18 23:09:33 +02:00
|
|
|
* beginning of MarkLigPos subtable */
|
2009-05-23 00:29:45 +02:00
|
|
|
OffsetTo<LigatureArray>
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct MarkLigPos
|
|
|
|
{
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c) 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) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1));
|
|
|
|
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
|
|
|
|
{
|
2012-11-24 07:38:41 +01:00
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2017-12-16 15:12:06 +01:00
|
|
|
if (unlikely (!(this+mark1Coverage).add_coverage (c->input))) return;
|
|
|
|
if (unlikely (!(this+mark2Coverage).add_coverage (c->input))) return;
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-07-28 23:31:01 +02:00
|
|
|
inline const Coverage &get_coverage (void) const
|
|
|
|
{
|
|
|
|
return this+mark1Coverage;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
|
|
|
|
if (likely (id1 == id2)) {
|
|
|
|
if (id1 == 0) /* Marks belonging to the same base. */
|
|
|
|
goto good;
|
|
|
|
else if (comp1 == comp2) /* Marks belonging to the same ligature component. */
|
|
|
|
goto good;
|
|
|
|
} else {
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
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 */
|
2009-05-21 14:27:07 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
mark1Coverage; /* Offset to Combining Mark1 Coverage
|
2009-05-18 23:09:33 +02:00
|
|
|
* table--from beginning of MarkMarkPos
|
|
|
|
* subtable */
|
2009-05-21 14:27:07 +02:00
|
|
|
OffsetTo<Coverage>
|
|
|
|
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 */
|
2009-05-21 14:27:07 +02:00
|
|
|
OffsetTo<MarkArray>
|
|
|
|
mark1Array; /* Offset to Mark1Array table--from
|
|
|
|
* beginning of MarkMarkPos subtable */
|
|
|
|
OffsetTo<Mark2Array>
|
|
|
|
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
|
|
|
|
{
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c) 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) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case 1: return_trace (c->dispatch (u.format1));
|
|
|
|
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
|
|
|
{
|
2012-11-23 23:04:55 +01:00
|
|
|
typedef struct PosLookupSubTable LookupSubTable;
|
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
|
|
|
|
{
|
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
|
|
|
};
|
|
|
|
|
2012-11-22 20:38:10 +01:00
|
|
|
template <typename context_t>
|
2013-03-09 07:55:04 +01:00
|
|
|
inline typename context_t::return_t dispatch (context_t *c, unsigned int lookup_type) const
|
2012-06-09 09:02:36 +02:00
|
|
|
{
|
2014-12-13 05:36:49 +01:00
|
|
|
TRACE_DISPATCH (this, lookup_type);
|
2015-10-09 18:25:55 +02:00
|
|
|
if (unlikely (!c->may_dispatch (this, &u.sub_format))) return_trace (c->no_dispatch_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
switch (lookup_type) {
|
2015-09-29 15:57:02 +02:00
|
|
|
case Single: return_trace (u.single.dispatch (c));
|
|
|
|
case Pair: return_trace (u.pair.dispatch (c));
|
|
|
|
case Cursive: return_trace (u.cursive.dispatch (c));
|
|
|
|
case MarkBase: return_trace (u.markBase.dispatch (c));
|
|
|
|
case MarkLig: return_trace (u.markLig.dispatch (c));
|
|
|
|
case MarkMark: return_trace (u.markMark.dispatch (c));
|
|
|
|
case Context: return_trace (u.context.dispatch (c));
|
|
|
|
case ChainContext: return_trace (u.chainContext.dispatch (c));
|
|
|
|
case Extension: return_trace (u.extension.dispatch (c));
|
|
|
|
default: return_trace (c->default_return_value ());
|
2012-07-28 23:31:01 +02:00
|
|
|
}
|
2012-06-09 09:02:36 +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 sub_format;
|
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:
|
2015-02-17 14:05:30 +01:00
|
|
|
DEFINE_SIZE_UNION (2, sub_format);
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
struct PosLookup : Lookup
|
|
|
|
{
|
2012-07-12 00:01:27 +02:00
|
|
|
inline const PosLookupSubTable& get_subtable (unsigned int i) const
|
2015-02-18 11:09:54 +01:00
|
|
|
{ return Lookup::get_subtable<PosLookupSubTable> (i); }
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2013-05-03 23:34:29 +02:00
|
|
|
inline bool is_reverse (void) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
inline 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
|
|
|
}
|
|
|
|
|
2013-05-03 23:33:16 +02:00
|
|
|
inline hb_collect_glyphs_context_t::return_t collect_glyphs (hb_collect_glyphs_context_t *c) const
|
2012-11-24 07:38:41 +01:00
|
|
|
{
|
|
|
|
TRACE_COLLECT_GLYPHS (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (dispatch (c));
|
2012-11-24 07:38:41 +01:00
|
|
|
}
|
|
|
|
|
2012-08-02 03:18:54 +02:00
|
|
|
template <typename set_t>
|
|
|
|
inline void add_coverage (set_t *glyphs) const
|
|
|
|
{
|
2015-02-17 17:15:34 +01:00
|
|
|
hb_add_coverage_context_t<set_t> c (glyphs);
|
|
|
|
dispatch (&c);
|
2012-08-02 03:18:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
static 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>
|
|
|
|
static inline typename context_t::return_t dispatch_recurse_func (context_t *c, unsigned int lookup_index);
|
|
|
|
|
|
|
|
template <typename context_t>
|
|
|
|
inline typename context_t::return_t dispatch (context_t *c) const
|
2015-02-18 11:18:46 +01:00
|
|
|
{ return Lookup::dispatch<PosLookupSubTable> (c); }
|
2013-03-09 07:59:30 +01:00
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (unlikely (!Lookup::sanitize (c))) return_trace (false);
|
|
|
|
return_trace (dispatch (c));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
2009-05-18 23:09:33 +02:00
|
|
|
};
|
|
|
|
|
2009-08-04 19:30:49 +02:00
|
|
|
typedef OffsetListOf<PosLookup> PosLookupList;
|
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
|
|
|
|
{
|
2013-09-09 21:43:10 +02:00
|
|
|
static const hb_tag_t tableTag = HB_OT_TAG_GPOS;
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2009-05-20 05:42:30 +02:00
|
|
|
inline const PosLookup& get_lookup (unsigned int i) const
|
2010-04-23 22:35:01 +02:00
|
|
|
{ return CastR<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
|
|
|
|
2015-02-17 15:27:44 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
TRACE_SANITIZE (this);
|
2015-09-29 15:57:02 +02:00
|
|
|
if (unlikely (!GSUBGPOS::sanitize (c))) return_trace (false);
|
2015-02-17 15:27:44 +01:00
|
|
|
const OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
|
2015-09-29 15:57:02 +02:00
|
|
|
return_trace (list.sanitize (c, this));
|
2009-08-04 19:30:49 +02:00
|
|
|
}
|
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
|
2016-02-11 10:48:13 +01:00
|
|
|
propagate_attachment_offsets (hb_glyph_position_t *pos, 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
|
|
|
|
2016-02-11 09:25:28 +01:00
|
|
|
unsigned int j = (int) i + chain;
|
2011-05-25 03:04:15 +02:00
|
|
|
|
2016-02-11 10:48:13 +01:00
|
|
|
pos[i].attach_chain() = 0;
|
2016-02-11 09:25:28 +01:00
|
|
|
|
2016-02-11 10:48:13 +01:00
|
|
|
propagate_attachment_offsets (pos, 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
|
2016-02-11 10:34:28 +01:00
|
|
|
GPOS::position_finish_advances (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
|
|
|
|
{
|
|
|
|
//_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++)
|
2016-02-11 10:48:13 +01:00
|
|
|
propagate_attachment_offsets (pos, i, direction);
|
2010-10-28 04:48:31 +02:00
|
|
|
}
|
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
|
|
|
|
/* Out-of-class implementation for methods recursing */
|
|
|
|
|
2012-11-24 00:04:08 +01:00
|
|
|
template <typename context_t>
|
2014-04-28 23:29:39 +02:00
|
|
|
/*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index)
|
2012-11-24 00:04:08 +01:00
|
|
|
{
|
|
|
|
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
|
|
|
|
const PosLookup &l = gpos.get_lookup (lookup_index);
|
2013-03-09 07:55:04 +01:00
|
|
|
return l.dispatch (c);
|
2012-11-24 00:04:08 +01:00
|
|
|
}
|
|
|
|
|
2018-01-18 01:46:51 +01:00
|
|
|
/*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
|
2009-05-20 05:42:30 +02:00
|
|
|
{
|
2012-07-27 08:12:28 +02:00
|
|
|
const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos);
|
2009-05-18 23:09:33 +02:00
|
|
|
const PosLookup &l = gpos.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
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-11 08:49:10 +01:00
|
|
|
#undef attach_chain
|
2016-02-11 09:25:28 +01:00
|
|
|
#undef attach_type
|
2010-10-28 05:09:10 +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 */
|