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
|
|
|
|
2022-06-25 00:01:02 +02:00
|
|
|
#include "OT/Layout/GPOS/GPOS.hh"
|
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
|
|
|
|
2010-10-28 05:09:10 +02:00
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
/* Shared Tables: ValueRecord, Anchor Table, and MarkArray */
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-25 00:01:02 +02:00
|
|
|
/* Lookups */
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2020-10-05 22:14:53 +02:00
|
|
|
|
2022-06-25 00:36:14 +02:00
|
|
|
struct MarkMarkPos
|
2009-05-20 05:42:30 +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, 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) {
|
2021-11-02 07:18:22 +01:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, std::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 */
|
2022-06-25 00:36:14 +02:00
|
|
|
MarkMarkPosFormat1 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);
|
2021-11-20 19:46:48 +01:00
|
|
|
unsigned unsafe_from;
|
|
|
|
if (!skippy_iter.prev (&unsafe_from))
|
|
|
|
{
|
2022-01-22 18:16:23 +01:00
|
|
|
buffer->unsafe_to_concat_from_outbuffer (unsafe_from, buffer->idx + 1);
|
2021-11-20 19:46:48 +01:00
|
|
|
return_trace (false);
|
|
|
|
}
|
2009-08-12 21:40:04 +02:00
|
|
|
|
2022-01-22 18:35:05 +01:00
|
|
|
if (!_hb_glyph_info_is_mark (&buffer->info[skippy_iter.idx]))
|
|
|
|
{
|
|
|
|
buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1);
|
|
|
|
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. */
|
2022-01-22 18:35:05 +01:00
|
|
|
buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1);
|
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);
|
2022-01-22 18:35:05 +01:00
|
|
|
if (mark2_index == NOT_COVERED)
|
|
|
|
{
|
|
|
|
buffer->unsafe_to_concat_from_outbuffer (skippy_iter.idx, buffer->idx + 1);
|
|
|
|
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) {
|
2021-11-02 07:18:22 +01:00
|
|
|
case 1: return_trace (c->dispatch (u.format1, std::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
|
|
|
|
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,
|
2022-06-26 03:53:11 +02:00
|
|
|
hb_direction_t direction,
|
|
|
|
unsigned nesting_level = HB_MAX_NESTING_LEVEL)
|
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
|
|
|
|
2022-06-26 03:53:11 +02:00
|
|
|
if (unlikely (!nesting_level))
|
|
|
|
return;
|
|
|
|
|
|
|
|
propagate_attachment_offsets (pos, len, j, direction, nesting_level - 1);
|
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
|
2021-12-19 15:25:37 +01:00
|
|
|
GPOS::position_finish_offsets (hb_font_t *font, 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)
|
2021-12-19 15:25:37 +01:00
|
|
|
for (unsigned i = 0; i < len; i++)
|
2018-10-17 01:24:03 +02:00
|
|
|
propagate_attachment_offsets (pos, len, i, direction);
|
2021-12-19 15:25:37 +01:00
|
|
|
|
|
|
|
if (unlikely (font->slant))
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < len; i++)
|
|
|
|
if (unlikely (pos[i].y_offset))
|
|
|
|
pos[i].x_offset += _hb_roundf (font->slant_xy * pos[i].y_offset);
|
|
|
|
}
|
2010-10-28 04:48:31 +02:00
|
|
|
}
|
|
|
|
|
2009-05-18 23:09:33 +02:00
|
|
|
|
2022-01-20 19:47:17 +01:00
|
|
|
struct GPOS_accelerator_t : GPOS::accelerator_t {
|
|
|
|
GPOS_accelerator_t (hb_face_t *face) : GPOS::accelerator_t (face) {}
|
|
|
|
};
|
2018-11-06 05:19:04 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-06-08 14:34:48 +02:00
|
|
|
template <>
|
|
|
|
inline hb_closure_lookups_context_t::return_t
|
|
|
|
PosLookup::dispatch_recurse_func<hb_closure_lookups_context_t> (hb_closure_lookups_context_t *c, unsigned this_index)
|
2019-10-23 01:00:43 +02:00
|
|
|
{
|
|
|
|
const PosLookup &l = c->face->table.GPOS.get_relaxed ()->table->get_lookup (this_index);
|
|
|
|
return l.closure_lookups (c, this_index);
|
|
|
|
}
|
|
|
|
|
2022-06-08 14:25:23 +02:00
|
|
|
template <>
|
|
|
|
inline bool PosLookup::dispatch_recurse_func<hb_ot_apply_context_t> (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 */
|