Implement hb_ot_layout_get_glyphs_in_class()

This commit is contained in:
Behdad Esfahbod 2012-11-16 13:53:40 -08:00
parent 5a08ecf920
commit 89ca8eeb83
4 changed files with 36 additions and 3 deletions

View File

@ -686,6 +686,14 @@ struct ClassDefFormat1
return TRACE_RETURN (c->check_struct (this) && classValue.sanitize (c));
}
template <typename set_t>
inline void add_class (set_t *glyphs, unsigned int klass) const {
unsigned int count = classValue.len;
for (unsigned int i = 0; i < count; i++)
if (classValue[i] == klass)
glyphs->add (startGlyph + i);
}
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
unsigned int count = classValue.len;
for (unsigned int i = 0; i < count; i++)
@ -721,6 +729,14 @@ struct ClassDefFormat2
return TRACE_RETURN (rangeRecord.sanitize (c));
}
template <typename set_t>
inline void add_class (set_t *glyphs, unsigned int klass) const {
unsigned int count = rangeRecord.len;
for (unsigned int i = 0; i < count; i++)
if (rangeRecord[i].value == klass)
rangeRecord[i].add_coverage (glyphs);
}
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
unsigned int count = rangeRecord.len;
for (unsigned int i = 0; i < count; i++)
@ -761,6 +777,14 @@ struct ClassDef
}
}
inline void add_class (hb_set_t *glyphs, unsigned int klass) const {
switch (u.format) {
case 1: u.format1.add_class (glyphs, klass); return;
case 2: u.format2.add_class (glyphs, klass); return;
default:return;
}
}
inline bool intersects_class (const hb_set_t *glyphs, unsigned int klass) const {
switch (u.format) {
case 1: return u.format1.intersects_class (glyphs, klass);

View File

@ -337,6 +337,8 @@ struct GDEF
inline bool has_glyph_classes (void) const { return glyphClassDef != 0; }
inline unsigned int get_glyph_class (hb_codepoint_t glyph) const
{ return (this+glyphClassDef).get_class (glyph); }
inline void get_glyphs_in_class (unsigned int klass, hb_set_t *glyphs) const
{ (this+glyphClassDef).add_class (glyphs, klass); }
inline bool has_mark_attachment_types (void) const { return markAttachClassDef != 0; }
inline unsigned int get_mark_attachment_type (hb_codepoint_t glyph) const

View File

@ -128,6 +128,14 @@ hb_ot_layout_get_glyph_class (hb_face_t *face,
return (hb_ot_layout_glyph_class_t) _get_gdef (face).get_glyph_class (glyph);
}
void
hb_ot_layout_get_glyphs_in_class (hb_face_t *face,
hb_ot_layout_glyph_class_t klass,
hb_set_t *glyphs /* OUT */)
{
return _get_gdef (face).get_glyphs_in_class (klass, glyphs);
}
unsigned int
hb_ot_layout_get_attach_points (hb_face_t *face,
hb_codepoint_t glyph,

View File

@ -62,11 +62,10 @@ hb_ot_layout_glyph_class_t
hb_ot_layout_get_glyph_class (hb_face_t *face,
hb_codepoint_t glyph);
#ifdef HB_NOT_IMPLEMENTED
Xhb_ot_layout_get_glyphs_in_class (hb_face_t *face,
void
hb_ot_layout_get_glyphs_in_class (hb_face_t *face,
hb_ot_layout_glyph_class_t klass,
hb_set_t *glyphs /* OUT */);
#endif
/* Not that useful. Provides list of attach points for a glyph that a