From: Behdad Esfahbod Date: Tue, 26 May 2009 16:40:10 +0000 (-0400) Subject: [HB] Implement get_lig_carets() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62964afcecd96038cfaa8bc2bc931f43ee83be7e;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [HB] Implement get_lig_carets() --- diff --git a/src/hb-ot-layout-gdef-private.h b/src/hb-ot-layout-gdef-private.h index d038098..d5dac9d 100644 --- a/src/hb-ot-layout-gdef-private.h +++ b/src/hb-ot-layout-gdef-private.h @@ -50,11 +50,16 @@ ASSERT_SIZE (AttachPoint, 2); struct AttachList { - inline void get_attach_points (hb_codepoint_t glyph_id, + inline bool get_attach_points (hb_codepoint_t glyph_id, unsigned int *point_count /* IN/OUT */, unsigned int *point_array /* OUT */) const { unsigned int index = (this+coverage) (glyph_id); + if (index == NOT_COVERED) + { + *point_count = 0; + return false; + } const AttachPoint &points = this+attachPoint[index]; unsigned int count = MIN (points.len, *point_count); @@ -62,6 +67,8 @@ struct AttachList point_array[i] = points[i]; *point_count = points.len; + + return true; } private: @@ -157,11 +164,22 @@ ASSERT_SIZE (CaretValue, 2); struct LigGlyph { - friend struct LigCaretList; + inline void get_lig_carets (hb_ot_layout_t *layout, + hb_codepoint_t glyph_id, + unsigned int *caret_count /* IN/OUT */, + int *caret_array /* OUT */) const + { + + unsigned int count = MIN (carets.len, *caret_count); + for (unsigned int i = 0; i < count; i++) + caret_array[i] = (this+carets[i]).get_caret_value (layout, glyph_id); + + *caret_count = carets.len; + } private: OffsetArrayOf - caret; /* Offset rrray of CaretValue tables + carets; /* Offset rrray of CaretValue tables * --from beginning of LigGlyph table * --in increasing coordinate order */ }; @@ -169,13 +187,20 @@ ASSERT_SIZE (LigGlyph, 2); struct LigCaretList { - friend struct GDEF; - - private: - inline const LigGlyph& get_lig_glyph (hb_codepoint_t glyph_id) + inline bool get_lig_carets (hb_ot_layout_t *layout, + hb_codepoint_t glyph_id, + unsigned int *caret_count /* IN/OUT */, + int *caret_array /* OUT */) const { unsigned int index = (this+coverage) (glyph_id); - return this+ligGlyph[index]; + if (index == NOT_COVERED) + { + *caret_count = 0; + return false; + } + const LigGlyph &lig_glyph = this+ligGlyph[index]; + lig_glyph.get_lig_carets (layout, glyph_id, caret_count, caret_array); + return true; } private: @@ -207,20 +232,28 @@ struct GDEF STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1); inline bool has_glyph_classes () const { return glyphClassDef != 0; } - inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const + inline hb_ot_layout_class_t get_glyph_class (hb_ot_layout_t *layout, + hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); } inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; } - inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const + inline hb_ot_layout_class_t get_mark_attachment_type (hb_ot_layout_t *layout, + hb_codepoint_t glyph) const { return (this+markAttachClassDef).get_class (glyph); } inline bool has_attach_points () const { return attachList != 0; } - inline void get_attach_points (hb_codepoint_t glyph_id, + inline bool get_attach_points (hb_ot_layout_t *layout, + hb_codepoint_t glyph_id, unsigned int *point_count /* IN/OUT */, unsigned int *point_array /* OUT */) const - { (this+attachList).get_attach_points (glyph_id, point_count, point_array); } + { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); } inline bool has_lig_carets () const { return ligCaretList != 0; } + inline bool get_lig_carets (hb_ot_layout_t *layout, + hb_codepoint_t glyph_id, + unsigned int *caret_count /* IN/OUT */, + int *caret_array /* OUT */) const + { return (this+ligCaretList).get_lig_carets (layout, glyph_id, caret_count, caret_array); } private: FixedVersion version; /* Version of the GDEF table--initially diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 5a30f94..8f53d46 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -140,11 +140,11 @@ _hb_ot_layout_get_glyph_property (hb_ot_layout_t *layout, /* TODO old harfbuzz doesn't always parse mark attachments as it says it was * introduced without a version bump, so it may not be safe */ - klass = layout->gdef->get_mark_attachment_type (glyph); + klass = layout->gdef->get_mark_attachment_type (layout, glyph); if (klass) return klass << 8; - klass = layout->gdef->get_glyph_class (glyph); + klass = layout->gdef->get_glyph_class (layout, glyph); if (!klass && glyph < layout->new_gdef.len) klass = layout->new_gdef.klasses[glyph]; @@ -302,13 +302,22 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout, hb_ot_layout_set_glyph_class (layout, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]); } -void +hb_bool_t hb_ot_layout_get_attach_points (hb_ot_layout_t *layout, hb_codepoint_t glyph, unsigned int *point_count /* IN/OUT */, unsigned int *point_array /* OUT */) { - layout->gdef->get_attach_points (glyph, point_count, point_array); + return layout->gdef->get_attach_points (layout, glyph, point_count, point_array); +} + +hb_bool_t +hb_ot_layout_get_lig_carets (hb_ot_layout_t *layout, + hb_codepoint_t glyph, + unsigned int *caret_count /* IN/OUT */, + int *caret_array /* OUT */) +{ + return layout->gdef->get_lig_carets (layout, glyph, caret_count, caret_array); } /* diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 984243c..7759532 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -99,12 +99,18 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout, unsigned char *klasses, uint16_t count); -void +hb_bool_t hb_ot_layout_get_attach_points (hb_ot_layout_t *layout, hb_codepoint_t glyph, unsigned int *point_count /* IN/OUT */, unsigned int *point_array /* OUT */); +hb_bool_t +hb_ot_layout_get_lig_carets (hb_ot_layout_t *layout, + hb_codepoint_t glyph, + unsigned int *caret_count /* IN/OUT */, + int *caret_array /* OUT */); + /* * GSUB/GPOS */ diff --git a/src/main.cc b/src/main.cc index 11aa57d..1347cdf 100644 --- a/src/main.cc +++ b/src/main.cc @@ -159,15 +159,8 @@ main (int argc, char **argv) gdef.has_attach_points () ? "" : "no "); printf (" Has %slig carets\n", gdef.has_lig_carets () ? "" : "no "); - - for (int glyph = 0; glyph < 1; glyph++) - printf (" glyph %d has class %d and mark attachment type %d\n", - glyph, - gdef.get_glyph_class (glyph), - gdef.get_mark_attachment_type (glyph)); - - } break; + } } } }