[otlayout] More shuffling around

This commit is contained in:
Behdad Esfahbod 2013-10-18 00:42:39 +02:00
parent 91689de260
commit 101303dbf7
5 changed files with 102 additions and 35 deletions

View File

@ -877,7 +877,7 @@ struct CursivePosFormat1
TRACE_APPLY (this);
/* We don't handle mark glyphs here. */
if (c->buffer->cur().glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK) return TRACE_RETURN (false);
if (unlikely (_hb_glyph_info_is_mark (&c->buffer->cur()))) return TRACE_RETURN (false);
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
@ -1035,8 +1035,8 @@ struct MarkBasePosFormat1
skippy_iter.reject ();
} while (1);
/* The following assertion is too strong, so we've disabled it. */
if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/}
/* 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);*/ }
unsigned int base_index = (this+baseCoverage).get_coverage (c->buffer->info[skippy_iter.idx].codepoint);
if (base_index == NOT_COVERED) return TRACE_RETURN (false);
@ -1133,8 +1133,8 @@ struct MarkLigPosFormat1
skippy_iter.set_lookup_props (LookupFlag::IgnoreMarks);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
/* The following assertion is too strong, so we've disabled it. */
if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE)) {/*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);*/ }
unsigned int j = skippy_iter.idx;
unsigned int lig_index = (this+ligatureCoverage).get_coverage (c->buffer->info[j].codepoint);
@ -1248,7 +1248,7 @@ struct MarkMarkPosFormat1
skippy_iter.set_lookup_props (c->lookup_props & ~LookupFlag::IgnoreFlags);
if (!skippy_iter.prev ()) return TRACE_RETURN (false);
if (!(c->buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) { return TRACE_RETURN (false); }
if (!_hb_glyph_info_is_mark (&c->buffer->info[skippy_iter.idx])) { return TRACE_RETURN (false); }
unsigned int j = skippy_iter.idx;
@ -1591,9 +1591,7 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
for (unsigned int i = 0; i < len; i++)
fix_mark_attachment (pos, i, direction);
HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_props);
_hb_buffer_deallocate_gsubgpos_vars (buffer);
}

View File

@ -291,8 +291,7 @@ struct Sequence
TRACE_APPLY (this);
if (unlikely (!substitute.len)) return TRACE_RETURN (false);
unsigned int klass = c->buffer->cur().glyph_props() &
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ?
unsigned int klass = _hb_glyph_info_is_ligature (&c->buffer->cur()) ?
HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0;
unsigned int count = substitute.len;
if (count == 1) /* Special-case to make it in-place. */
@ -1375,15 +1374,15 @@ struct GSUB : GSUBGPOS
void
GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
{
HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props);
HB_BUFFER_ALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_ALLOCATE_VAR (buffer, syllable);
_hb_buffer_allocate_gsubgpos_vars (buffer);
const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++) {
buffer->info[i].lig_props() = buffer->info[i].syllable() = 0;
for (unsigned int i = 0; i < count; i++)
{
_hb_glyph_info_set_glyph_props (&buffer->info[i], gdef.get_glyph_props (buffer->info[i].codepoint));
_hb_glyph_info_clear_lig_props (&buffer->info[i]);
buffer->info[i].syllable() = 0;
}
}

View File

