Implement hb_ot_layout_get_glyph_class()

This commit is contained in:
Behdad Esfahbod 2012-11-16 13:34:29 -08:00
parent f9edd5d56b
commit 5a08ecf920
8 changed files with 38 additions and 26 deletions

View File

@ -383,13 +383,13 @@ struct GDEF
switch (klass) {
default:
case UnclassifiedGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED;
case BaseGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
case LigatureGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
case ComponentGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT;
case UnclassifiedGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_UNCLASSIFIED;
case BaseGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH;
case LigatureGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE;
case ComponentGlyph: return HB_OT_LAYOUT_GLYPH_PROPS_COMPONENT;
case MarkGlyph:
klass = get_mark_attachment_type (glyph);
return HB_OT_LAYOUT_GLYPH_CLASS_MARK | (klass << 8);
return HB_OT_LAYOUT_GLYPH_PROPS_MARK | (klass << 8);
}
}

View File

@ -863,7 +863,7 @@ struct CursivePosFormat1
TRACE_APPLY ();
/* We don't handle mark glyphs here. */
if (c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK) return TRACE_RETURN (false);
if (c->property & HB_OT_LAYOUT_GLYPH_PROPS_MARK) return TRACE_RETURN (false);
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);
@ -1030,7 +1030,7 @@ struct MarkBasePosFormat1
} while (1);
/* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/}
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/}
unsigned int base_index = (this+baseCoverage) (c->buffer->info[skippy_iter.idx].codepoint);
if (base_index == NOT_COVERED) return TRACE_RETURN (false);
@ -1136,7 +1136,7 @@ struct MarkLigPosFormat1
if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks)) return TRACE_RETURN (false);
/* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)) {/*return TRACE_RETURN (false);*/}
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE)) {/*return TRACE_RETURN (false);*/}
unsigned int j = skippy_iter.idx;
unsigned int lig_index = (this+ligatureCoverage) (c->buffer->info[j].codepoint);
@ -1258,7 +1258,7 @@ struct MarkMarkPosFormat1
hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
if (!skippy_iter.prev (&property)) return TRACE_RETURN (false);
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) return TRACE_RETURN (false);
if (!(property & HB_OT_LAYOUT_GLYPH_PROPS_MARK)) return TRACE_RETURN (false);
unsigned int j = skippy_iter.idx;

View File

@ -266,7 +266,7 @@ struct Sequence
TRACE_APPLY ();
if (unlikely (!substitute.len)) return TRACE_RETURN (false);
unsigned int klass = c->property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE ? HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH : 0;
unsigned int klass = c->property & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE ? HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH : 0;
unsigned int count = substitute.len;
for (unsigned int i = 0; i < count; i++) {
set_lig_props_for_component (c->buffer->cur(), i);

View File

@ -264,7 +264,7 @@ struct hb_apply_context_t
if (glyph_props & lookup_props & LookupFlag::IgnoreFlags)
return false;
if (unlikely (glyph_props & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
if (unlikely (glyph_props & HB_OT_LAYOUT_GLYPH_PROPS_MARK))
return match_properties_mark (glyph, glyph_props, lookup_props);
return true;
@ -295,7 +295,7 @@ struct hb_apply_context_t
*property_out = property;
/* If it's a mark, skip it if we don't accept it. */
if (unlikely (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
if (unlikely (property & HB_OT_LAYOUT_GLYPH_PROPS_MARK))
return !match_properties (info->codepoint, property, lookup_props);
/* If not a mark, don't skip. */
@ -445,7 +445,7 @@ static inline bool match_input (hb_apply_context_t *c,
* ligate with a conjunct...)
*/
bool is_mark_ligature = !!(c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
bool is_mark_ligature = !!(c->property & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
unsigned int total_component_count = 0;
total_component_count += get_lig_num_comps (c->buffer->cur());
@ -478,7 +478,7 @@ static inline bool match_input (hb_apply_context_t *c,
return TRACE_RETURN (false);
}
is_mark_ligature = is_mark_ligature && (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
is_mark_ligature = is_mark_ligature && (property & HB_OT_LAYOUT_GLYPH_PROPS_MARK);
total_component_count += get_lig_num_comps (c->buffer->info[skippy_iter.idx]);
}
@ -530,7 +530,7 @@ static inline void ligate_input (hb_apply_context_t *c,
* https://bugzilla.gnome.org/show_bug.cgi?id=437633
*/
unsigned int klass = is_mark_ligature ? 0 : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE;
unsigned int klass = is_mark_ligature ? 0 : HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE;
unsigned int lig_id = is_mark_ligature ? 0 : allocate_lig_id (c->buffer);
unsigned int last_lig_id = get_lig_id (c->buffer->cur());
unsigned int last_num_components = get_lig_num_comps (c->buffer->cur());

View File

@ -49,6 +49,14 @@
* GDEF
*/
typedef enum {
HB_OT_LAYOUT_GLYPH_PROPS_UNCLASSIFIED = 0x0001,
HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH = 0x0002,
HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE = 0x0004,
HB_OT_LAYOUT_GLYPH_PROPS_MARK = 0x0008,
HB_OT_LAYOUT_GLYPH_PROPS_COMPONENT = 0x0010
} hb_ot_layout_glyph_class_mask_t;
/*
@ -115,7 +123,7 @@ get_lig_comp (const hb_glyph_info_t &info)
static inline unsigned int
get_lig_num_comps (const hb_glyph_info_t &info)
{
if ((info.glyph_props() & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE) && is_a_ligature (info))
if ((info.glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE) && is_a_ligature (info))
return info.lig_props() & 0x0F;
else
return 1;

View File

@ -121,6 +121,12 @@ hb_ot_layout_has_glyph_classes (hb_face_t *face)
return _get_gdef (face).has_glyph_classes ();
}
hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class (hb_face_t *face,
hb_codepoint_t glyph)
{
return (hb_ot_layout_glyph_class_t) _get_gdef (face).get_glyph_class (glyph);
}
unsigned int
hb_ot_layout_get_attach_points (hb_face_t *face,

View File

@ -51,18 +51,16 @@ hb_bool_t
hb_ot_layout_has_glyph_classes (hb_face_t *face);
typedef enum {
HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0001,
HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002,
HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 0x0004,
HB_OT_LAYOUT_GLYPH_CLASS_MARK = 0x0008,
HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 0x0010
HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0,
HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 1,
HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 2,
HB_OT_LAYOUT_GLYPH_CLASS_MARK = 3,
HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 4
} hb_ot_layout_glyph_class_t;
#ifdef HB_NOT_IMPLEMENTED
hb_ot_layout_glyph_class_t
Xhb_ot_layout_get_glyph_class (hb_face_t *face,
hb_ot_layout_get_glyph_class (hb_face_t *face,
hb_codepoint_t glyph);
#endif
#ifdef HB_NOT_IMPLEMENTED
Xhb_ot_layout_get_glyphs_in_class (hb_face_t *face,

View File

@ -348,8 +348,8 @@ hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
unsigned int count = c->buffer->len;
for (unsigned int i = 0; i < count; i++)
c->buffer->info[i].glyph_props() = _hb_glyph_info_get_general_category (&c->buffer->info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK ?
HB_OT_LAYOUT_GLYPH_CLASS_MARK :
HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
HB_OT_LAYOUT_GLYPH_PROPS_MARK :
HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH;
}
static inline void