This commit is contained in:
Behdad Esfahbod 2013-10-18 19:33:09 +02:00
parent 0f3fe37fcc
commit ac8cd51191
4 changed files with 145 additions and 117 deletions

View File

@ -390,6 +390,7 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
unsigned int glyph_pos) const
{
TRACE_APPLY (this);
hb_buffer_t *buffer = c->buffer;
const MarkRecord &record = ArrayOf<MarkRecord>::operator[](mark_index);
unsigned int mark_class = record.klass;
@ -402,15 +403,15 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
hb_position_t mark_x, mark_y, base_x, base_y;
mark_anchor.get_anchor (c->font, c->buffer->cur().codepoint, &mark_x, &mark_y);
glyph_anchor.get_anchor (c->font, c->buffer->info[glyph_pos].codepoint, &base_x, &base_y);
mark_anchor.get_anchor (c->font, buffer->cur().codepoint, &mark_x, &mark_y);
glyph_anchor.get_anchor (c->font, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
hb_glyph_position_t &o = c->buffer->cur_pos();
hb_glyph_position_t &o = buffer->cur_pos();
o.x_offset = base_x - mark_x;
o.y_offset = base_y - mark_y;
o.attach_lookback() = c->buffer->idx - glyph_pos;
o.attach_lookback() = buffer->idx - glyph_pos;
c->buffer->idx++;
buffer->idx++;
return TRACE_RETURN (true);
}
@ -439,13 +440,14 @@ struct SinglePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
hb_buffer_t *buffer = c->buffer;
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
valueFormat.apply_value (c->font, c->direction, this,
values, c->buffer->cur_pos());
values, buffer->cur_pos());
c->buffer->idx++;
buffer->idx++;
return TRACE_RETURN (true);
}
@ -484,16 +486,17 @@ struct SinglePosFormat2
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
hb_buffer_t *buffer = c->buffer;
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (likely (index >= valueCount)) return TRACE_RETURN (false);
valueFormat.apply_value (c->font, c->direction, this,
&values[index * valueFormat.get_len ()],
c->buffer->cur_pos());
buffer->cur_pos());
c->buffer->idx++;
buffer->idx++;
return TRACE_RETURN (true);
}
@ -588,6 +591,7 @@ struct PairSet
unsigned int pos) const
{
TRACE_APPLY (this);
hb_buffer_t *buffer = c->buffer;
unsigned int len1 = valueFormats[0].get_len ();
unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = USHORT::static_size * (1 + len1 + len2);
@ -597,15 +601,15 @@ struct PairSet
for (unsigned int i = 0; i < count; i++)
{
/* TODO bsearch */
if (c->buffer->info[pos].codepoint == record->secondGlyph)
if (buffer->info[pos].codepoint == record->secondGlyph)
{
valueFormats[0].apply_value (c->font, c->direction, this,
&record->values[0], c->buffer->cur_pos());
&record->values[0], buffer->cur_pos());
valueFormats[1].apply_value (c->font, c->direction, this,
&record->values[len1], c->buffer->pos[pos]);
&record->values[len1], buffer->pos[pos]);
if (len2)
pos++;
c->buffer->idx = pos;
buffer->idx = pos;
return TRACE_RETURN (true);
}
record = &StructAtOffset<PairValueRecord> (record, record_size);
@ -659,10 +663,11 @@ struct PairPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
hb_buffer_t *buffer = c->buffer;
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@ -729,10 +734,11 @@ struct PairPosFormat2
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
hb_buffer_t *buffer = c->buffer;
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
unsigned int index = (this+coverage).get_coverage (c->buffer->cur().codepoint);
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@ -741,19 +747,19 @@ struct PairPosFormat2
unsigned int len2 = valueFormat2.get_len ();
unsigned int record_len = len1 + len2;
unsigned int klass1 = (this+classDef1).get_class (c->buffer->cur().codepoint);
unsigned int klass2 = (this+classDef2).get_class (c->buffer->info[skippy_iter.idx].codepoint);
unsigned int klass1 = (this+classDef1).get_class (buffer->cur().codepoint);
unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return TRACE_RETURN (false);
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
valueFormat1.apply_value (c->font, c->direction, this,
v, c->buffer->cur_pos());
v, buffer->cur_pos());
valueFormat2.apply_value (c->font, c->direction, this,
v + len1, c->buffer->pos[skippy_iter.idx]);
v + len1, buffer->pos[skippy_iter.idx]);
c->buffer->idx = skippy_iter.idx;
buffer->idx = skippy_iter.idx;
if (len2)
c->buffer->idx++;
buffer->idx++;
return TRACE_RETURN (true);
}
@ -875,29 +881,30 @@ struct CursivePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_buffer_t *buffer = c->buffer;
/* We don't handle mark glyphs here. */
if (unlikely (_hb_glyph_info_is_mark (&c->buffer->cur()))) return TRACE_RETURN (false);
if (unlikely (_hb_glyph_info_is_mark (&buffer->cur()))) return TRACE_RETURN (false);
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (c->buffer->cur().codepoint)];
const EntryExitRecord &this_record = entryExitRecord[(this+coverage).get_coverage (buffer->cur().codepoint)];
if (!this_record.exitAnchor) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
const EntryExitRecord &next_record = entryExitRecord[(this+coverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint)];
const EntryExitRecord &next_record = entryExitRecord[(this+coverage).get_coverage (buffer->info[skippy_iter.idx].codepoint)];
if (!next_record.entryAnchor) return TRACE_RETURN (false);
unsigned int i = c->buffer->idx;
unsigned int i = buffer->idx;
unsigned int j = skippy_iter.idx;
hb_position_t entry_x, entry_y, exit_x, exit_y;
(this+this_record.exitAnchor).get_anchor (c->font, c->buffer->info[i].codepoint, &exit_x, &exit_y);
(this+next_record.entryAnchor).get_anchor (c->font, c->buffer->info[j].codepoint, &entry_x, &entry_y);
(this+this_record.exitAnchor).get_anchor (c->font, buffer->info[i].codepoint, &exit_x, &exit_y);
(this+next_record.entryAnchor).get_anchor (c->font, buffer->info[j].codepoint, &entry_x, &entry_y);
hb_glyph_position_t *pos = c->buffer->pos;
hb_glyph_position_t *pos = buffer->pos;
hb_position_t d;
/* Main-direction adjustment */
@ -950,7 +957,7 @@ struct CursivePosFormat1
pos[j].x_offset = exit_x - entry_x;
}
c->buffer->idx = j;
buffer->idx = j;
return TRACE_RETURN (true);
}
@ -1022,23 +1029,24 @@ struct MarkBasePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int mark_index = (this+markCoverage).get_coverage (c->buffer->cur().codepoint);
hb_buffer_t *buffer = c->buffer;
unsigned int mark_index = (this+markCoverage).get_coverage (buffer->cur().codepoint);
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, buffer->idx, 1);
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
do {
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
/* We only want to attach to the first of a MultipleSubst sequence. Reject others. */
if (0 == _hb_glyph_info_get_lig_comp (&c->buffer->info[skippy_iter.idx])) break;
if (0 == _hb_glyph_info_get_lig_comp (&buffer->info[skippy_iter.idx])) break;
skippy_iter.reject ();
} while (1);
/* Checking that matched glyph is actually a base glyph by GDEF is too strong; disabled */
if (!_hb_glyph_info_is_base_glyph (&c->buffer->info[skippy_iter.idx])) { /*return TRACE_RETURN (false);*/ }
if (!_hb_glyph_info_is_base_glyph (&buffer->info[skippy_iter.idx])) { /*return TRACE_RETURN (false);*/ }
unsigned int base_index = (this+baseCoverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint);
unsigned int base_index = (this+baseCoverage).get_coverage (buffer->info[skippy_iter.idx].codepoint);
if (base_index == NOT_COVERED) return TRACE_RETURN (false);
return TRACE_RETURN ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx));
@ -1125,19 +1133,20 @@ struct MarkLigPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int mark_index = (this+markCoverage).get_coverage (c->buffer->cur().codepoint);
hb_buffer_t *buffer = c->buffer;
unsigned int mark_index = (this+markCoverage).get_coverage (buffer->cur().codepoint);
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, buffer->idx, 1);
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
/* Checking that matched glyph is actually a ligature by GDEF is too strong; disabled */
if (!_hb_glyph_info_is_ligature (&c->buffer->info[skippy_iter.idx])) { /*return TRACE_RETURN (false);*/ }
if (!_hb_glyph_info_is_ligature (&buffer->info[skippy_iter.idx])) { /*return TRACE_RETURN (false);*/ }
unsigned int j = skippy_iter.idx;
unsigned int lig_index = (this+ligatureCoverage).get_coverage (c->buffer->info[j].codepoint);
unsigned int lig_index = (this+ligatureCoverage).get_coverage (buffer->info[j].codepoint);
if (lig_index == NOT_COVERED) return TRACE_RETURN (false);
const LigatureArray& lig_array = this+ligatureArray;
@ -1152,11 +1161,11 @@ struct MarkLigPosFormat1
* can directly use the component index. If not, we attach the mark
* glyph to the last component of the ligature. */
unsigned int comp_index;
unsigned int lig_id = _hb_glyph_info_get_lig_id (&c->buffer->info[j]);
unsigned int mark_id = _hb_glyph_info_get_lig_id (&c->buffer->cur());
unsigned int mark_comp = _hb_glyph_info_get_lig_comp (&c->buffer->cur());
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());
if (lig_id && lig_id == mark_id && mark_comp > 0)
comp_index = MIN (comp_count, _hb_glyph_info_get_lig_comp (&c->buffer->cur())) - 1;
comp_index = MIN (comp_count, _hb_glyph_info_get_lig_comp (&buffer->cur())) - 1;
else
comp_index = comp_count - 1;
@ -1240,22 +1249,23 @@ struct MarkMarkPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int mark1_index = (this+mark1Coverage).get_coverage (c->buffer->cur().codepoint);
hb_buffer_t *buffer = c->buffer;
unsigned int mark1_index = (this+mark1Coverage).get_coverage (buffer->cur().codepoint);
if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
hb_apply_context_t::skipping_backward_iterator_t skippy_iter (c, buffer->idx, 1);
skippy_iter.set_lookup_props (c->lookup_props & ~LookupFlag::IgnoreFlags);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
if (!_hb_glyph_info_is_mark (&c->buffer->info[skippy_iter.idx])) { return TRACE_RETURN (false); }
if (!_hb_glyph_info_is_mark (&buffer->info[skippy_iter.idx])) { return TRACE_RETURN (false); }
unsigned int j = skippy_iter.idx;
unsigned int id1 = _hb_glyph_info_get_lig_id (&c->buffer->cur());
unsigned int id2 = _hb_glyph_info_get_lig_id (&c->buffer->info[j]);
unsigned int comp1 = _hb_glyph_info_get_lig_comp (&c->buffer->cur());
unsigned int comp2 = _hb_glyph_info_get_lig_comp (&c->buffer->info[j]);
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]);
if (likely (id1 == id2)) {
if (id1 == 0) /* Marks belonging to the same base. */
@ -1273,7 +1283,7 @@ struct MarkMarkPosFormat1
return TRACE_RETURN (false);
good:
unsigned int mark2_index = (this+mark2Coverage).get_coverage (c->buffer->info[j].codepoint);
unsigned int mark2_index = (this+mark2Coverage).get_coverage (buffer->info[j].codepoint);
if (mark2_index == NOT_COVERED) return TRACE_RETURN (false);
return TRACE_RETURN ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j));

