Add accessort to buffer for current info, current pos, and prev info

This commit is contained in:
Behdad Esfahbod 2012-05-13 15:45:18 +02:00
parent 6736f3c5b0
commit 99c2695759
8 changed files with 76 additions and 66 deletions

View File

@ -70,6 +70,15 @@ struct _hb_buffer_t {
hb_glyph_info_t *out_info;
hb_glyph_position_t *pos;
inline hb_glyph_info_t &cur (unsigned int i = 0) { return info[idx + i]; }
inline hb_glyph_info_t cur (unsigned int i = 0) const { return info[idx + i]; }
inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; }
inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; }
inline hb_glyph_info_t &prev (void) { return out_info[out_len - 1]; }
inline hb_glyph_info_t prev (void) const { return info[out_len - 1]; }
unsigned int serial;
uint8_t allocated_var_bytes[8];
const char *allocated_var_owner[8];

View File

@ -403,10 +403,10 @@ 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->info[c->buffer->idx].codepoint, &mark_x, &mark_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);
hb_glyph_position_t &o = c->buffer->pos[c->buffer->idx];
hb_glyph_position_t &o = c->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;
@ -432,11 +432,11 @@ struct SinglePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
valueFormat.apply_value (c->font, c->direction, this,
values, c->buffer->pos[c->buffer->idx]);
values, c->buffer->cur_pos());
c->buffer->idx++;
return TRACE_RETURN (true);
@ -469,14 +469,14 @@ struct SinglePosFormat2
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->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->pos[c->buffer->idx]);
c->buffer->cur_pos());
c->buffer->idx++;
return TRACE_RETURN (true);
@ -569,7 +569,7 @@ struct PairSet
if (c->buffer->info[pos].codepoint == record->secondGlyph)
{
valueFormats[0].apply_value (c->font, c->direction, this,
&record->values[0], c->buffer->pos[c->buffer->idx]);
&record->values[0], c->buffer->cur_pos());
valueFormats[1].apply_value (c->font, c->direction, this,
&record->values[len1], c->buffer->pos[pos]);
if (len2)
@ -620,7 +620,7 @@ struct PairPosFormat1
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@ -672,7 +672,7 @@ struct PairPosFormat2
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@ -681,13 +681,13 @@ struct PairPosFormat2
unsigned int len2 = valueFormat2.get_len ();
unsigned int record_len = len1 + len2;
unsigned int klass1 = (this+classDef1) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int klass1 = (this+classDef1) (c->buffer->cur().codepoint);
unsigned int klass2 = (this+classDef2) (c->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->pos[c->buffer->idx]);
v, c->buffer->cur_pos());
valueFormat2.apply_value (c->font, c->direction, this,
v + len1, c->buffer->pos[skippy_iter.idx]);
@ -816,7 +816,7 @@ struct CursivePosFormat1
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->info[c->buffer->idx].codepoint)];
const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->cur().codepoint)];
if (!this_record.exitAnchor) return TRACE_RETURN (false);
if (!skippy_iter.next ()) return TRACE_RETURN (false);
@ -949,7 +949,7 @@ struct MarkBasePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int mark_index = (this+markCoverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
@ -1040,7 +1040,7 @@ struct MarkLigPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int mark_index = (this+markCoverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
@ -1068,10 +1068,10 @@ struct MarkLigPosFormat1
* can directly use the component index. If not, we attach the mark
* glyph to the last component of the ligature. */
if (get_lig_id (c->buffer->info[j]) &&
get_lig_id (c->buffer->info[j]) == get_lig_id (c->buffer->info[c->buffer->idx]) &&
get_lig_comp (c->buffer->info[c->buffer->idx]) > 0)
get_lig_id (c->buffer->cur()) &&
get_lig_comp (c->buffer->cur()) > 0)
{
comp_index = get_lig_comp (c->buffer->info[c->buffer->idx]) - 1;
comp_index = get_lig_comp (c->buffer->cur()) - 1;
if (comp_index >= comp_count)
comp_index = comp_count - 1;
}
@ -1151,7 +1151,7 @@ struct MarkMarkPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int mark1_index = (this+mark1Coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int mark1_index = (this+mark1Coverage) (c->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 */
@ -1166,9 +1166,9 @@ struct MarkMarkPosFormat1
/* Two marks match only if they belong to the same base, or same component
* of the same ligature. That is, the component numbers must match, and
* if those are non-zero, the ligid number should also match. */
if ((get_lig_comp (c->buffer->info[j]) != get_lig_comp (c->buffer->info[c->buffer->idx])) ||
if ((get_lig_comp (c->buffer->cur())) ||
(get_lig_comp (c->buffer->info[j]) > 0 &&
get_lig_id (c->buffer->info[j]) != get_lig_id (c->buffer->info[c->buffer->idx])))
get_lig_id (c->buffer->cur())))
return TRACE_RETURN (false);
unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint);
@ -1363,7 +1363,7 @@ struct PosLookup : Lookup
{
unsigned int lookup_type = get_type ();
if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->idx], c->lookup_props, &c->property))
if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->cur(), c->lookup_props, &c->property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
@ -1385,7 +1385,7 @@ struct PosLookup : Lookup
c->buffer->idx = 0;
while (c->buffer->idx < c->buffer->len)
{
if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
ret = true;
else
c->buffer->idx++;

View File

@ -58,7 +58,7 @@ struct SingleSubstFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@ -110,7 +110,7 @@ struct SingleSubstFormat2
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@ -257,7 +257,7 @@ struct MultipleSubstFormat1
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
return TRACE_RETURN ((this+sequence[index]).apply (c));
@ -360,7 +360,7 @@ struct AlternateSubstFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@ -369,7 +369,7 @@ struct AlternateSubstFormat1
if (unlikely (!alt_set.len)) return TRACE_RETURN (false);
hb_mask_t glyph_mask = c->buffer->info[c->buffer->idx].mask;
hb_mask_t glyph_mask = c->buffer->cur().mask;
hb_mask_t lookup_mask = c->lookup_mask;
/* Note: This breaks badly if two features enabled this lookup together. */
@ -500,7 +500,7 @@ struct Ligature
/* Allocate new ligature id */
unsigned int lig_id = allocate_lig_id (c->buffer);
set_lig_props (c->buffer->info[c->buffer->idx], lig_id, 0);
set_lig_props (c->buffer->cur(), lig_id, 0);
if (skippy_iter.idx < c->buffer->idx + count) /* No input glyphs skipped */
{
@ -521,8 +521,8 @@ struct Ligature
{
while (c->should_mark_skip_current_glyph ())
{
set_lig_props (c->buffer->info[c->buffer->idx], lig_id, i);
c->replace_glyph (c->buffer->info[c->buffer->idx].codepoint);
set_lig_props (c->buffer->cur(), lig_id, i);
c->replace_glyph (c->buffer->cur().codepoint);
}
/* Skip the base glyph */
@ -628,7 +628,7 @@ struct LigatureSubstFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->info[c->buffer->idx].codepoint;
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
@ -807,7 +807,7 @@ struct ReverseChainSingleSubstFormat1
if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL))
return TRACE_RETURN (false); /* No chaining to this type */
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
@ -821,7 +821,7 @@ struct ReverseChainSingleSubstFormat1
match_coverage, this,
1))
{
c->buffer->info[c->buffer->idx].codepoint = substitute[index];
c->buffer->cur().codepoint = substitute[index];
c->buffer->idx--; /* Reverse! */
return TRACE_RETURN (true);
}
@ -1055,7 +1055,7 @@ struct SubstLookup : Lookup
{
unsigned int lookup_type = get_type ();
if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->idx], c->lookup_props, &c->property))
if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->cur(), c->lookup_props, &c->property))
return false;
if (unlikely (lookup_type == SubstLookupSubTable::Extension))
@ -1096,7 +1096,7 @@ struct SubstLookup : Lookup
c->buffer->idx = 0;
while (c->buffer->idx < c->buffer->len)
{
if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
ret = true;
else
c->buffer->next_glyph ();
@ -1111,7 +1111,7 @@ struct SubstLookup : Lookup
c->buffer->idx = c->buffer->len - 1;
do
{
if ((c->buffer->info[c->buffer->idx].mask & c->lookup_mask) && apply_once (c))
if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
ret = true;
else
c->buffer->idx--;

View File

@ -95,7 +95,7 @@ struct hb_closure_context_t
#endif
#define TRACE_APPLY() \
hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", this, HB_FUNC, "idx %d codepoint %u", c->buffer->idx, c->buffer->info[c->buffer->idx].codepoint);
hb_auto_trace_t<HB_DEBUG_APPLY> trace (&c->debug_depth, "APPLY", this, HB_FUNC, "idx %d codepoint %u", c->buffer->cur().codepoint);
@ -137,7 +137,7 @@ struct hb_apply_context_t
idx = start_index_;
num_items = num_items_;
mask = context_match ? -1 : c->lookup_mask;
syllable = context_match ? 0 : c->buffer->info[c->buffer->idx].syllable ();
syllable = context_match ? 0 : c->buffer->cur().syllable ();
end = c->buffer->len;
}
inline bool has_no_chance (void) const
@ -183,7 +183,7 @@ struct hb_apply_context_t
idx = start_index_;
num_items = num_items_;
mask = mask_ ? mask_ : c->lookup_mask;
syllable = match_syllable_ ? c->buffer->info[c->buffer->idx].syllable () : 0;
syllable = match_syllable_ ? c->buffer->cur().syllable () : 0;
}
inline bool has_no_chance (void) const
{
@ -217,7 +217,7 @@ struct hb_apply_context_t
inline bool should_mark_skip_current_glyph (void) const
{
return _hb_ot_layout_skip_mark (face, &buffer->info[buffer->idx], lookup_props, NULL);
return _hb_ot_layout_skip_mark (face, &buffer->cur(), lookup_props, NULL);
}
@ -238,14 +238,14 @@ struct hb_apply_context_t
inline void guess_glyph_class (unsigned int klass)
{
/* XXX if ! has gdef */
buffer->info[buffer->idx].props_cache() = klass;
buffer->cur().props_cache() = klass;
}
private:
inline void clear_property (void) const
{
/* XXX if has gdef */
buffer->info[buffer->idx].props_cache() = 0;
buffer->cur().props_cache() = 0;
}
};
@ -625,7 +625,7 @@ struct ContextFormat1
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED))
return TRACE_RETURN (false);
@ -685,11 +685,11 @@ struct ContextFormat2
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const ClassDef &class_def = this+classDef;
index = class_def (c->buffer->info[c->buffer->idx].codepoint);
index = class_def (c->buffer->cur().codepoint);
const RuleSet &rule_set = this+ruleSet[index];
struct ContextApplyLookupContext lookup_context = {
{match_class, apply_func},
@ -745,7 +745,7 @@ struct ContextFormat3
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage[0]) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage[0]) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
@ -1020,7 +1020,7 @@ struct ChainContextFormat1
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const ChainRuleSet &rule_set = this+ruleSet[index];
@ -1082,14 +1082,14 @@ struct ChainContextFormat2
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{
TRACE_APPLY ();
unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const ClassDef &backtrack_class_def = this+backtrackClassDef;
const ClassDef &input_class_def = this+inputClassDef;
const ClassDef &lookahead_class_def = this+lookaheadClassDef;
index = input_class_def (c->buffer->info[c->buffer->idx].codepoint);
index = input_class_def (c->buffer->cur().codepoint);
const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextApplyLookupContext lookup_context = {
{match_class, apply_func},
@ -1164,7 +1164,7 @@ struct ChainContextFormat3
TRACE_APPLY ();
const OffsetArrayOf<Coverage> &input = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
unsigned int index = (this+input[0]) (c->buffer->info[c->buffer->idx].codepoint);
unsigned int index = (this+input[0]) (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (input);

View File

@ -222,8 +222,8 @@ arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
/* Mandatory ligatures */
buffer->clear_output ();
for (buffer->idx = 0; buffer->idx + 1 < count;) {
hb_codepoint_t ligature = get_ligature (buffer->info[buffer->idx].codepoint,
buffer->info[buffer->idx + 1].codepoint);
hb_codepoint_t ligature = get_ligature (buffer->cur().codepoint,
buffer->cur(+1).codepoint);
if (likely (!ligature) || !(hb_font_get_glyph (font, ligature, 0, &glyph))) {
buffer->next_glyph ();
continue;

View File

@ -141,7 +141,7 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb
unsigned int count = buffer->len;
for (buffer->idx = 0; buffer->idx < count;)
{
hb_codepoint_t u = buffer->info[buffer->idx].codepoint;
hb_codepoint_t u = buffer->cur().codepoint;
if (likely (!IS_SARA_AM (u))) {
buffer->next_glyph ();
continue;
@ -167,11 +167,12 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb
sizeof (buffer->out_info[0]) * (end - start - 2));
buffer->out_info[start] = t;
/* XXX Make this easier! */
/* Make cluster */
for (; start > 0 && buffer->out_info[start - 1].cluster == buffer->out_info[start].cluster; start--)
;
for (; buffer->idx < count;)
if (buffer->info[buffer->idx].cluster == buffer->out_info[buffer->out_len - 1].cluster)
if (buffer->cur().cluster == buffer->prev().cluster)
buffer->next_glyph ();
else
break;

View File

@ -73,7 +73,7 @@ output_glyph (hb_font_t *font, hb_buffer_t *buffer,
hb_codepoint_t glyph)
{
buffer->output_glyph (glyph);
_hb_glyph_info_set_unicode_props (&buffer->out_info[buffer->out_len - 1], buffer->unicode);
_hb_glyph_info_set_unicode_props (&buffer->prev(), buffer->unicode);
}
static bool
@ -116,7 +116,7 @@ static void
decompose_current_glyph (hb_font_t *font, hb_buffer_t *buffer,
bool shortest)
{
if (decompose (font, buffer, shortest, buffer->info[buffer->idx].codepoint))
if (decompose (font, buffer, shortest, buffer->cur().codepoint))
buffer->skip_glyph ();
else
buffer->next_glyph ();
@ -129,7 +129,7 @@ decompose_single_char_cluster (hb_font_t *font, hb_buffer_t *buffer,
hb_codepoint_t glyph;
/* If recomposing and font supports this, we're good to go */
if (will_recompose && hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph)) {
if (will_recompose && hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph)) {
buffer->next_glyph ();
return;
}
@ -185,7 +185,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
{
unsigned int end;
for (end = buffer->idx + 1; end < count; end++)
if (buffer->info[buffer->idx].cluster != buffer->info[end].cluster)
if (buffer->cur().cluster != buffer->info[end].cluster)
break;
if (buffer->idx + 1 == end)
@ -247,15 +247,15 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
if (/* If mode is NOT COMPOSED_FULL (ie. it's COMPOSED_DIACRITICS), we don't try to
* compose a CCC=0 character with it's preceding starter. */
(mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_FULL ||
_hb_glyph_info_get_modified_combining_class (&buffer->info[buffer->idx]) != 0) &&
_hb_glyph_info_get_modified_combining_class (&buffer->cur()) != 0) &&
/* If there's anything between the starter and this char, they should have CCC
* smaller than this character's. */
(starter == buffer->out_len - 1 ||
_hb_glyph_info_get_modified_combining_class (&buffer->out_info[buffer->out_len - 1]) < _hb_glyph_info_get_modified_combining_class (&buffer->info[buffer->idx])) &&
_hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) &&
/* And compose. */
hb_unicode_compose (buffer->unicode,
buffer->out_info[starter].codepoint,
buffer->info[buffer->idx].codepoint,
buffer->cur().codepoint,
&composed) &&
/* And the font has glyph for the composite. */
hb_font_get_glyph (font, composed, 0, &glyph))
@ -272,7 +272,7 @@ _hb_ot_shape_normalize (hb_font_t *font, hb_buffer_t *buffer,
/* Blocked, or doesn't compose. */
buffer->next_glyph ();
if (_hb_glyph_info_get_modified_combining_class (&buffer->out_info[buffer->out_len - 1]) == 0)
if (_hb_glyph_info_get_modified_combining_class (&buffer->prev()) == 0)
starter = buffer->out_len - 1;
}
buffer->swap_buffers ();

View File

@ -244,16 +244,16 @@ hb_map_glyphs (hb_font_t *font,
unsigned int count = buffer->len - 1;
for (buffer->idx = 0; buffer->idx < count;) {
if (unlikely (_hb_unicode_is_variation_selector (buffer->info[buffer->idx + 1].codepoint))) {
hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, buffer->info[buffer->idx + 1].codepoint, &glyph);
if (unlikely (_hb_unicode_is_variation_selector (buffer->cur(+1).codepoint))) {
hb_font_get_glyph (font, buffer->cur().codepoint, buffer->cur(+1).codepoint, &glyph);
buffer->replace_glyphs (2, 1, &glyph);
} else {
hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph);
hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph);
buffer->replace_glyph (glyph);
}
}
if (likely (buffer->idx < buffer->len)) {
hb_font_get_glyph (font, buffer->info[buffer->idx].codepoint, 0, &glyph);
hb_font_get_glyph (font, buffer->cur().codepoint, 0, &glyph);
buffer->replace_glyph (glyph);
}
buffer->swap_buffers ();