@ -401,7 +401,7 @@ struct hb_apply_context_t
{
unsigned int property;
property = info.glyph_props();
property = _hb_glyph_info_get_glyph_props (&info);
if (!c->match_properties (info.codepoint, property, lookup_props))
return SKIP_YES;
@ -610,7 +610,7 @@ struct hb_apply_context_t
{
unsigned int property;
property = info->glyph_props();
property = _hb_glyph_info_get_glyph_props (info);
return match_properties (info->codepoint, property, lookup_props);
}
@ -790,7 +790,7 @@ static inline bool match_input (hb_apply_context_t *c,
* ligate with a conjunct...)
*/
bool is_mark_ligature = !!(buffer->cur().glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
bool is_mark_ligature = _hb_glyph_info_is_mark (&buffer->cur());
unsigned int total_component_count = 0;
total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->cur());
@ -822,7 +822,7 @@ static inline bool match_input (hb_apply_context_t *c,
return TRACE_RETURN (false);
}
is_mark_ligature = is_mark_ligature && (buffer->info[skippy_iter.idx].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
is_mark_ligature = is_mark_ligature && _hb_glyph_info_is_mark (&buffer->info[skippy_iter.idx]);
total_component_count += _hb_glyph_info_get_lig_num_comps (&buffer->info[skippy_iter.idx]);
}

View File

@ -38,16 +38,6 @@
#include "hb-set-private.hh"
/* buffer var allocations, used during the entire shaping process */
#define unicode_props0() var2.u8[0]
#define unicode_props1() var2.u8[1]
/* buffer var allocations, used during the GSUB/GPOS processing */
#define glyph_props() var1.u16[0] /* GDEF glyph properties */
#define lig_props() var1.u8[2] /* GSUB/GPOS ligature tracking */
#define syllable() var1.u8[3] /* GSUB/GPOS shaping boundaries */
/*
* GDEF
*/
@ -171,6 +161,15 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout);
* Buffer var routines.
*/
/* buffer var allocations, used during the entire shaping process */
#define unicode_props0() var2.u8[0]
#define unicode_props1() var2.u8[1]
/* buffer var allocations, used during the GSUB/GPOS processing */
#define glyph_props() var1.u16[0] /* GDEF glyph properties */
#define lig_props() var1.u8[2] /* GSUB/GPOS ligature tracking */
#define syllable() var1.u8[3] /* GSUB/GPOS shaping boundaries */
/* unicode_props */
enum {
@ -264,7 +263,15 @@ _hb_glyph_info_flip_joiners (hb_glyph_info_t *info)
* The numbers are also used in GPOS to do mark-to-mark positioning only
* to marks that belong to the same component of the same ligature.
*/
static inline void
_hb_glyph_info_clear_lig_props (hb_glyph_info_t *info)
{
info->lig_props() = 0;
}
#define IS_LIG_BASE 0x10
static inline void
_hb_glyph_info_set_lig_props_for_ligature (hb_glyph_info_t *info,
unsigned int lig_id,
@ -272,6 +279,7 @@ _hb_glyph_info_set_lig_props_for_ligature (hb_glyph_info_t *info,
{
info->lig_props() = (lig_id << 5) | IS_LIG_BASE | (lig_num_comps & 0x0F);
}
static inline void
_hb_glyph_info_set_lig_props_for_mark (hb_glyph_info_t *info,
unsigned int lig_id,
@ -279,6 +287,7 @@ _hb_glyph_info_set_lig_props_for_mark (hb_glyph_info_t *info,
{
info->lig_props() = (lig_id << 5) | (lig_comp & 0x0F);
}
static inline void
_hb_glyph_info_set_lig_props_for_component (hb_glyph_info_t *info, unsigned int comp)
{
@ -290,11 +299,13 @@ _hb_glyph_info_get_lig_id (const hb_glyph_info_t *info)
{
return info->lig_props() >> 5;
}
static inline bool
_hb_glyph_info_is_ligated (const hb_glyph_info_t *info)
{
return !!(info->lig_props() & IS_LIG_BASE);
}
static inline unsigned int
_hb_glyph_info_get_lig_comp (const hb_glyph_info_t *info)
{
@ -303,6 +314,7 @@ _hb_glyph_info_get_lig_comp (const hb_glyph_info_t *info)
else
return info->lig_props() & 0x0F;
}
static inline unsigned int
_hb_glyph_info_get_lig_num_comps (const hb_glyph_info_t *info)
{
@ -329,7 +341,67 @@ _hb_glyph_info_set_glyph_props (hb_glyph_info_t *info, unsigned int props)
info->glyph_props() = props;
}
inline unsigned int
_hb_glyph_info_get_glyph_props (const hb_glyph_info_t *info)
{
return info->glyph_props();
}
inline bool
_hb_glyph_info_is_base_glyph (const hb_glyph_info_t *info)
{
return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH);
}
inline bool
_hb_glyph_info_is_ligature (const hb_glyph_info_t *info)
{
return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE);
}
inline bool
_hb_glyph_info_is_mark (const hb_glyph_info_t *info)
{
return !!(info->glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
}
/* Allocation / deallocation. */
inline void
_hb_buffer_allocate_unicode_vars (hb_buffer_t *buffer)
{
HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props0);
HB_BUFFER_ALLOCATE_VAR (buffer, unicode_props1);
}
inline void
_hb_buffer_deallocate_unicode_vars (hb_buffer_t *buffer)
{
HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props0);
HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props1);
}
inline void
_hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer)
{
HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props);
HB_BUFFER_ALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_ALLOCATE_VAR (buffer, syllable);
}
inline void
_hb_buffer_deallocate_gsubgpos_vars (hb_buffer_t *buffer)
{
HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_props);
}
/* Make sure no one directly touches our props... */
#undef unicode_props0
#undef unicode_props1
#undef lig_props
#undef glyph_props
#endif /* HB_OT_LAYOUT_PRIVATE_HH */

View File

@ -410,7 +410,7 @@ zero_mark_widths_by_gdef (hb_buffer_t *buffer)
{
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
if ((buffer->info[i].glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_MARK))
if (_hb_glyph_info_is_mark (&buffer->info[i]))
{
buffer->pos[i].x_advance = 0;
buffer->pos[i].y_advance = 0;
@ -584,8 +584,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
/* Save the original direction, we use it later. */
c->target_direction = c->buffer->props.direction;
HB_BUFFER_ALLOCATE_VAR (c->buffer, unicode_props0);
HB_BUFFER_ALLOCATE_VAR (c->buffer, unicode_props1);
_hb_buffer_allocate_unicode_vars (c->buffer);
c->buffer->clear_output ();
@ -600,8 +599,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
hb_ot_hide_default_ignorables (c);
HB_BUFFER_DEALLOCATE_VAR (c->buffer, unicode_props1);
HB_BUFFER_DEALLOCATE_VAR (c->buffer, unicode_props0);
_hb_buffer_deallocate_unicode_vars (c->buffer);
c->buffer->props.direction = c->target_direction;