diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index bfb3bdbfd..0696e470b 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -686,6 +686,14 @@ struct ClassDefFormat1 return TRACE_RETURN (c->check_struct (this) && classValue.sanitize (c)); } + template + 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 + 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); diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index e7fb42fa9..0ab2bc28d 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -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 diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 8b827a6ba..a0c9fe822 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -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, diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 0128534ca..4a023c4eb 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -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