View File

@ -825,8 +825,9 @@ apply_string (OT::hb_apply_context_t *c,
bool ret = false;
OT::hb_is_inplace_context_t inplace_c (c->face);
bool inplace = lookup.is_inplace (&inplace_c);
hb_buffer_t *buffer = c->buffer;
if (unlikely (!c->buffer->len || !c->lookup_mask))
if (unlikely (!buffer->len || !c->lookup_mask))
return false;
c->set_lookup (lookup);
@ -835,43 +836,43 @@ apply_string (OT::hb_apply_context_t *c,
{
/* in/out forward substitution/positioning */
if (Proxy::table_index == 0)
c->buffer->clear_output ();
c->buffer->idx = 0;
buffer->clear_output ();
buffer->idx = 0;
while (c->buffer->idx < c->buffer->len)
while (buffer->idx < buffer->len)
{
if (accel.digest.may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
if (accel.digest.may_have (buffer->cur().codepoint) &&
(buffer->cur().mask & c->lookup_mask) &&
apply_once (c, lookup))
ret = true;
else
c->buffer->next_glyph ();
buffer->next_glyph ();
}
if (ret)
{
if (!inplace)
c->buffer->swap_buffers ();
buffer->swap_buffers ();
else
assert (!c->buffer->has_separate_output ());
assert (!buffer->has_separate_output ());
}
}
else
{
/* in-place backward substitution/positioning */
if (Proxy::table_index == 0)
c->buffer->remove_output ();
c->buffer->idx = c->buffer->len - 1;
buffer->remove_output ();
buffer->idx = buffer->len - 1;
do
{
if (accel.digest.may_have (c->buffer->cur().codepoint) &&
(c->buffer->cur().mask & c->lookup_mask) &&
if (accel.digest.may_have (buffer->cur().codepoint) &&
(buffer->cur().mask & c->lookup_mask) &&
apply_once (c, lookup))
ret = true;
/* The reverse lookup doesn't "advance" cursor (for good reason). */
c->buffer->idx--;
buffer->idx--;
}
while ((int) c->buffer->idx >= 0);
while ((int) buffer->idx >= 0);
}
return ret;

View File

@ -132,17 +132,19 @@ static inline unsigned int
decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint_t ab)
{
hb_codepoint_t a, b, a_glyph, b_glyph;
hb_buffer_t * const buffer = c->buffer;
hb_font_t * const font = c->font;
if (!c->decompose (c, ab, &a, &b) ||
(b && !c->font->get_glyph (b, 0, &b_glyph)))
(b && !font->get_glyph (b, 0, &b_glyph)))
return 0;
bool has_a = c->font->get_glyph (a, 0, &a_glyph);
bool has_a = font->get_glyph (a, 0, &a_glyph);
if (shortest && has_a) {
/* Output a and b */
output_char (c->buffer, a, a_glyph);
output_char (buffer, a, a_glyph);
if (likely (b)) {
output_char (c->buffer, b, b_glyph);
output_char (buffer, b, b_glyph);
return 2;
}
return 1;
@ -151,16 +153,16 @@ decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint
unsigned int ret;
if ((ret = decompose (c, shortest, a))) {
if (b) {
output_char (c->buffer, b, b_glyph);
output_char (buffer, b, b_glyph);
return ret + 1;
}
return ret;
}
if (has_a) {
output_char (c->buffer, a, a_glyph);
output_char (buffer, a, a_glyph);
if (likely (b)) {
output_char (c->buffer, b, b_glyph);
output_char (buffer, b, b_glyph);
return 2;
}
return 1;
@ -214,34 +216,35 @@ static inline void
handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
{
hb_buffer_t * const buffer = c->buffer;
hb_font_t * const font = c->font;
for (; buffer->idx < end - 1;) {
if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepoint))) {
/* The next two lines are some ugly lines... But work. */
if (c->font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index()))
if (font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index()))
{
buffer->replace_glyphs (2, 1, &buffer->cur().codepoint);
}
else
{
/* Just pass on the two characters separately, let GSUB do its magic. */
set_glyph (buffer->cur(), c->font);
set_glyph (buffer->cur(), font);
buffer->next_glyph ();
set_glyph (buffer->cur(), c->font);
set_glyph (buffer->cur(), font);
buffer->next_glyph ();
}
/* Skip any further variation selectors. */
while (buffer->idx < end && unlikely (buffer->unicode->is_variation_selector (buffer->cur().codepoint)))
{
set_glyph (buffer->cur(), c->font);
set_glyph (buffer->cur(), font);
buffer->next_glyph ();
}
} else {
set_glyph (buffer->cur(), c->font);
set_glyph (buffer->cur(), font);
buffer->next_glyph ();
}
}
if (likely (buffer->idx < end)) {
set_glyph (buffer->cur(), c->font);
set_glyph (buffer->cur(), font);
buffer->next_glyph ();
}
}

