提交 cdd756b9 编写于 作者: B Behdad Esfahbod

[OTLayout] Implement GPOS collect_glyphs()

上级 4c4e8f0e
...@@ -419,6 +419,12 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde ...@@ -419,6 +419,12 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
struct SinglePosFormat1 struct SinglePosFormat1
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (&c->input);
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+coverage; return this+coverage;
...@@ -458,6 +464,12 @@ struct SinglePosFormat1 ...@@ -458,6 +464,12 @@ struct SinglePosFormat1
struct SinglePosFormat2 struct SinglePosFormat2
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (&c->input);
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+coverage; return this+coverage;
...@@ -548,6 +560,23 @@ struct PairSet ...@@ -548,6 +560,23 @@ struct PairSet
{ {
friend struct PairPosFormat1; friend struct PairPosFormat1;
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 ();
unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
const PairValueRecord *record = CastP<PairValueRecord> (array);
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
{
c->input.add (record->secondGlyph);
record = &StructAtOffset<PairValueRecord> (record, record_size);
}
}
inline bool apply (hb_apply_context_t *c, inline bool apply (hb_apply_context_t *c,
const ValueFormat *valueFormats, const ValueFormat *valueFormats,
unsigned int pos) const unsigned int pos) const
...@@ -557,8 +586,8 @@ struct PairSet ...@@ -557,8 +586,8 @@ struct PairSet
unsigned int len2 = valueFormats[1].get_len (); unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = USHORT::static_size * (1 + len1 + len2); unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
unsigned int count = len;
const PairValueRecord *record = CastP<PairValueRecord> (array); const PairValueRecord *record = CastP<PairValueRecord> (array);
unsigned int count = len;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (c->buffer->info[pos].codepoint == record->secondGlyph) if (c->buffer->info[pos].codepoint == record->secondGlyph)
...@@ -606,6 +635,15 @@ struct PairSet ...@@ -606,6 +635,15 @@ struct PairSet
struct PairPosFormat1 struct PairPosFormat1
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (&c->input);
unsigned int count = pairSet.len;
for (unsigned int i = 0; i < count; i++)
(this+pairSet[i]).collect_glyphs (c, &valueFormat1);
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+coverage; return this+coverage;
...@@ -660,6 +698,24 @@ struct PairPosFormat1 ...@@ -660,6 +698,24 @@ struct PairPosFormat1
struct PairPosFormat2 struct PairPosFormat2
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
/* (this+coverage).add_coverage (&c->input); // Don't need this. */
/* TODO only add values for pairs that have nonzero adjustments. */
unsigned int count1 = class1Count;
const ClassDef &klass1 = this+classDef1;
for (unsigned int i = 0; i < count1; i++)
klass1.add_class (&c->input, i);
unsigned int count2 = class2Count;
const ClassDef &klass2 = this+classDef2;
for (unsigned int i = 0; i < count2; i++)
klass2.add_class (&c->input, i);
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+coverage; return this+coverage;
...@@ -800,6 +856,12 @@ struct EntryExitRecord ...@@ -800,6 +856,12 @@ struct EntryExitRecord
struct CursivePosFormat1 struct CursivePosFormat1
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (&c->input);
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+coverage; return this+coverage;
...@@ -940,6 +1002,14 @@ typedef AnchorMatrix BaseArray; /* base-major-- ...@@ -940,6 +1002,14 @@ typedef AnchorMatrix BaseArray; /* base-major--
struct MarkBasePosFormat1 struct MarkBasePosFormat1
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+markCoverage).add_coverage (&c->input);
(this+baseCoverage).add_coverage (&c->input);
/* TODO only add combinations that have nonzero adjustment. */
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+markCoverage; return this+markCoverage;
...@@ -1036,6 +1106,14 @@ typedef OffsetListOf<LigatureAttach> LigatureArray; ...@@ -1036,6 +1106,14 @@ typedef OffsetListOf<LigatureAttach> LigatureArray;
struct MarkLigPosFormat1 struct MarkLigPosFormat1
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+markCoverage).add_coverage (&c->input);
(this+ligatureCoverage).add_coverage (&c->input);
/* TODO only add combinations that have nonzero adjustment. */
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+markCoverage; return this+markCoverage;
...@@ -1144,6 +1222,14 @@ typedef AnchorMatrix Mark2Array; /* mark2-major-- ...@@ -1144,6 +1222,14 @@ typedef AnchorMatrix Mark2Array; /* mark2-major--
struct MarkMarkPosFormat1 struct MarkMarkPosFormat1
{ {
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
(this+mark1Coverage).add_coverage (&c->input);
(this+mark2Coverage).add_coverage (&c->input);
/* TODO only add combinations that have nonzero adjustment. */
}
inline const Coverage &get_coverage (void) const inline const Coverage &get_coverage (void) const
{ {
return this+mark1Coverage; return this+mark1Coverage;
...@@ -1357,6 +1443,13 @@ struct PosLookup : Lookup ...@@ -1357,6 +1443,13 @@ struct PosLookup : Lookup
template <typename context_t> template <typename context_t>
static inline typename context_t::return_t process_recurse_func (context_t *c, unsigned int lookup_index); static inline typename context_t::return_t process_recurse_func (context_t *c, unsigned int lookup_index);
inline hb_collect_glyphs_context_t::return_t collect_glyphs_lookup (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
c->set_recurse_func (process_recurse_func<hb_collect_glyphs_context_t>);
return TRACE_RETURN (process (c));
}
template <typename set_t> template <typename set_t>
inline void add_coverage (set_t *glyphs) const inline void add_coverage (set_t *glyphs) const
{ {
......
...@@ -412,18 +412,19 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, ...@@ -412,18 +412,19 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
{ {
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return; if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return;
// OT::hb_collect_glyphs_context_t c (face, glyphs_before, glyphs_input, glyphs_after, glyphs_output); OT::hb_collect_glyphs_context_t c (face, glyphs_before, glyphs_input, glyphs_after, glyphs_output);
switch (table_tag) { switch (table_tag) {
case HB_OT_TAG_GSUB: case HB_OT_TAG_GSUB:
{ {
// hb_ot_layout_from_face (face)->gsub->collect_glyphs_lookup (&c, lookup_index); const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index);
l.collect_glyphs_lookup (&c);
return; return;
} }
case HB_OT_TAG_GPOS: case HB_OT_TAG_GPOS:
{ {
// hb_ot_layout_from_face (face)->gpos->collect_glyphs_lookup (&c, lookup_index); const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index);
// l.collect_glyphs_lookup (&c); l.collect_glyphs_lookup (&c);
return; return;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册