View File

@ -290,16 +290,18 @@ hb_ot_mirror_chars (hb_ot_shape_context_t *c)
if (HB_DIRECTION_IS_FORWARD (c->target_direction))
return;
hb_unicode_funcs_t *unicode = c->buffer->unicode;
hb_buffer_t *buffer = c->buffer;
hb_unicode_funcs_t *unicode = buffer->unicode;
hb_mask_t rtlm_mask = c->plan->map.get_1_mask (HB_TAG ('r','t','l','m'));
unsigned int count = c->buffer->len;
unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info;
for (unsigned int i = 0; i < count; i++) {
hb_codepoint_t codepoint = unicode->mirroring (c->buffer->info[i].codepoint);
if (likely (codepoint == c->buffer->info[i].codepoint))
c->buffer->info[i].mask |= rtlm_mask;
hb_codepoint_t codepoint = unicode->mirroring (info[i].codepoint);
if (likely (codepoint == info[i].codepoint))
info[i].mask |= rtlm_mask;
else
c->buffer->info[i].codepoint = codepoint;
info[i].codepoint = codepoint;
}
}
@ -307,12 +309,13 @@ static inline void
hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
{
hb_ot_map_t *map = &c->plan->map;
hb_buffer_t *buffer = c->buffer;
hb_mask_t global_mask = map->get_global_mask ();
c->buffer->reset_masks (global_mask);
buffer->reset_masks (global_mask);
if (c->plan->shaper->setup_masks)
c->plan->shaper->setup_masks (c->plan, c->buffer, c->font);
c->plan->shaper->setup_masks (c->plan, buffer, c->font);
for (unsigned int i = 0; i < c->num_user_features; i++)
{
@ -320,7 +323,7 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
if (!(feature->start == 0 && feature->end == (unsigned int)-1)) {
unsigned int shift;
hb_mask_t mask = map->get_mask (feature->tag, &shift);
c->buffer->set_masks (feature->value << shift, mask, feature->start, feature->end);
buffer->set_masks (feature->value << shift, mask, feature->start, feature->end);
}
}
}
@ -338,9 +341,10 @@ static inline void
hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
{
unsigned int count = c->buffer->len;
hb_glyph_info_t *info = c->buffer->info;
for (unsigned int i = 0; i < count; i++)
_hb_glyph_info_set_glyph_props (&c->buffer->info[i],
_hb_glyph_info_get_general_category (&c->buffer->info[i])
_hb_glyph_info_set_glyph_props (&info[i],
_hb_glyph_info_get_general_category (&info[i])
== HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ?
HB_OT_LAYOUT_GLYPH_PROPS_MARK :
HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH);
@ -349,37 +353,41 @@ hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
static inline void
hb_ot_substitute_default (hb_ot_shape_context_t *c)
{
hb_buffer_t *buffer = c->buffer;
if (c->plan->shaper->preprocess_text)
c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font);
c->plan->shaper->preprocess_text (c->plan, buffer, c->font);
hb_ot_mirror_chars (c);
HB_BUFFER_ALLOCATE_VAR (c->buffer, glyph_index);
HB_BUFFER_ALLOCATE_VAR (buffer, glyph_index);
_hb_ot_shape_normalize (c->plan, c->buffer, c->font);
_hb_ot_shape_normalize (c->plan, buffer, c->font);
hb_ot_shape_setup_masks (c);
/* This is unfortunate to go here, but necessary... */
if (!hb_ot_layout_has_positioning (c->face))
_hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, c->buffer);
_hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, buffer);
hb_ot_map_glyphs_fast (c->buffer);
hb_ot_map_glyphs_fast (buffer);
HB_BUFFER_DEALLOCATE_VAR (c->buffer, glyph_index);
HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_index);
}
static inline void
hb_ot_substitute_complex (hb_ot_shape_context_t *c)
{
hb_ot_layout_substitute_start (c->font, c->buffer);
hb_buffer_t *buffer = c->buffer;
hb_ot_layout_substitute_start (c->font, buffer);
if (!hb_ot_layout_has_glyph_classes (c->face))
hb_synthesize_glyph_classes (c);
c->plan->substitute (c->font, c->buffer);
c->plan->substitute (c->font, buffer);
hb_ot_layout_substitute_finish (c->font, c->buffer);
hb_ot_layout_substitute_finish (c->font, buffer);
return;
}
@ -420,17 +428,20 @@ zero_mark_widths_by_gdef (hb_buffer_t *buffer)
static inline void
hb_ot_position_default (hb_ot_shape_context_t *c)
{
hb_direction_t direction = c->buffer->props.direction;
unsigned int count = c->buffer->len;
hb_glyph_info_t *info = c->buffer->info;
hb_glyph_position_t *pos = c->buffer->pos;
for (unsigned int i = 0; i < count; i++)
{
c->font->get_glyph_advance_for_direction (c->buffer->info[i].codepoint,
c->buffer->props.direction,
&c->buffer->pos[i].x_advance,
&c->buffer->pos[i].y_advance);
c->font->subtract_glyph_origin_for_direction (c->buffer->info[i].codepoint,
c->buffer->props.direction,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
c->font->get_glyph_advance_for_direction (info[i].codepoint,
direction,
&pos[i].x_advance,
&pos[i].y_advance);
c->font->subtract_glyph_origin_for_direction (info[i].codepoint,
direction,
&pos[i].x_offset,
&pos[i].y_offset);
}
}
@ -462,22 +473,25 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
if (hb_ot_layout_has_positioning (c->face))
{
hb_glyph_info_t *info = c->buffer->info;
hb_glyph_position_t *pos = c->buffer->pos;
/* Change glyph origin to what GPOS expects, apply GPOS, change it back. */
for (unsigned int i = 0; i < count; i++) {
c->font->add_glyph_origin_for_direction (c->buffer->info[i].codepoint,
c->font->add_glyph_origin_for_direction (info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
&pos[i].x_offset,
&pos[i].y_offset);
}
c->plan->position (c->font, c->buffer);
for (unsigned int i = 0; i < count; i++) {
c->font->subtract_glyph_origin_for_direction (c->buffer->info[i].codepoint,
c->font->subtract_glyph_origin_for_direction (info[i].codepoint,
HB_DIRECTION_LTR,
&c->buffer->pos[i].x_offset,
&c->buffer->pos[i].y_offset);
&pos[i].x_offset,
&pos[i].y_offset);
}
ret = true;